private function getQuizzesFromLms(QuizRequest $request) { if (!isset($_SESSION)) { session_start(); } $lms = strtoupper($_SESSION['lms']); if (Lms::isValidValue($lms)) { $quizzes = array(); switch ($lms) { case Lms::CANVAS: $canvasHelper = new CanvasHelper(); $quizzes = $canvasHelper->getQuizzes(); if ($request->getInclude_questions() && !is_null($request->getId())) { $canvasHelper->getQuizQuestions($request->getId()); } else { if ($request->getInclude_questions()) { foreach ($quizzes as $quiz) { $canvasHelper->getQuizQuestions($quiz->quiz_id); } } } return $this->dbHelper->getQuizzes($request); default: $canvasHelper = new CanvasHelper(); $quizzes = $canvasHelper->getQuizzes(); if ($request->getInclude_questions() && !is_null($request->getId())) { $canvasHelper->getQuizQuestions($request->getId()); } else { if ($request->getInclude_questions()) { foreach ($quizzes as $quiz) { $canvasHelper->getQuizQuestions($quiz->id); } } } return $this->dbHelper->getQuizzes($request); } } else { throw new \Exception("Invalid LMS"); } }
public function getQuizzes(QuizRequest $request) { if (!isset($_SESSION)) { session_start(); } $courseId = $_SESSION['courseID']; if ($request->getId()) { if ($request->getInclude_questions()) { return Quiz::with('questions')->where(array('quiz_id' => $request->getId(), 'course_id' => $courseId))->first(); } else { return Quiz::where(array('quiz_id' => $request->getId(), 'course_id' => $courseId))->first(); } } else { //if no moduleId was found they must want all the modules if ($request->getInclude_questions()) { return Quiz::with('questions')->where(array('course_id' => $courseId))->get(); } else { return Quiz::where(array('course_id' => $courseId))->get(); } } }
public function getQuizzes(QuizRequest $request) { if (!isset($_SESSION)) { session_start(); } $courseId = $_SESSION['courseID']; if ($request->getId()) { // return Quiz::with('content')->where(array( // 'module_id' => $request->getModuleId(), // 'module_item_id'=> $request->getModuleItemId() // ))->first(); return Quiz::where(array('id' => $request->getId(), 'course_id' => $courseId))->first(); } else { //if no moduleId was found they must want all the modules return Quiz::where(array('course_id' => $courseId))->get(); } }