Changeset 730 for trunk/app/models
- Timestamp:
- 08/20/08 20:54:59 (3 months ago)
- Files:
-
- 1 modified
-
trunk/app/models/vclassroom.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/models/vclassroom.php
r729 r730 120 120 ); */ 121 121 /** 122 * Get student record in Vclassroom , return array 122 * Get student record in Vclassroom , return array usd in admin_record method (vclassrooms_controller.php) 123 123 * 124 * @param integer $user_id description124 * @param integer $user_id: in $fact student_id 125 125 * @param integer $vclassroom_id description 126 126 * @return array $record description 127 127 * @access public 128 * @author authorManuel Montoya128 * @author Manuel Montoya 129 129 **/ 130 130 public function studentRecord($user_id, $vclassroom_id) … … 133 133 $record = array(); 134 134 135 $this->User->unbindAll(); 136 135 $this->User->unbindAll(); // unbind unnecesaries tables 136 137 //Get the student data 137 138 $record = $this->User->find(array('User.id'=>$user_id), array('id', 'username', 'name', 'email')); 138 139 139 // Consult Test Model 140 // Consult Test Model associated to this Vclassroom 140 141 $this->TestsVclassroom->bindModel(array('belongsTo'=>array('Test'))); 141 142 … … 143 144 $fields = array('TestsVclassroom.test_id', 'TestsVclassroom.id', 'Test.title'); 144 145 $record['tests'] = $this->TestsVclassroom->findAll($conditions, $fields); 145 // die(debug($record['tests']));146 // die(debug($record)); 146 147 147 148 foreach($record['tests'] as $k => $t): … … 151 152 152 153 $conditions = array('Result.vclassroom_id'=>$vclassroom_id,'Result.user_id'=>$user_id,'Result.test_id'=>$t['TestsVclassroom']['test_id']); 153 $fields = array('Result.correct', 'Result.answer_id',' Test.title', 'Question.question', 'Question.worth');154 $fields = array('Result.correct', 'Result.answer_id','Question.worth'); 154 155 $results = $this->Test->Result->findAll($conditions, $fields); 155 156 //debug($results); 157 // Get points from answers 156 158 if ( count($results) > 0 ): 157 159 $points = (int) 0; 158 160 else: 159 $points = null; //student has no answered this test yet161 $points = null; //student has not answered this test yet 160 162 endif; 161 163 162 164 foreach($results as $r): 163 165 if ($r['Result']['correct'] == 1): 164 $points += $r['Question']['worth'];166 $points += (int) $r['Question']['worth']; 165 167 endif; 166 168 endforeach; … … 169 171 endforeach; 170 172 //die(debug($record['tests'])); 171 // Consult Treasure Model 173 174 // Now Treasure Model 172 175 $conditions = array('ResultTreasure.vclassroom_id'=>$vclassroom_id, 'ResultTreasure.user_id'=>$user_id); 173 176 $fields = array('ResultTreasure.points', 'Treasure.title', 'Treasure.id'); //null;
