| 120 | | $tests = $this->Test->Question->findAll(array('Question.test_id'=>$this->data['Test']['test_id']), $fields); |
| 121 | | |
| 122 | | //die(debug($this->data['Test'])); |
| 123 | | |
| 124 | | $points = 0; |
| 125 | | |
| 126 | | foreach($this->data['Test'] as $k => $t): |
| 127 | | if ( is_numeric($k) ): |
| 128 | | $res = $this->Test->Question->Answer->find(array('Answer.id'=>$t)); |
| 129 | | if ( $res['Answer']['correct'] == 1): |
| 130 | | $points += (int) $res['Question']['worth']; |
| 131 | | endif; |
| 132 | | endif; |
| 133 | | endforeach; |
| | 120 | $conditions = array('Result.user_id'=>$user_id, 'Result.test_id'=>$test_id, 'Result.vclassroom_id'=>$vclassroom_id); |
| | 121 | $this->Result->bindModel(array('belongsTo'=>array('Question', 'Answer'))); |
| | 122 | $fields = array('Result.id', 'Result.created','Result.question_id','Test.title', 'Question.question', 'Question.worth', 'Answer.answer', 'Answer.correct'); |
| | 123 | $data = $this->Result->findAll($conditions, $fields); |