public function resourceRecommendationsAction($scope, $groupingId, $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;
     }
     if (!isset($groupingId)) {
         echo '[{"error":"No scope grouping ID specified"}]';
         return;
     }
     // Get the list of resources associated with concepts for the given scope and grouping ID
     $resources = [];
     switch ($scope) {
         case "concept":
             // Filter based on concept
             $resources = MappingHelper::resourcesForConcept($groupingId);
             break;
         default:
             // We currently only need resources for a selected concept
             echo '[{"error":"Invalid scope option"}]';
             return;
             break;
     }
     echo json_encode($resources);
 }
 public function mappingsAction()
 {
     echo "<pre>";
     echo "All units\n";
     print_r(MappingHelper::allUnits());
     echo "<hr>Concepts in unit 4\n";
     print_r(MappingHelper::conceptsInUnit("4"));
     echo "<hr>Questions in concept (lecture number) 1\n";
     print_r(MappingHelper::questionsInConcept("1"));
     echo "<hr>Question info for question 78.4\n";
     print_r(MappingHelper::questionInformation("78.4"));
     echo "<hr>Videos for concept 9\n";
     print_r(MappingHelper::videosForConcept("9"));
     echo "<hr>Resources for concept 1\n";
     print_r(MappingHelper::resourcesForConcept("1"));
     echo "<hr>Concepts within the past 2 weeks: \n";
     print_r(MappingHelper::conceptsWithin2Weeks());
 }
 public function resourcesAction()
 {
     $this->tag->setTitle('Course Resources | Student Dashboard');
     $this->view->pageTitle = 'Course Resources | Student Dashboard';
     // Get our context (this takes care of starting the session, too)
     $context = $this->getDI()->getShared('ltiContext');
     // Get list of concepts
     $conceptsMapping = MappingHelper::allConcepts();
     $concepts = [];
     $resources = [];
     // Get list of resources for each concept
     foreach ($conceptsMapping as $c) {
         // Formatting for view
         $concepts[] = ["id" => $c["Lecture Number"], "title" => $c["Concept Title"], "date" => $c["Date"]];
         // Get resources for each of the concepts
         $conceptId = $c["Lecture Number"];
         $resourceLists[$conceptId] = MappingHelper::resourcesForConcept($conceptId);
         // Get videos for each of the concepts
         $videos = MappingHelper::videosForConcept($conceptId);
         // Format videos to be the same format as ayamel links from the resources.csv mapping
         foreach ($videos as $video) {
             $resourceLists[$conceptId][] = ["Lecture Number" => $video["Lecture Number"], "Resource Type" => "ayamel", "Resource Title" => $video["Video Title"], "Resource Link" => $video["Video ID"], "Resource Tracking Number" => $video["Video ID"]];
         }
     }
     // Figure out which concept to position the list at (based on the current day)
     $currentConceptID = $conceptsMapping[0]["Date"];
     // This is assuming that every concept has a date, and that they are listed in concepts.csv in chronological non-descending order
     // Find the first concept that's past today, and then use the previous concept
     $today = strtotime("today");
     foreach ($conceptsMapping as $concept) {
         if (strtotime($concept["Date"]) > $today) {
             break;
         } else {
             $currentConceptID = $concept["Lecture Number"];
             // If this concept has a date of today, then stop
             if (strtotime($concept["Date"]) == $today) {
                 break;
             }
         }
     }
     $this->view->concepts = $concepts;
     $this->view->resources = $resourceLists;
     $this->view->currentConceptID = $currentConceptID;
 }