コード例 #1
0
ファイル: examresult.php プロジェクト: hemsinfotech/kodelearn
 /**
  * @param int $examgroup_id
  */
 public function __construct($examgroup_id)
 {
     // keep everything fetched from the db
     $this->_examgroup = ORM::factory('examgroup', $examgroup_id);
     // get all the exams in this exam group
     $this->_exams = Model_Examgroup::get_exams($examgroup_id);
     $this->_exams_arr = $this->_exams->as_array('id', 'name');
     $this->_students = Model_Examgroup::get_students($examgroup_id);
     $this->_results = Model_Examgroup::get_results($examgroup_id);
     $this->_exam_wise_students = self::exam_wise_students($this->_exams);
 }
コード例 #2
0
ファイル: examresult.php プロジェクト: hemsinfotech/kodelearn
 /**
  * Method to get the result sets from the post data submitted
  * @param array $results (keys = exam_id, values = array ( keys = student_id, values = marks scored)
  * @return array $results array keys (exam_id, user_id, marks)
  */
 private function result_sets($examgroup_id, $examresults)
 {
     if (!$examresults) {
         return array();
     }
     // get all the exams in this exam group
     $exams = Model_Examgroup::get_exams($examgroup_id)->as_array('id', 'total_marks');
     $sets = array();
     foreach ($examresults as $exam_id => $results) {
         foreach ($results as $user_id => $marks) {
             if ($marks > $exams[$exam_id]) {
                 $this->_invalid_rows[] = $user_id;
             }
             $sets[] = array('exam_id' => $exam_id, 'user_id' => $user_id, 'marks' => $marks);
         }
     }
     return $sets;
 }