コード例 #1
0
 public function questionsbyChapterName($coursename, $subject, $chapterName)
 {
     $chapters = Chapter::where('name', $chapterName)->get();
     $chapterID = null;
     if (count($chapters) == 1) {
         $chapterID = $chapters->first()->id;
     } else {
         $subjects = Course::where('name', $coursename)->first()->subjects()->where('name', $subject)->get();
         $questions = collect([]);
         foreach ($subjects as $subject) {
             foreach ($subject->modules as $module) {
                 foreach ($module->chapters as $chapter) {
                     if ($chapter->name === $chapterName) {
                         $chapterID = $chapter->id;
                         break 3;
                     }
                 }
             }
         }
     }
     return Question::where('chapter_id', $chapterID);
 }
コード例 #2
0
 public function getfirst($typeid, $uuid)
 {
     // to get first element matching based on uuid
     switch ($typeid) {
         case 0:
             //Course
             return Course::where('id', $uuid)->first();
         case 1:
             //Subject
             # code...
             return Subject::where('id', $uuid)->first();
         case 2:
             //Module
             # code...
             return Module::where('id', $uuid)->first();
         case 3:
             //Cha[ter]
             # code...
             return Chapter::where('id', $uuid)->first();
         case 4:
             //Topic
             # code...
             return Topic::where('id', $uuid)->first();
         default:
             # code...
             break;
     }
 }
コード例 #3
0
 public function getchapters($moduleid)
 {
     $chapters = Chapter::where('ref_id', $moduleid)->get();
     foreach ($chapters as $chapter) {
         $chapter->bookmark = $chapter->userbookmark;
     }
     return $chapters;
 }