Changeset 730 for trunk/app/models

Show
Ignore:
Timestamp:
08/20/08 20:54:59 (3 months ago)
Author:
aarkerio
Message:

Bugs fixed

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/app/models/vclassroom.php

    r729 r730  
    120120                       ); */  
    121121 /** 
    122  *  Get student record in Vclassroom , return array 
     122 *  Get student record in Vclassroom , return array  usd in admin_record method (vclassrooms_controller.php) 
    123123 * 
    124  * @param  integer $user_id  description 
     124 * @param  integer $user_id:  in $fact student_id 
    125125 * @param  integer $vclassroom_id  description 
    126126 * @return array   $record description 
    127127 * @access public 
    128  * @author author Manuel Montoya  
     128 * @author Manuel Montoya  
    129129 **/ 
    130130 public function studentRecord($user_id, $vclassroom_id) 
     
    133133     $record                  = array(); 
    134134    
    135      $this->User->unbindAll(); 
    136       
     135     $this->User->unbindAll();  // unbind unnecesaries tables 
     136      
     137     //Get the student data 
    137138     $record   = $this->User->find(array('User.id'=>$user_id), array('id', 'username', 'name', 'email')); 
    138139      
    139      // Consult Test Model 
     140     // Consult Test Model associated to this Vclassroom 
    140141     $this->TestsVclassroom->bindModel(array('belongsTo'=>array('Test'))); 
    141142      
     
    143144     $fields            = array('TestsVclassroom.test_id', 'TestsVclassroom.id', 'Test.title');  
    144145     $record['tests']   = $this->TestsVclassroom->findAll($conditions, $fields); 
    145      //die(debug($record['tests'])); 
     146     // die(debug($record)); 
    146147    
    147148     foreach($record['tests'] as $k => $t): 
     
    151152        
    152153       $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'); 
    154155       $results    = $this->Test->Result->findAll($conditions, $fields); 
    155  
     156       //debug($results); 
     157       // Get points from answers 
    156158       if ( count($results) > 0 ): 
    157159            $points     = (int) 0; 
    158160       else: 
    159             $points     = null;   //student has no answered this test yet 
     161            $points     = null;   //student has not answered this test yet 
    160162       endif; 
    161163        
    162164       foreach($results as $r): 
    163165            if ($r['Result']['correct'] == 1): 
    164                   $points     += $r['Question']['worth'];      
     166                  $points     += (int) $r['Question']['worth'];      
    165167        endif; 
    166168       endforeach; 
     
    169171     endforeach; 
    170172     //die(debug($record['tests'])); 
    171      // Consult Treasure Model 
     173 
     174     // Now Treasure Model 
    172175     $conditions = array('ResultTreasure.vclassroom_id'=>$vclassroom_id, 'ResultTreasure.user_id'=>$user_id); 
    173176     $fields     = array('ResultTreasure.points', 'Treasure.title', 'Treasure.id'); //null;