Changeset 577 for trunk/app/models
- Timestamp:
- 05/31/08 16:41:09 (6 months ago)
- Files:
-
- 1 modified
-
trunk/app/models/vclassroom.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/models/vclassroom.php
r576 r577 131 131 132 132 // Consult Test Model 133 //$this->TestsVclassroom->bindModel(array('hasMany'=>array('Tests')));133 $this->TestsVclassroom->bindModel(array('belongsTo'=>array('Test'))); 134 134 135 135 $conditions = array('TestsVclassroom.vclassroom_id'=>$vclassroom_id); 136 $fields = array('Result.question_id', 'Result.answer_id', 'Result.correct', 'Test.title', 'Test.id', 'Question.id', 'Question.worth'); 137 $record['tests'] = $this->TestsVclassroom->findAll($conditions, null, null, null, null, 2); 136 $fields = array('TestsVclassroom.test_id', 'TestsVclassroom.id', 'Test.title'); 137 $record['tests'] = $this->TestsVclassroom->findAll($conditions, $fields); 138 //die(debug($record['tests'])); 139 138 140 foreach($record['tests'] as $k => $t): 141 $record['tests'][$k]['TestsVclassroom']['title'] = $t['Test']['title']; 139 142 $this->Test->Result->unbindAll(); 140 143 $this->Test->Result->bindModel(array('belongsTo'=>array('Question','Test'))); … … 143 146 $fields = array('Result.correct', 'Result.answer_id','Test.title', 'Question.question', 'Question.worth'); 144 147 $results = $this->Test->Result->findAll($conditions, $fields); 145 $points = (int) 0; 148 149 if ( count($results) > 0 ): 150 $points = (int) 0; 151 else: 152 $points = null; //student has no answered this test yet 153 endif; 154 146 155 foreach($results as $r): 147 156 if ($r['Result']['correct'] == 1): … … 149 158 endif; 150 159 //die(debug($results)); 151 $record['tests'][$k]['TestsVclassroom']['title'] = $r['Test']['title'];160 152 161 endforeach; 153 162 154 163 $record['tests'][$k]['TestsVclassroom']['points'] = $points; 164 155 165 endforeach; 156 166 //die(debug($record['tests']));
