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]); }
public function getallquestionsbyChapterID($id, $level, $type, $ratings) { $chapter = \App\Models\Contents\Chapter::find($id); // $questions = []; foreach ($chapter->topics as $key => $topic) { $tQuestions = $topic->questions()->where('level', $level)->where('type', $type)->whereIn('rating', $ratings)->where('status', 1)->get(); //inject chapterid foreach ($tQuestions as $key => $tq) { $tq->chapter_id = $id; } if (count($tQuestions) > 0) { array_push($questions, $tQuestions->toArray()); } } return $questions; }