Beispiel #1
0
 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");
     }
 }
Beispiel #2
0
 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();
                 $canvasHelper->getQuizzes($request);
                 return $this->dbHelper->getQuizzes($request);
             default:
                 $canvasHelper = new CanvasHelper();
                 $canvasHelper->getQuizzes($request);
                 return $this->dbHelper->getQuizzes($request);
         }
     } else {
         throw new \Exception("Invalid LMS");
     }
 }
Beispiel #3
0
 public function testSubmitQuiz()
 {
     if (!isset($_SESSION)) {
         session_start();
     }
     $userId = $_SESSION['userID'];
     $quizId = 621753;
     $dbHelper = new DbHelper();
     $canvasHelper = new CanvasHelper();
     //        $canvasHelper->postQuizTakingSession($quizId);
     $quizSubmission = $dbHelper->getQuizSubmission($quizId, $userId);
     $result = $canvasHelper->postSubmitQuiz($quizSubmission);
     echo json_encode($result);
 }
Beispiel #4
0
 public function test()
 {
     $quizId = 623422;
     $questionId = 10897397;
     $canvasHelper = new CanvasHelper();
     $dbHelper = new DbHelper();
     $res = $canvasHelper->postQuizTakingSession($quizId);
     echo json_encode($res);
     //        $canvasHelper->getQuizSubmissionsFromCanvas($quizId);
     //        $req = new ModulesRequest(ActionType::GET, 380206, null, true, true, null, null , false);
     //        $db = new \Delphinium\Roots\DB\DbHelper();
     //        $res = $db->getModuleData($req);
     //
     //        echo json_encode($res);
     //        $this->convertDatesUTCLocal();
     //        $now = new DateTime(date("Y-m-d"));
     //        echo json_encode($now);
     //
     //
     //
     //        $rb = new RuleBuilder;
     //
     //        $bonus_90 = $rb->create('current_user_submissions', 'submission',
     //        $rb['submission']['score']->greaterThan($rb['score_threshold']),
     //        [
     //            $rb['(bonus)']->assign($rb['(bonus)']->add($rb['points']))
     //        ]);
     //
     //        $rb['(bonus)'] = 0;
     //        $rb['submission']['score'] = 0;
     //        $rb['score_threshold'] = 0;
     //        $rb['point'] = 0;
     //
     //        $rg = new RuleGroup('submissionstest');
     //        $rg->add($bonus_90);
     //        $rg->saveRules();
     //        $manager = ComponentManager::instance();
     //       echo json_encode($manager->listComponents());
 }