Ejemplo n.º 1
0
 public function run()
 {
     $course = Course::firstOrCreate(['id' => '01234567891011121314151617181920', 'name' => "+2 Science"]);
     $subject = Subject::firstOrCreate(['id' => '23456789101112131415161718192001', 'name' => "Maths", 'ref_id' => $course->id]);
     $module = Module::firstOrCreate(['id' => '12345678910111213141516171819200', 'name' => "Calculas", 'ref_id' => $subject->id]);
     $chapter = Chapter::firstOrCreate(['id' => '45678910111213141516171819200123', 'name' => "Definite Integral", 'ref_id' => $module->id]);
     $topic = Topic::firstOrCreate(['id' => '67891011121314151617181920012345', 'name' => "Introduction", 'ref_id' => $chapter->id]);
     $question = Question::firstOrCreate(['id' => '89101112131415161718192001234567', 'topic_id' => $topic->id, 'question' => "What is the value of x? (x belongs to y) ", 'type' => 2, 'rating' => 3, 'level' => 4, 'source' => null, 'status' => 1, 'subject_id' => $subject->id, 'chapter_id' => $chapter->id, 'module_id' => $module->id]);
 }
 public function getchapterIdsfromSubject($subjectids)
 {
     $qsubject = Subject::findOrFail($subjectids[0]->subject_id);
     //currently only one subject per part later can be increased
     $qchapters = [];
     //array ids of available chapters
     foreach ($qsubject->modules as $key => $module) {
         foreach ($module->chapters as $key => $chapter) {
             array_push($qchapters, $chapter);
         }
     }
     return array_pluck($qchapters, 'id');
 }
 public function getdatas(Request $request)
 {
     $dateline = null;
     $data = null;
     $sort = Input::get("sort");
     $filters = [Input::get("subject") ? Input::get("subject") : null, Input::get("chapter") ? Input::get("chapter") : null, Input::get("topic") ? Input::get("topic") : null, Input::get("rating") ? Input::get("rating") : null, Input::get("level") ? Input::get("level") : null, Input::get("type") ? Input::get("type") : null];
     $activequestions = Question::where('type', '!=', 7)->active()->orderBy("created_at", "DESC");
     //filter subject,chapter,topic
     if ($filters[2]) {
         $activequestions = $activequestions->where('topic_id', $filters[2]);
     } else {
         if ($filters[1]) {
             $activequestions = $activequestions->where('chapter_id', $filters[1]);
         } else {
             if ($filters[0]) {
                 $activequestions = $activequestions->where('subject_id', $filters[0]);
             }
         }
     }
     //filter RATING if
     if ($filters[3]) {
         $activequestions = $activequestions->where('rating', $filters[3]);
     }
     //filter LEVEL if
     if ($filters[4]) {
         $activequestions = $activequestions->where('level', $filters[4]);
     }
     //filter TYPE if
     if ($filters[5]) {
         $activequestions = $activequestions->where('type', $filters[5]);
     }
     //get the query results
     $activequestions = $activequestions->get();
     //
     if ($sort == "authorwise") {
         $data = $this->convertToAuthorwise($activequestions);
         $dateline = $this->getDateLine($activequestions);
     } else {
         if ($sort == "datewise") {
             $data = $this->convertToDatewise($activequestions);
         } else {
             $data = $this->convertToOverall($activequestions);
             $dateline = $this->getDateLine($activequestions);
         }
     }
     return view('superadmin.analytics')->with('questions', $data)->with('datelines', $dateline)->with('sort', $sort)->with('filters', $filters)->with('qtypes', \App\QuestionType::all())->with('subjects', Subject::all())->with('path', $request->path());
 }
 public function tobereviewedquestions(Request $req, $type = null)
 {
     // $type=$req->input('type',null);
     $qbCtrl = new QuestionBankController();
     $selectedSubject = Input::get('subject') ? Subject::find(Input::get('subject')) : null;
     $selectedChapter = Input::get('chapter') ? Chapter::find(Input::get('chapter')) : null;
     $selectedTopic = Input::get('topic') ? Topic::find(Input::get('topic')) : null;
     $questions = [];
     if (!$type) {
         return redirect("/admin/question-reviews/new");
         // $questions=Question::where('status','!=',1)->where('type','!=',7)->orderBy('created_at','DESC');
     } else {
         if ($type == "rejected") {
             $questions = Question::where('type', '!=', 7)->rejected()->orderBy('created_at', 'DESC');
         } else {
             if ($type == "new") {
                 $questions = Question::where('type', '!=', 7)->notreviewed()->orderBy('created_at', 'DESC');
             } else {
                 if ($type == "accepted") {
                     $questions = Question::where('type', '!=', 7)->active()->orderBy('created_at', 'DESC');
                 } else {
                     if ($type == "edited") {
                         $questions = Question::where('type', '!=', 7)->where('status', 3)->orderBy('created_at', 'DESC');
                     }
                 }
             }
         }
     }
     if ($selectedTopic) {
         $questions = $questions->where("topic_id", $selectedTopic->id)->paginate(15);
     } else {
         if ($selectedChapter) {
             $questions = $questions->where("chapter_id", $selectedChapter->id)->paginate(15);
         } else {
             if ($selectedSubject) {
                 $questions = $questions->where("subject_id", $selectedSubject->id)->paginate(15);
             } else {
                 $questions = $questions->paginate(15);
             }
         }
     }
     return view('superadmin.review_question')->with('data', $questions)->with('type', $type)->with('subjects', Subject::all())->with('path', $req->path())->with('selected', [$selectedSubject, $selectedChapter, $selectedTopic]);
 }
Ejemplo n.º 5
0
 public function subjectname()
 {
     $this->subjectname = \App\Models\Contents\Subject::find($this->subject_id)->name;
     return $this->subjectname;
 }
Ejemplo n.º 6
0
 public function getsubjects($courseid)
 {
     return Subject::where('ref_id', $courseid)->get();
 }
Ejemplo n.º 7
0
 public function getindex()
 {
     return view("superadmin.rqg", ["subjects" => Subject::all(), "chapters" => Chapter::all(), "topics" => Topic::all(), "modules" => Module::all()]);
 }