public function getContentByType() { $roots = new Roots(); $type = \Input::get('type'); switch ($type) { case "File": $response = $roots->getFiles(); break; case "Page": $response = $roots->getPages(); break; case "Assignment": $req = new AssignmentsRequest(ActionType::GET, null, false); $response = $roots->assignments($req); $return = array(); $i = 0; $assignments = array(); foreach ($response as $item) { $file = new \stdClass(); $file->id = $item->assignment_id; $file->name = $item->name; $assignments[] = $file; $i++; } return $assignments; case "Quiz": $response = $roots->getQuizzes(); break; case "ExternalTool": $response = $roots->getExternalTools(); break; default: $response = []; } return json_encode($response); }
public function addNewAssignment() { $name = \Input::get('name'); $date = \Input::get('due_at'); $due_at = new DateTime($date); $points_possible = \Input::get('points'); $assignment = new Assignment(); $assignment->name = $name; $assignment->points_possible = $points_possible; $assignment->due_at = $due_at; $req = new AssignmentsRequest(ActionType::POST, null, null, $assignment); $roots = new Roots(); $res = $roots->assignments($req); return json_encode($res); }