Ejemplo n.º 1
0
 public function getAnalyticsAssignmentData($includeTags = false)
 {
     if (!isset($_SESSION)) {
         session_start();
     }
     $lms = strtoupper($_SESSION['lms']);
     if (Lms::isValidValue($lms)) {
         switch ($lms) {
             case Lms::CANVAS:
                 $canvasHelper = new CanvasHelper();
                 $data = json_decode($canvasHelper->getAnalyticsAssignmentData());
                 if ($includeTags) {
                     $result = [];
                     foreach ($data as $item) {
                         $item->tags = $canvasHelper->matchAssignmentIdWithTags($item->assignment_id);
                         $result[] = $item;
                     }
                     return $result;
                 }
                 return $data;
             default:
                 $canvasHelper = new CanvasHelper();
                 $data = json_decode($canvasHelper->getAnalyticsAssignmentData());
                 if ($includeTags) {
                     $result = [];
                     foreach ($data as $item) {
                         $item->tags = $canvasHelper->matchAssignmentIdWithTags($item->assignment_id);
                         $result[] = item;
                     }
                     return $result;
                 }
                 return $data;
         }
     } else {
         throw new \Exception("Invalid LMS");
     }
 }