Changeset 466 for trunk/app/models/test.php
- Timestamp:
- 05/08/08 19:18:13 (8 months ago)
- Files:
-
- 1 modified
-
trunk/app/models/test.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/models/test.php
r428 r466 75 75 return $vclassrooms; 76 76 } 77 /* 78 * check if studen already found treasure 79 * int treasure_id 80 * int user_id 81 * int vclassroom_id 82 * return boolean 83 */ 84 public function chk($test_id, $user_id, $vclassroom_id) 85 { 86 $conditions = array("Result.user_id"=>$user_id, "Result.test_id"=>$test_id, "Result.vclassroom_id"=>$vclassroom_id); 87 $data = $this->Result->field('Result.id', $conditions); 88 89 if ($data != null ): 90 return false; 91 else: 92 return true; 93 endif; 94 } 77 95 78 96 public function chkAnswers($answers, $test_id) … … 82 100 $result = 0; 83 101 84 foreach($questions as $q_id => $a_id) // question id and answer id 85 { 102 foreach($questions as $q_id => $a_id): // question id and answer id 86 103 $correct_answer = $this->Test->Question->Answer->field('Answer.correct', array('Answer.id'=>$a_id)); // answer was correct? 87 104 88 if ($correct_answer == 1) 89 { 105 if ($correct_answer == 1): 90 106 $worth = $this->Test->Question->field('Question.worth', array('Question.id'=>$q_id)); // how many points 91 107 $result += $worth; 92 }93 }94 //exit('Result was:' . $result) ;108 endif; 109 endforeach; 110 //exit('Result was:' . $result)e 95 111 return $result; 96 112 }
