<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/WebBristol/model/DAL/ComponentDAL.php'; $id = filter_input(INPUT_GET, 'id'); $components = ComponentDAL::findByModule($id); $result = array(); foreach ($components as $component) { $user = $component->getUser(); $idAction = 'idUser='******'&idExam=' . $component->getId(); $action = '<button id="' . $idAction . '" type="button" class="btn btn-default" data-toggle="modal" data-target="#myModal"> <span class="glyphicon glyphicon-scale"></span></button>'; $row = array("first_name" => $user->getFirstName(), "last_name" => $user->getLastName(), "module" => $component->getModule()->getTitle(), "type" => $component->getType()->getTypeName(), "mark" => $component->getMark(), "date" => $component->getDate(), "action" => $action); $result[] = $row; } echo json_encode($result);
if ($role === 'Professor') { $componentsScheduled = ComponentDAL::findByModule($module); foreach ($componentsScheduled as $componentScheduled) { $typeScheduled = $componentScheduled->getType(); if (!$componentScheduled->getIsResit() && $typeScheduled->getId() == $type) { $_SESSION['message']['warning'] = 'An ' . $typeScheduled->getTypeName() . ' has already been scheduled (' . $componentScheduled->getDate() . ') for this module.'; header('Location: ../administration/schedule'); die; } } $usersHaveModule = UserHasModuleDAL::findByModule($module); if (count($usersHaveModule) == 0) { $_SESSION['message']['warning'] = 'There is no student assigned to this module.'; header('Location: ../administration/schedule'); die; } foreach ($usersHaveModule as $userHasModule) { $component = new Component(0, 0, $dateSchedule, false); $component->setType($type); $component->setComponent(0); $component->setModule($module); $component->setUser($userHasModule->getUserId()); ComponentDAL::flush($component); } $_SESSION['message']['success'] = 'Your exam has been scheduled with success.'; header('Location: ../administration/schedule'); } else { // 403 $_SESSION['message']['danger'] = 'You can\'t access this page.'; header('Location: ../home'); }
<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/WebBristol/model/DAL/ComponentDAL.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/WebBristol/model/DAL/UserDAL.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/WebBristol/model/DAL/UserHasModuleDAL.php'; $idUser = filter_input(INPUT_POST, 'idUser'); $idExam = filter_input(INPUT_POST, 'idExam'); $mark = floatval(filter_input(INPUT_POST, 'mark')); $component = ComponentDAL::findById($idExam); $component->setMark($mark); if (ComponentDAL::flush($component)) { $module = $component->getModule(); $user = UserDAL::findById($idUser); $hasFailed = $user->hasFailed($module); $mustResit = $user->mustResit($module); $finalMark = $user->getFinalMark($module); $userHasModule = UserHasModuleDAL::findByStudentAndModule($idUser, $module->getId()); $userHasModule->setHasFailed($hasFailed); $userHasModule->setMustPay($mustResit); $userHasModule->setFinalMark($finalMark); if ($hasFailed && $mustResit) { UserHasModuleDAL::flush($userHasModule); // Send mail -> Explain which component to resit and how to pay // (Always worst component to resit) } else { if ($hasFailed && !$mustResit) { UserHasModuleDAL::flush($userHasModule); // Send mail -> Tell he has failed the module and that there is no resit } else { if (!$hasFailed && $finalMark > 0) { UserHasModuleDAL::flush($userHasModule);
public function getComponent() { $component = null; if (is_int($this->component)) { $component = ComponentDAL::findById($this->component); } else { if (is_a($this->component, "Component")) { $component = $this->component; } } return $component; }
<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/WebBristol/model/DAL/ComponentDAL.php'; $id = filter_input(INPUT_GET, 'id'); $components = ComponentDAL::findByStudent($id); $result = array(); foreach ($components as $component) { $user = $component->getUser(); $idAction = 'idUser='******'&idExam=' . $component->getId(); $action = '<button id="' . $idAction . '" type="button" class="btn btn-default" data-toggle="modal" data-target="#myModal"> <span class="glyphicon glyphicon-scale"></span></button>'; $row = array("first_name" => $user->getFirstName(), "last_name" => $user->getLastName(), "module" => $component->getModule()->getTitle(), "type" => $component->getType()->getTypeName(), "mark" => $component->getMark(), "date" => $component->getDate(), "action" => $action); $result[] = $row; } echo json_encode($result);
<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/WebBristol/model/DAL/ComponentDAL.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/WebBristol/model/DAL/UserDAL.php'; $id = filter_input(INPUT_GET, 'id'); $component = ComponentDAL::findById($id); // Recipient $to = $component->getUser()->getMail(); // Subject $subject = 'New Mark'; // Message $message = ' <html> <head> <title>New Mark</title> </head> <body> ' . $component->getUser()->getFirstName() . ' ' . $component->getUser()->getLastName() . 'Here your results of the following exercise:\\n' . $component->getModule()->getTitle() . ' ' . $component->getModule()->getNumber() . ' ' . $component->getType()->getTypeName() . ' ' . $component->getDate() . '\\n Mark : ' . $component->getMark() . '/100.\\n --------------- It is an automated email. Please do not respond.</body></html>'; // HTML Email $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional Headers $headers = 'From: "Yann"<*****@*****.**>' . "\n"; $headers .= 'Reply-To: yannbutscher@gmail.com' . "\n"; // Sending mail($to, $subject, $message, $headers); /*error_reporting(E_ALL); if(mail($to, $subject, $message, $headers))
<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/WebBristol/model/DAL/ComponentDAL.php'; $idStudent = filter_input(INPUT_GET, 'idStudent'); $idModule = filter_input(INPUT_GET, 'idModule'); $components = ComponentDAL::findByStudentAndModule($idStudent, $idModule); $result = array(); foreach ($components as $component) { $user = $component->getUser(); $row = array("module" => $component->getModule()->getTitle(), "type" => $component->getType()->getTypeName(), "mark" => $component->getMark(), "date" => $component->getDate()); $result[] = $row; } echo json_encode($result);
public function hasFailed($module) { $hasFailed = false; // Get all the exams for the current user and the given module. $exams = ComponentDAL::findLastByStudentAndModule($this->idUser, $this->getIdModule($module)); $nbExams = count($exams); if ($nbExams === 2) { $assignmentMark = 0; $examMark = 0; foreach ($exams as $exam) { if ($exam->getType()->getTypeName() === 'Assignment') { $assignmentMark = $exam->getMark(); } else { $examMark = $exam->getMark(); } } $average = ($examMark + $assignmentMark) / 2; if ($assignmentMark < 40 || $examMark < 40 || $average < 50) { $hasFailed = true; } } return $hasFailed; }