Example #1
0
function delete(Exam $obj)
{
    $output = array('code' => '000', 'message' => 'Something gone wrong. Please try again', 'type' => 'danger');
    if ($obj->deleteExam($_REQUEST['id'])) {
        $output = array('code' => '200', 'message' => 'Exam deleted successfully.', 'type' => 'success');
    }
    return $output;
}
Example #2
0
 /**
  * @see cron/exam.php/cal_test_result_score()
  */
 public function cal_test_score()
 {
     try {
         $schedule = new Exam();
         $schedule->cal_test_result_score();
     } catch (Exception $e) {
         echo $e->getMessage();
     }
 }
Example #3
0
 /**
  * Retourne tous les exam enregistrés.
  * 
  * @return array[Exam] Tous les objets dans un tableau.
  */
 public static function findAll()
 {
     $mesExams = array();
     $data = BaseSingleton::select('SELECT id, module_id, label, description, ' . 'date_creation, date_passage, affiche, prixRattrapage, rattrapage ' . 'FROM exam ');
     foreach ($data as $row) {
         $exam = new Exam();
         $exam->hydrate($row);
         $mesExams[] = $exam;
     }
     return $mesExams;
 }
 public function store()
 {
     $title = Input::get('title');
     $score = Input::get('minimunScore');
     $numberOfquestions = Input::get('numberQuestions');
     $Creator = Teacher::where('id_user', '=', Auth::id())->get()->first();
     $exam = new Exam();
     $exam->title = $title;
     $exam->creator = $Creator->id;
     $exam->score = $score;
     $exam->save();
     $ex = Exam::where('title', '=', $title)->get()->first();
     $id = $ex->id;
     return View::make('questions.create', compact('id', 'numberOfquestions'));
 }
 public function run()
 {
     //DB::table('exams')->delete();
     $teacher = Teacher::where('first_name', '=', 'Luis')->get()->first();
     $exam = new Exam();
     $exam->title = 'Sumas basicas';
     $exam->creator = $teacher->id;
     $exam->score = 2;
     $exam->save();
     $teacher2 = Teacher::where('first_name', '=', 'Luis')->get()->first();
     $exam2 = new Exam();
     $exam2->title = 'Restas basicas';
     $exam2->creator = $teacher2->id;
     $exam2->score = 2;
     $exam2->save();
 }
 public function do_re_enter(Request $request)
 {
     $students = [$request->input('students')];
     // $students = [10073];
     foreach ($students as $student_id) {
         $exam = Exam::select('exams.type', 'exams.start_at', 'exams.finish_at', 'exams.name', 'exams.id')->join('subject_subjects as subsub', 'subsub.id', '=', 'exams.subject_id')->join('student_subjects as stusub', function ($j) use($student_id) {
             $j->on('stusub.subject_id', '=', 'subsub.id')->where('stusub.student_id', '=', $student_id)->where('stusub.state', '=', 'study');
         })->where(function ($query) use($request, $student_id) {
             $query->orWhereIn('exams.type', ['midterm', 'remidterm', 'activity'])->orWhereRaw('exams.id IN (SELECT ce.exam_id FROM classrooms_exam as ce
                             JOIN classrooms as c ON c.id = ce.classroom_id
                             JOIN classroom_students as cs ON cs.classroom_id = c.id
                                 AND cs.student_id = ' . $student_id . '
                             WHERE exam_id = exams.id GROUP BY ce.id)');
             if ($request->has('finalExam') == 'true') {
                 $query->orWhereIn('exams.type', ['final', 'summer', 'refinal']);
             }
         })->where('exams.semester_id', semester()->id)->where('finish_at', '>=', date('Y-m-d H:i:s'))->groupBy('exams.id')->orderBy('exams.start_at')->with(['questions' => function ($w) {
             $w->select('questionbank_questions.id', 'questionbank_questions.question', 'questionbank_questions.type');
             if ($this->randomize_questions) {
                 $w->orderByRaw('RAND()');
             } else {
                 $w->orderBy('questionbank_questions.type', 'DESC');
             }
         }, 'questions.choices' => function ($w) {
             $w->select('questionbank_choices.id', 'questionbank_choices.question_id', 'questionbank_choices.choice', 'questionbank_choices.istrue');
         }])->first();
         dd($exam);
         ExamResult::where('exam_id', $exam->id)->where('student_id', $student_id)->update(['exit_at' => '']);
     }
     return redirect()->route('exams.extends.reenter')->with('success', 'تمت العملية بنجاح');
 }
Example #7
0
 public static function getInstance()
 {
     if (null == self::$_objInstance) {
         self::$_objInstance = new Exam();
     }
     return self::$_objInstance;
 }
Example #8
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $marks = Mark::create(['exam_id' => $request->exam_id, 'student_id' => $request->student_id, 'obt_marks' => $request->obt_marks]);
     $exams = Exam::find($request->exam_id);
     $students = Student::find($request->student_id);
     $marks->exams()->save($exams);
     $marks->students()->save($students);
     return redirect('principal/create#mark-tab')->withInput();
 }
 protected function get()
 {
     header("Content-Type: application/javascript");
     $clef = filter_input(INPUT_GET, 'clef', FILTER_DEFAULT);
     if (Exam::isValidClef($clef)) {
         http_response_code(200);
     } else {
         http_response_code(400);
     }
 }
 public function run()
 {
     DB::table('exam')->truncate();
     /**
      *	Tipos de examen
      */
     $examList = [["specialityId" => '1', "examTypeId" => '1']];
     foreach ($examList as $exam) {
         Exam::create($exam);
     }
 }
 public function executeSubmitExam(sfWebRequest $request)
 {
     if ($request->isMethod(sfRequest::POST) && $request->hasParameter('security') && $request->hasParameter('year') && $request->hasParameter('descr')) {
         $files = $request->getFiles();
         $file = $files['file'];
         $descr = $request->getParameter('descr');
         if (isset($file) && strtoupper(substr($file['name'], -3, 3)) == 'PDF' && !helperFunctions::isMaliciousString($descr)) {
             if ($request->getParameter("security") != $_SESSION['securityImage']) {
                 echo "<input type='text' id='status' value='Security'/>";
                 exit;
             }
             $year = $request->getParameter("year") . $request->getParameter("term");
             // make directories if not exist
             if (!is_dir("exams/custom")) {
                 if (!mkdir("exams/custom")) {
                     echo "<input type='text' id='status' value='Moving'/>";
                     exit;
                 }
             }
             $tgt_path = "exams/custom/" . $year;
             if (!is_dir($tgt_path)) {
                 if (!mkdir($tgt_path)) {
                     echo "<input type='text' id='status' value='Moving'/>";
                     exit;
                 }
             }
             $fileName = time() . ".pdf";
             if (move_uploaded_file($file['tmp_name'], $tgt_path . "/" . $fileName)) {
                 // register in db
                 $conn = Propel::getConnection();
                 $exam = new Exam();
                 $exam->setCourseId($request->getParameter("course"));
                 $exam->setFilePath($tgt_path . "/" . $fileName);
                 $exam->setYear($year);
                 $exam->setType($request->getParameter("type"));
                 $exam->setDescr($descr);
                 $exam->save($conn);
                 // send notification email
                 $ip = $_SERVER['REMOTE_ADDR'];
                 $msg = "Submitted by " . $ip . " [id=" . $exam->getId() . "]";
                 helperFunctions::sendEmailNotice("Exam Submission", $msg);
                 echo "<input type='text' id='status' value='Success'/>";
             } else {
                 echo "<input type='text' id='status' value='Moving'/>";
             }
         } else {
             echo "<input type='text' id='status' value='PDF'/>";
         }
     }
     exit;
 }
Example #12
0
 /**
  * Handles when changes are submited to a schedule/edit
  * 
  */
 public function editSave()
 {
     $schedule_model = $this->loadModel('Schedule');
     $exam = new Exam();
     $exam->setId($_POST['examId']);
     $exam->setLocation($_POST['textLocation']);
     $exam->setDate($_POST['textDate']);
     $exam->setTime($_POST['textTime']);
     $schedule_model->editExam($exam);
 }
Example #13
0
 public function getEvaluatedScore()
 {
     if (!$this->present) {
         return 1;
     }
     $clef = $this->exam->getClef();
     $maxScore = $this->exam->getMaxScore();
     $score = $this->score;
     $result = -1;
     if (Exam::isValidClef($clef)) {
         $clef = preg_replace('/e(?!x)/', '$score', $clef);
         $clef = preg_replace('/m/', '$maxScore', $clef);
         $success = eval('$result = ' . $clef . ';');
         if ($success === false && error_get_last()) {
             return -1;
         }
         return round($result, 2);
     }
     return -1;
 }
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $examAll = Exam::model()->findAll('status=1');
     $examOption = array();
     foreach ($examAll as $exam) {
         $examOption[$exam->exam_id] = $exam->name;
     }
     $answerTypeAll = AnswerType::model()->findAll();
     $answerTypeOption = array();
     foreach ($answerTypeAll as $answerType) {
         $answerTypeOption[$answerType->answer_type_id] = $answerType->answer_type_name;
     }
     $model = $this->loadModel($id);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Session'])) {
         $model->attributes = $_POST['Session'];
         if ($model->save()) {
             $this->redirect(array('index'));
         }
     }
     $this->render('update', array('model' => $model, 'examOption' => $examOption, 'answerTypeOption' => $answerTypeOption));
 }
Example #15
0
 public function getExamsData($classid)
 {
     $colid = Session::get('user')->collegeid;
     //$colid = "bt123";
     $exams = Exam::whereRaw('collegeid = ? and classid = ?', array($colid, $classid))->get();
     $data['data'] = [];
     $i = 0;
     for ($i = 0; $i < sizeof($exams); $i++) {
         $data['data'][$i]['examname'] = $exams[$i]->examname;
         $data['data'][$i]['examdate'] = $exams[$i]->examdate;
         $data['data'][$i]['examstime'] = $exams[$i]->starttime;
         $data['data'][$i]['exametime'] = $exams[$i]->endtime;
         $data['data'][$i]['note'] = $exams[$i]->note;
         $a = $exams[$i]->id;
         $flag = Auth::user()->flag;
         if ($flag == 3) {
             $data['data'][$i]['action'] = "<a href=\"/exam/{$a}\"><button type=\"button\" class=\"btn btn-xs btn-icon-toggle\" style=\"float: right;  margin-bottom: -0.6em; margin-top: -0.5em;\" data-toggle=\"tooltip\" data-placement=\"top\" data-original-title=\"View row\"><i class=\"fa fa-copy\"></i></button></a>";
         } else {
             $data['data'][$i]['action'] = "<button type=\"button\" class=\"btn btn-xs btn-icon-toggle\" style=\"float: right; margin-bottom: -0.6em; margin-top: -0.5em; \" data-placement=\"top\" data-original-title=\"Delete row\" onclick=\"deleteexam({$a}, {$classid})\"><i class=\"fa fa-trash-o\"></i></button>\n\n            <a href=\"/exam/{$a}\">\n             <button type=\"button\" class=\"btn btn-xs btn-icon-toggle\" style=\"float: right;  margin-bottom: -0.6em; margin-top: -0.5em;\" data-toggle=\"tooltip\" data-placement=\"top\" data-original-title=\"View row\"><i class=\"fa fa-copy\"></i></button></a>";
         }
     }
     return $data;
     // return json_encode($data);
 }
Example #16
0
    function displayBody()
    {
        parent::displayBody();
        $translator = new Translator();
        $course = new Course();
        $category = new Category();
        $training = new Training();
        $t_data = $training->get(array('id' => $this->id, 'user_id' => $_SESSION['user_id']));
        $c_data = $course->get(array('id' => $t_data['course_id']));
        foreach ($c_data as $key => $val) {
            $c_data[$key] = htmlspecialchars($val, ENT_QUOTES);
        }
        $category_id = $c_data['category_id'];
        $enum = $category->enumerate();
        if ($enum) {
            foreach ($enum as $key => $val) {
                if ($val['id'] != 0) {
                    $items[$val['id']] = $val;
                }
            }
            $categories = $this->makeCategoryList($items, $category_id);
        }
        if ($t_data['status_id'] == Training::FINISHED) {
            $result = $translator->Congratulations;
            $result_class = "alert-success";
        } else {
            $result = $translator->Sorry;
            $result_class = "alert-danger";
        }
        echo <<<EOF
<div class="container-fluid">
    <div class="col-lg-10 col-lg-offset-1" id="window">
\t<h4>{$categories}</h4>
\t<h2>{$c_data[name]}</h2>
\t<h3 class="alert {$result_class}" role="alert">{$result}</h3>
\t<h4>{$translator->Result}: {$t_data[result]}% ({$t_data['answers']} / {$t_data[questions]})</h4>
\t<table class="table">
\t    <tr>
\t\t<th>#</th>
\t\t<th>{$translator->Question}</th>
\t\t<th>{$translator->Result}</th>
\t    </tr>

EOF;
        $exam = new Exam();
        $enum = $exam->enumerateResult($t_data['id']);
        $i = 1;
        foreach ($enum as $key => $e_data) {
            $answer = $e_data['result'] == 't' ? $translator->Right : $translator->Wrong;
            $class = $e_data['result'] == 't' ? "success" : "danger";
            echo <<<EOF
\t    <tr class="alert alert-{$class}" role="alert">
\t\t<td>{$i}</td>
\t\t<td>{$e_data[question]}</td>
\t\t<td >{$answer}</td>
\t    </tr>
EOF;
            $i++;
        }
        echo <<<EOF
\t</table>
    </div>
</div> <!-- /container -->

EOF;
    }
Example #17
0
 public function getExamNames()
 {
     $exam = new Exam();
     return Response::json($exam->getExamNames());
 }
Example #18
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getExam()
 {
     return $this->hasOne(Exam::className(), ['id' => 'exam_id']);
 }
 /**
  * Start browsing the directory and register files
  *
  * @return       Exception code = 400 if directory non-existent
  *               An array containing list of non-imported files if successful
  */
 public function doImport()
 {
     if (!file_exists($this->_dir)) {
         throw new Exception("directory non-existent", 400);
     }
     $errArr = array();
     $handler = opendir($this->_dir);
     // TODO: does not do recrusive listing, do we need that?
     while (false !== ($file = readdir($handler))) {
         if ($file != '.' && $file != '..') {
             $err = false;
             $pos = strrpos($file, '.');
             $fileName = strtoupper(substr($file, 0, $pos));
             $token = strtok($fileName, '_');
             $counter = 0;
             while (false !== $token) {
                 switch ($counter) {
                     case 0:
                         if (strlen($token) != 7) {
                             $err = true;
                         }
                         $rawCourseCode = $token;
                         break;
                     case 1:
                         if ($token != substr($this->_year, 0, 4)) {
                             $err = true;
                         }
                         break;
                     case 2:
                         if ($token != "EXAM") {
                             if (substr($token, 0, 5) == "EXAM(") {
                                 // name could have the following syntax: AER205S_2009_EXAM(2).pdf
                                 $count = strtok($token, '(');
                                 $count = strtok('(');
                                 $count = strtok($count, ')');
                                 if ($count === false || !is_numeric($count)) {
                                     $err = true;
                                 }
                             } else {
                                 $err = true;
                             }
                         }
                         break;
                 }
                 $token = strtok("_");
                 $counter++;
             }
             if ($counter != 3 || $err) {
                 $err = true;
             } else {
                 // assume course code is 7 chars in length with the last char being either S, F or Y
                 $part1 = substr($rawCourseCode, 0, 6);
                 //e.g. AER205
                 $part2 = substr($rawCourseCode, 6, 1);
                 //e.g. F
                 switch ($part2) {
                     case "F":
                     case "S":
                         $courseCode = $part1 . "H1";
                         $descr = $part1 . " " . $this->_year . " Official Exam" . (isset($count) ? ' (' . $count . ')' : '');
                         break;
                     case "Y":
                         $courseCode = $part1 . "Y1";
                         $descr = $part1 . " " . $this->_year . " Official Exam" . (isset($count) ? ' (' . $count . ')' : '');
                         break;
                     default:
                         $err = true;
                         break;
                 }
                 if (!$err) {
                     $conn = Propel::getConnection();
                     // check if we have exam of this descr already
                     $examArr = ExamPeer::getExamsForYearAndCourseId($courseCode, $this->_year, $conn);
                     foreach ($examArr as $ex) {
                         if ($ex->getType() == EnumItemPeer::EXAM && $ex->getDescr() == $descr) {
                             $err = true;
                             break;
                         }
                     }
                     if (!$err) {
                         // first check if course exists
                         $course = CoursePeer::retrieveByPK($courseCode, $conn);
                         if (!isset($course)) {
                             $course = new Course();
                             //$course->setDeptId(substr($courseCode, 0, 3));
                             $course->setDescr($courseCode);
                             $course->setIsEng(1);
                             $course->setId($courseCode);
                             $dept = DepartmentPeer::retrieveByPK(substr($courseCode, 0, 3), $conn);
                             if (!isset($dept)) {
                                 $dept = new Department();
                                 $dept->setId(substr($courseCode, 0, 3));
                                 $dept->setDescr(substr($courseCode, 0, 3));
                                 $dept->save($conn);
                             }
                             $course->setDepartment($dept);
                             $course->save($conn);
                         }
                         // register exam
                         $exam = new Exam();
                         $exam->setType(EnumItemPeer::EXAM);
                         $exam->setDescr($descr);
                         $exam->setCourseId($courseCode);
                         $exam->setFilePath($this->_dir . $file);
                         $exam->setYear($this->_year);
                         $exam->save();
                     }
                 }
             }
             if ($err) {
                 $errArr[] = $file;
             }
         }
     }
     closedir($handler);
     return $errArr;
 }
Example #20
0
 public function randomExam()
 {
     $request = self::$_appInstance->request();
     $data = json_decode($request->post('data'));
     $exams = array();
     //loop through exams data
     foreach ($data as $key => $value) {
         $questions = Exam::getInstance()->getRandomQuestion($value->id, $value->num);
         $exams = array_merge($exams, $questions);
     }
     $response = array('isError' => true, 'exams' => null);
     if (isset($exams)) {
         $workingQuestions = array();
         foreach ($exams as $question) {
             array_push($workingQuestions, $question['id']);
         }
         $_SESSION['random_questions'] = serialize($exams);
         $_SESSION['questions_id'] = serialize($workingQuestions);
         $response['isError'] = false;
         $response['exams'] = self::processExam($exams);
         $response['questions_id'] = $_SESSION['questions_id'];
     } else {
         $response['error_text'] = 'ไม่พบข้อมูลข้อสอบ';
     }
     echo json_encode($response);
 }
Example #21
0
 public function results($course)
 {
     $exams = \Exam::all(array("course_id = ?" => $course->id), array("year", "type", "id"));
     $result = array();
     foreach ($exams as $e) {
         $whole_class = \ExamResult::all(array("exam_id = ?" => $e->id), array("marks", "user_id"));
         $total = 0;
         $highest = -1;
         $count = 0;
         $user_marks = 0;
         foreach ($whole_class as $w_c) {
             $total += $w_c->marks;
             if ((int) $w_c->marks > $highest) {
                 $highest = (int) $w_c->marks;
             }
             if ($w_c->user_id == self::$_student->user_id) {
                 $user_marks = (int) $w_c->marks;
             }
             ++$count;
         }
         $data = array("type" => $e->type, "year" => $e->year, "exam_id" => $e->id, "marks" => $user_marks, "highest" => $highest, "average" => $total / $count);
         $data = ArrayMethods::toObject($data);
         $result[] = $data;
     }
     return $result;
 }
 /**
  * @expectedException mdagostino\MultipleChoiceExams\ExpiredTimeException
  * @expectedExceptionMessage There is no left time to complete the exam.
  */
 public function testTimeLeftZero()
 {
     // This test checks if the questions are not available to be answered
     // when the time to complete the exam is exactly the duration of the exam.
     $exam = new Exam();
     $exam->setDuration(30);
     $examTimer = \Mockery::mock('ExamTimer');
     // The time is in seconds, 30 minutes are 1800 seconds.
     $examTimer->shouldReceive('getTime')->andReturn(0, 1000, 1800);
     $exam->setTimer($examTimer);
     for ($i = 0; $i < 10; $i++) {
         $available_answers = array('one', 'two', 'three');
         $right_answers = array('one', 'three');
         $question = new Question();
         $question->setTitle('Question ' . $i)->setDescription('Description for question ' . $i)->setAvailableAnswers($available_answers)->setRightAnswers($right_answers);
         $questions[] = $question;
     }
     $exam->setQuestions($questions);
     $exam->start();
     $exam->answerQuestion(0, array('one'));
     $exam->answerQuestion(1, array('one', 'two'));
     $exam->answerQuestion(2, array('one', 'three'));
     $exam->finalize();
     $this->assertFalse($exam->isApproved());
 }
 /**
  * Add a like  
  */
 public function addAction()
 {
     if (isset($_SESSION['connected']) && $_SESSION['connected'] == TRUE) {
         $tableau = array();
         $tableau[0] = 'none';
         $tableau[1] = 'none';
         $tableau[2] = 'none';
         $tableau[3] = 'none';
         $this->activeBar = $tableau;
         if ($_SESSION['isAdmin'] == 1) {
             $this->result = TRUE;
             if (isset($_POST['idAdd']) && $_POST['idAdd'] > 0) {
                 $_SESSION['idAdd'] = $_POST['idAdd'];
             }
             // update: save
             if (isset($_POST['content']) && strlen($_POST['content']) > 0 && $_POST['service'] != "-" && $_SESSION['idAdd'] > 0) {
                 $update = new Exam();
                 $update->save($_POST['content'], $_POST['service'], $_SESSION['idAdd'], $_SESSION['idMember']);
                 unset($_POST);
                 unset($_SESSION['idAdd']);
                 $this->redirect('/profile/view');
             }
         } else {
             $this->result = FALSE;
             $this->redirect('/index/index');
         }
     } else {
         $this->redirect('/index/index');
     }
 }
Example #24
0
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
require_once '../../model/class/Exam.php';
require_once '../../model/DAL/ExamDAL.php';
require_once '../../model/class/Assignment.php';
require_once '../../model/DAL/AssignmentDAL.php';
require_once '../../model/class/Module.php';
require_once '../../model/DAL/ModuleDAL.php';
//===Création du module====
$newModule = new Module();
$newAssignment = new Assignment();
$newExam = new Exam();
//regex opur les date format YYYY/MM/DD
$myregex = "~^[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}\$~";
//********CREATION MODULE *******
//Vérifie ce qui est renvoyer par le POST de /view/phtml/module_create.php
//et set de l'objet newModule au fur et à mesure
$validModuleLabel = filter_input(INPUT_POST, 'label', FILTER_SANITIZE_STRING);
$newModule->setLabel($validModuleLabel);
$validModuleNumber = filter_input(INPUT_POST, 'moduleNumber', FILTER_SANITIZE_NUMBER_INT);
$newModule->setNumber($validModuleNumber);
$validModuleDescription = filter_input(INPUT_POST, 'descriptionModule', FILTER_SANITIZE_STRING);
$newModule->setDescription($validModuleDescription);
$newModule->setBareme(1);
//barème par defaut
$newModule->setAffiche(1);
//visible
Example #25
0
 /**
  * Retourne tous les exam avec rattrapage à .
  *
  * @return Exam Tous les objets dans un tableau.
  */
 public static function findAllRattrapageExam($moduleId)
 {
     $data = BaseSingleton::select('SELECT exam.id, exam.module_id, ' . 'exam.label, ' . 'exam.description, exam.date_creation, ' . 'exam.date_passage, exam.affiche, ' . 'exam.prixRattrapage, exam.rattrapage ' . 'FROM module, assignment, exam ' . 'WHERE module.id = exam.module_id AND module.id = exam.module_id ' . ' AND exam.rattrapage = 1' . ' AND module.id = ? ' . 'GROUP BY module.id', array('i', &$moduleId));
     $rattrapageExam = new Exam();
     if (sizeof($data) <= 0) {
         return false;
     } else {
         $rattrapageExam->hydrate($data[0]);
     }
     return $rattrapageExam;
 }
Example #26
0
 private function _findStudents()
 {
     $session = Registry::get("session");
     if (RequestMethods::post("action") == "findStudents") {
         $exam = RequestMethods::post("exam");
         preg_match("/(.*);(.*)/", $exam, $matches);
         $exam_type = $matches[1];
         $exam_year = $matches[2];
         $classroom_id = RequestMethods::post("classroom_id");
         $grade_id = RequestMethods::post("grade");
         $enrollments = Enrollment::all(array("classroom_id = ?" => $classroom_id));
         $exams = Exam::all(array("grade_id = ?" => $grade_id, "type = ?" => $exam_type), array("id", "grade_id", "course_id"));
         $courses = Course::all(array("organization_id = ?" => $this->organization->id), array("title", "id"));
         $arr = array();
         foreach ($courses as $c) {
             $arr["{$c->id}"] = $c->title;
         }
         $courses = array();
         foreach ($exams as $e) {
             $courses[] = array("title" => $arr["{$e->course_id}"], "id" => $e->course_id);
         }
         $courses = ArrayMethods::toObject($courses);
         $session->set('Exams\\Result:$exams', $exams);
         $session->set('Exams\\Result:$grade_id', $grade_id);
         return array("courses" => $courses, "exams" => $exams, "enrollments" => $enrollments);
     }
     return false;
 }
Example #27
0
                                    </p>
                                </div>
                         <div class="tab-pane fade" id="profile">
                              <p>
                                      
                                <table class="table">
                                    <thead>
                                        <tr>
                                            <th>#</th>
                                            <th>Exam</th>
                                            <th>Start Date</th>
                                             </tr>
                                    </thead>
                                    <tbody>
                                        <?php 
$exams = Exam::all();
?>
                                        @foreach($exams as $exam)
                                        <tr>
                                            <td>{{$exam->id}}</td>
                                            <td>{{$exam->name}} <?php 
echo "[";
?>
{{$exam->examType->name}}<?php 
echo "]";
?>
</td>
                                            <td>{{$exam->start_date}}</td>
                                            <td>
                                                <a href="{{ URL::route('edit-exam' ,array('id'=>$exam->id))}}"
    data-toggle="tooltip" data-placement="left" title="Edit {{ $exam->name }} {{ $exam->start_date}} " >
Example #28
0
<?php

require_once 'Repository/Exam.php';
require_once 'libs/Membership.php';
require_once 'Repository/ExamStore.php';
$user_id = $_POST['user_id'];
$exam_id = $_POST['exam_id'];
$exam = Exam::getInstance();
$questions = $exam->getExistingExam($exam_id);
$index = 1;
$html = '';
$tempData = array();
if (isset($questions) && $questions != null) {
    //validate null
    foreach ($questions as $question) {
        $tempData[$index]['question_id'] = $question['question_id'];
        $tempData[$index]['answer'] = $question['answer'];
        $index++;
    }
    $content = "<tr><td>ข้อสอบข้อที่</td><td>หมายเลขข้อสอบจากคลังข้อสอบ</td><td>เฉลย</td></tr>";
    $flag = false;
    $index = 1;
    foreach ($tempData as $answer) {
        $content .= "<tr><td>{$index}</td><td>" . $answer['question_id'] . "</td> <td>" . $answer['answer'] . "</td></tr>";
        $index++;
    }
    header("Content-type: application/vnd.ms-excel");
    header("Content-Disposition: attachment;Filename=เฉลยปัญหาข้อสอบ.xls");
    header("Pragma: no-cache");
    header("Expires: 0");
    echo "<html>";
 protected function edit()
 {
     if (preg_match("@^.*/edit-note@", $_SERVER['REQUEST_URI'])) {
         $note = filter_input(INPUT_POST, 'note', FILTER_DEFAULT);
         $id = filter_input(INPUT_POST, 'id', FILTER_VALIDATE_INT);
         $this->mysqlAdapter->updateExamNote($id, $note);
         $this->index();
     } else {
         if (preg_match("@^.*/edit-score@", $_SERVER['REQUEST_URI'])) {
             $scoreId = filter_input(INPUT_POST, 'scoreId', FILTER_VALIDATE_INT);
             $studentId = filter_input(INPUT_POST, 'studentId', FILTER_VALIDATE_INT);
             $present = filter_input(INPUT_POST, 'present', FILTER_VALIDATE_BOOLEAN);
             if (!$present) {
                 $present = false;
             }
             $score = filter_input(INPUT_POST, 'score', FILTER_VALIDATE_FLOAT);
             $this->mysqlAdapter->updateScore($scoreId, $studentId, $present, $score);
             $examId = $this->mysqlAdapter->getExamIdOfScore($scoreId);
             $this->showExam($examId);
         } else {
             $id = filter_input(INPUT_POST, 'examId', FILTER_VALIDATE_INT);
             $subject = filter_input(INPUT_POST, 'subject', FILTER_VALIDATE_INT);
             $schoolClass = filter_input(INPUT_POST, 'schoolClass', FILTER_VALIDATE_INT);
             $clef = filter_input(INPUT_POST, 'clef', FILTER_DEFAULT);
             if (!Exam::isValidClef($clef)) {
                 throw new Exception('manipulation');
             }
             $date = filter_input(INPUT_POST, 'date', FILTER_DEFAULT);
             if (!$date) {
                 throw new Exception('manipulation');
             }
             $maxScore = filter_input(INPUT_POST, 'maxScore', FILTER_VALIDATE_FLOAT);
             $this->mysqlAdapter->editExam($id, $subject, $schoolClass, $clef, $date, $maxScore, $note = NULL);
             $this->index();
         }
     }
 }
Example #30
0
<?php

/**
 * Created by PhpStorm.
 * User: Dushyant
 * Date: 2015-11-20
 * Time: 11:10 AM
 */
//todo Display assigned sessions on login on click start session redirect to list of available patients
//required location class
require_once '../../Local/Classes/class.Exam.php';
include "header.php";
include "sidebar.php";
//create exam object
$exam = new Exam();
$examList = $exam->selectAllExams();
?>
<form role="form" id="frm">
    <div class="form-group">
        <div id="page-wrapper">
            <div class="row">
                <div class="col-lg-12">
                    <h1 class="page-header">Dash Board</h1>
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row1 -->
            <!-- /.row 5-->
            <div class="row">
                <div class="col-lg-12">