/** * Create a new Enrollment instance. * * @param int $idCourse * @param int $idUser * @return int $idEnrollment */ public static function enroll($idCourse, $idUser, $end_at = Null) { $app = \Slim\Slim::getInstance(); $user = UserController::findUser($idUser); $course = CourseController::getCourseDetails($idCourse); if ($end_at && date('Y-m-d H:i:s') > $end_at) { $app->halt("400", json_encode("Enrollment already expired. Please check the end date.")); } $data = array('user_id' => $idUser, 'course_id' => $idCourse); $enrollment = Enrollment::firstOrNew($data); // if there is scorm cloud id then enroll in scorm cloud if (isset($course->scorm_id)) { $scormRegistrationId = ScormCloudAPIController::register($idCourse, $idUser); if (isset($scormRegistrationId)) { $enrollment->scorm_registration_id = $scormRegistrationId; $enrollment->scorm_status = "enrolled"; } } if (!$enrollment->id) { $enrollment->isSafety = $course->safety; $enrollment->end_at = $end_at; $enrollment->save(); } else { $enrollment->end_at = $end_at; //echo $enrollment->end_at; $enrollment->save(); } return $enrollment->id; }
/** * @api {get} /managers/:id/bin Get Items in Manager's Content Bin * @apiName Get Items in Manager's Content Bin * @apiDescription As a manager, any content I purchased will be shown in my bin. When an item reaches its expiration date, change the date to read 'EXPIRED'. Keep listing 'EXPIRED' items in this way for 30 days. * @apiGroup Manager * @apiHeader (Header) {String} X_Authorization Authorization value. * @apiParam {Number} id Users unique ID. * * @apiSuccessExample {json} Success-Response: * HTTP/1.1 200 OK * { * "id": 14, * "quantity": 1, * "expiration_dt": "2015-11-30 00:00:00", * "created_at": "2015-11-19 14:12:30", * "updated_at": "2015-11-19 14:12:30", * "course_id": 45950, * "course_name": "Scotsman: Prodigy Eclipse Ice Cuber EH222", * "course_type": "course", * "restrictions":{ * "prerequisite":[], * "expiration":"" * } * } * */ public static function getBin($idUser) { GroupController::isAdmin($idUser); $bins = Manager_Bin::where('user_id', '=', $idUser)->get(); $result = []; foreach ($bins as &$bin) { unset($bin->user_id); unset($bin->company_id); $course = Price::find($bin->course_sale_id)->course; unset($bin->course_sale_id); $bin['course_id'] = $course->id; $bin['course_name'] = $course->name; $bin['course_type'] = $course->type; $expired_dt = new DateTime($bin['expiration_dt']); $now = new DateTime(); $diff = $now->diff($expired_dt, false); //var_dump($diff); $restrictions = []; //echo $diff->format("%R%a"); if ($diff->format("%R%a") >= 0) { $pre = CourseController::getCoursePrerequisites($course->id); if ($pre) { $restrictions['prerequisite'] = $pre; } } else { if ($diff->format("%R%a") > -30) { $bin['expiration_dt'] = "EXPIRED"; $restrictions['expiration'] = 'This content has expired. You cannot assign or transfer this content. You may renew this content for 30 days after the expiration at the renewal price.'; } else { continue; } } $bin['restrictions'] = $restrictions; array_push($result, $bin); } return json_encode($result); }
case 'POST': CourseController::create($_POST); break; case 'GET': if (isset($request) && !empty($request) && $request[0] !== '') { if ($request[0] == 'check') { $field = $request[1]; $value = $request[2]; $id = $request[3]; CourseController::check($field, $value, $id); } elseif ($request[0] == 'signup') { CourseController::readSignup(); } else { $id = $request[0]; CourseController::detail($id); } } else { CourseController::read(); } break; case 'DELETE': if (isset($request) && !empty($request) && $request[0] !== '') { $id = $request[0]; CourseController::delete($id); } break; default: print json_encode('ENTRANCE EXAM API v.0.1 developed by: Philip Cesar B. Garay'); break; } exit;
<?php require 'PHP/CourseController.php'; $courseController = new CourseController(); $courseTables = ""; if (!empty($_POST)) { $year = isset($_POST['year']) ? $_POST['year'] : NULL; $semester = isset($_POST['semester']) ? $_POST['semester'] : NULL; $department = isset($_POST['department']) ? $_POST['department'] : NULL; $course = isset($_POST['course']) ? $_POST['course'] : NULL; $professor = isset($_POST['professor']) ? $_POST['professor'] : NULL; $minrating = isset($_POST['minrating']) ? $_POST['minrating'] : NULL; $maxrating = isset($_POST['maxrating']) ? $_POST['maxrating'] : NULL; $courseTables = $courseController->CreateCourse($year, $semester, $department, $course, $professor, $minrating, $maxrating); } $title = 'Course overview'; $contentCourse = $courseController->CreateCourseList(); $contentDepartment = $courseController->CreateDepartmentList(); $contentProfessor = $courseController->CreateProfessorList(); include 'index.php';
}); // Radan esittelysivu $routes->get('/course/:courseid', 'check_logged_in', function ($courseid) { CourseController::show($courseid); }); // Radan muokkauslomakkeen esittäminen (vain admin) $routes->get('/course/:courseid/edit', 'check_admin_logged_in', function ($courseid) { CourseController::edit($courseid); }); // Radan muokkaaminen (vain admin) $routes->post('/course/:courseid/edit', 'check_admin_logged_in', function ($courseid) { CourseController::update($courseid); }); // Radan poisto (vain admin) $routes->post('/course/:courseid/destroy', 'check_admin_logged_in', function ($courseid) { CourseController::destroy($courseid); }); // Pelit // Pelien listaussivu $routes->get('/game', 'check_logged_in', function () { GameController::index(); }); // Pelin lisääminen tietokantaan $routes->post('/game', 'check_logged_in', function () { GameController::store(); }); // Pelin lisäyssivu $routes->get('/game/new', 'check_logged_in', function () { GameController::create(); }); // Pelin esittelysivu
<?php if (!$_POST['isAjax']) { } require_once './.env.php'; require_once './Model/CourseModel.php'; require_once './Controller/CourseController.php'; $controller = new CourseController(); if (isset($_POST['action']) && !empty($_POST['action'])) { switch ($_POST['action']) { case 'newCourse': echo $controller->create(); break; case 'removeCourse': echo $controller->removeCourse($_POST['courseId']); break; case 'storeCourse': echo $controller->storeCourse($_POST['form']); break; default: die; //TODO return error for ajax } } else { echo $controller->index(); }
$Course->set_id($_POST['id']); $Course = $this->courserepository->update($Course); header("location:index.php?page=Course&action=success"); } } public function delete() { $id = $_GET['id']; $this->courserepository->delete($id); header("Location: index.php?page=Course&action=delete"); } } if (isset($_GET['m'])) { $method = $_GET['m']; } else { $method = "index"; } $Coursecontroller = new CourseController(); switch ($method) { case 'add': $Coursecontroller->add(); break; case 'edit': $Coursecontroller->edit(); break; case 'delete': $Coursecontroller->delete(); break; default: $Coursecontroller->index(); }
CourseController::create(); }); $routes->get('/course/:id', function ($id) { CourseController::show($id); }); $routes->get('/course/:id/add', 'check_logged_in', function ($id) { RoundController::create($id); }); $routes->get('/course/:id/edit', 'check_logged_in', function ($id) { CourseController::edit($id); }); $routes->post('/course/:id/edit', 'check_logged_in', function ($id) { CourseController::update($id); }); $routes->post('/course/:id/destroy', 'check_logged_in', function ($id) { CourseController::destroy($id); }); ## Round $routes->get('/round', function () { RoundController::list_all(); }); $routes->post('/round', function () { RoundController::store(); }); $routes->get('/round/new', function () { RoundController::create(); }); $routes->post('/round/new', function () { RoundController::create(); }); $routes->get('/round/:id', function ($id) {