public function skillsAction($raw = false, $debug = false)
 {
     $this->view->disable();
     // Get our context (this takes care of starting the session, too)
     $context = $this->getDI()->getShared('ltiContext');
     if (!$context->valid) {
         echo '[{"error":"Invalid lti context"}]';
         return;
     }
     $skillsHelper = new SkillsHelper();
     $stats = ['student' => [['id' => 'time', 'score' => $skillsHelper->calculateTimeScore($context->getUserName(), $raw, $debug)], ['id' => 'activity', 'score' => $skillsHelper->calculateActivityScore($context->getUserName(), $raw, $debug)], ['id' => 'consistency', 'score' => $skillsHelper->calculateConsistencyScore($context->getUserName(), $raw, $debug)], ['id' => 'awareness', 'score' => $skillsHelper->calculateAwarenessScore($context->getUserName(), $raw, $debug)], ['id' => 'deepLearning', 'score' => $skillsHelper->calculateDeepLearningScore($context->getUserName(), $raw, $debug)], ['id' => 'persistence', 'score' => $skillsHelper->calculatePersistenceScore($context->getUserName(), $raw, $debug)]], 'class' => [['id' => 'time', 'score' => 5], ['id' => 'activity', 'score' => 5], ['id' => 'consistency', 'score' => 5], ['id' => 'awareness', 'score' => 5], ['id' => 'deepLearning', 'score' => 5], ['id' => 'persistence', 'score' => 5]]];
     echo json_encode($stats);
 }
コード例 #2
0
 public function dailyAction()
 {
     $config = $this->getDI()->getShared('config');
     if (!isset($_GET["p"])) {
         die("No history saver password provided.");
     }
     if ($_GET["p"] != $config->historySaverPassword) {
         die("Invalid history saver password provided.");
     }
     // We want to time this
     $startTime = microtime(true);
     $raw = false;
     $debug = false;
     $skillsHelper = new SkillsHelper();
     $classHelper = new ClassHelper();
     $studentIds = $classHelper->allStudents();
     //$studentIds = ["John Logie Baird"];
     // Update skill scores for every student, and save history
     foreach ($studentIds as $studentId) {
         // TODO make this more efficient
         $escStudentId = str_replace("'", "", $studentId);
         $history = new SkillHistory();
         $history->email = $escStudentId;
         $history->time = $skillsHelper->calculateTimeScore($studentId, $raw, $debug);
         $history->activity = $skillsHelper->calculateActivityScore($studentId, $raw, $debug);
         $history->consistency = $skillsHelper->calculateConsistencyScore($studentId, $raw, $debug);
         $history->awareness = $skillsHelper->calculateAwarenessScore($studentId, $raw, $debug);
         $history->deep_learning = $skillsHelper->calculateDeepLearningScore($studentId, $raw, $debug);
         $history->persistence = $skillsHelper->calculatePersistenceScore($studentId, $raw, $debug);
         if ($history->create() == false) {
             echo "*** Error saving history for {$studentId}\n";
         } else {
             echo "    Successfully saved history for {$studentId}\n";
         }
     }
     // Print total time taken
     $endTime = microtime(true);
     echo "Execution time: " . ($endTime - $startTime) . " seconds\n";
 }
コード例 #3
0
 public function timeAction()
 {
     $this->view->disable();
     $context = $this->getDI()->getShared('ltiContext');
     $sh = new SkillsHelper();
     echo $sh->calculateTimeScore($context->getUserName(), true, true);
 }