Beispiel #1
0
 public function grade_exam()
 {
     $exam_id = DB::escape($this->post->exam_id);
     $howmany = DB::escape($this->post->howmany);
     $exam_description = DB::escape($this->post->exam_description);
     $passing = DB::escape($this->post->passing);
     $version = DB::escape($this->post->version);
     $i = 1;
     $correct = 0;
     $this->set('title', $exam_description);
     $this->show('exams/exam_question_result_header');
     while ($i <= $howmany) {
         $id = 'question_id' . $i;
         $question_id = DB::escape($this->post->{$id});
         $id2 = 'question' . $i;
         $answer = DB::escape($this->post->{$id2});
         $cor = ExamsData::compare_answer($question_id, $answer);
         if ($cor->correct_answer == $answer) {
             Template::ClearVars($wrong);
             $question = ExamsData::get_question($question_id);
             $this->set('question', $question->question);
             if ($question->correct_answer == '1') {
                 $this->set('answer', $question->answer_1);
             } elseif ($question->correct_answer == '2') {
                 $this->set('answer', $question->answer_2);
             } elseif ($question->correct_answer == '3') {
                 $this->set('answer', $question->answer_3);
             } elseif ($question->correct_answer == '4') {
                 $this->set('answer', $question->answer_4);
             }
             $this->set('number', $i);
             $this->set('div', 'success');
             $this->show('exams/exam_question_result');
             $correct++;
         } else {
             $question = ExamsData::get_question($question_id);
             $this->set('question', $question->question);
             if ($question->correct_answer == '1') {
                 $this->set('answer', $question->answer_1);
             } elseif ($question->correct_answer == '2') {
                 $this->set('answer', $question->answer_2);
             } elseif ($question->correct_answer == '3') {
                 $this->set('answer', $question->answer_3);
             } elseif ($question->correct_answer == '4') {
                 $this->set('answer', $question->answer_4);
             }
             if ($answer == '1') {
                 $this->set('wrong', $question->answer_1);
             } elseif ($answer == '2') {
                 $this->set('wrong', $question->answer_2);
             } elseif ($answer == '3') {
                 $this->set('wrong', $question->answer_3);
             } elseif ($answer == '4') {
                 $this->set('wrong', $question->answer_4);
             }
             $this->set('number', $i);
             $this->set('div', 'error');
             $this->show('exams/exam_question_result');
         }
         $i++;
     }
     $result = round($correct / $howmany * 100, 0);
     if ($result >= $passing) {
         $passfail = 1;
     } else {
         $passfail = 0;
     }
     $pid = Auth::$userinfo->pilotid;
     $approve = ExamsData::get_setting_info('5');
     if ($approve->value == '1') {
     }
     ExamsData::unassign_exam($pid, $exam_id);
     ExamsData::record_results($pid, $exam_id, $exam_description, $result, $passfail, $version);
     if ($result >= $passing) {
         echo '<tr><td colspan="2"><br /><h4>You Passed With A ' . $result . '% On The Exam.</h4></td></tr>';
     } else {
         echo '<tr><td colspan="2"><br /><h4>You Did Not Pass The Exam.<br /> A ' . $passing . '% Is Required To Pass The Exam.<br />You Scored ' . $result . '%</h4></td></tr>';
     }
     echo '</table><br />';
     echo '<form method="link" action="' . SITE_URL . '/index.php/Exams/view_profile">';
     echo '<input type="submit" value="Return To Exam Center"></form>';
 }
Beispiel #2
0
 public function get_setting_info()
 {
     $id = $_GET['id'];
     $this->set('setting', ExamsData::get_setting_info($id));
     $this->show('exams/exam_edit_setting');
 }