Changeset 452 for trunk/app/models

Show
Ignore:
Timestamp:
05/04/08 23:49:32 (7 months ago)
Author:
aarkerio
Message:

Best podcast

Location:
trunk/app/models
Files:
2 modified

Legend:

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

    r451 r452  
    8585                         ) 
    8686                       ); 
     87 public $validate = array( 
     88      'name'    => VALID_NOT_EMPTY, 
     89      'user_id' => VALID_NOT_EMPTY, 
     90      'status'  => VALID_NOT_EMPTY 
     91   ); 
    8792  
    88  // get student record 
     93 /** 
     94 *  Get student record, return array 
     95 * 
     96 * @param  integer $user_id  description 
     97 * @param  integer $vclassroom_id  description 
     98 * @return array   $record description 
     99 * @access public 
     100 * @author author Manuel Montoya  
     101 **/ 
    89102 public function getRecord($user_id, $vclassroom_id) 
    90103 {    
    91      $record     = (string) ''; 
    92       
    93      $conditions = array('Result.vclassroom_id'=>$vclassroom_id, 'Result.user_id'=>$user_id); 
    94      $fields     = array('Result.percentage', 'Test.title'); //null; 
    95      $tests      = $this->Test->Result->findAll($conditions, $fields); 
     104     $record            = array(); 
     105      
     106     $record['user']   = $this->User->find(array('User.id'=>$user_id), array('id', 'username', 'name', 'email')); 
     107      
     108     $conditions        = array('Result.vclassroom_id'=>$vclassroom_id, 'Result.user_id'=>$user_id); 
     109     $fields            = array('Result.percentage', 'Test.title');  //null; 
     110     $record['tests']   = $this->Test->Result->findAll($conditions, $fields); 
    96111     //die(debug($tests)); 
    97      foreach ($tests as $t)  
    98      { 
    99      $record .= 'Test: ' . $t['Test']['title'] . '<br />'; 
    100          $record .= 'Percentage: ' . $t['Result']['percentage'] . '<br />'; 
    101      } 
    102       
    103      // $webquests  = $this->Webquest->ResultWebquest->findAll($conditions, $fields); 
    104       
     112     
    105113     $conditions = array('ResultTreasure.vclassroom_id'=>$vclassroom_id, 'ResultTreasure.user_id'=>$user_id); 
    106114     $fields     = array('ResultTreasure.points', 'Treasure.title'); //null; 
    107      $treasures  = $this->Treasure->ResultTreasure->findAll($conditions, $fields); 
    108       
    109      foreach ($treasures as $tr)  
    110      { 
    111        $record .= 'Treasure: '. $tr['Treasure']['title'] . '<br />'; 
    112        $record .= 'Points: ' . $tr['ResultTreasure']['points'] . '<br />'; 
    113      } 
    114       
    115      $conditions  = array('Topic.vclassroom_id'=>$vclassroom_id, 'Topic.user_id'=>$user_id); 
    116      $fields      = array('Forum.title', 'Topic.subject'); //null; 
    117      $topics      = $this->Forum->Topic->findAll($conditions, $fields); 
    118       
    119      $num_topics = (int) 0; 
    120       
    121      foreach ($topics as $p)  
    122      { 
    123        $record .= 'Forum: '. $p['Forum']['title'] . '<br />'; 
    124        $num_topics++; 
    125      } 
    126       
    127      $record .= 'Participations on Forums: ' . $num_topics . '<br />'; 
    128  
     115     $record['treasures']  =  $this->Treasure->ResultTreasure->findAll($conditions, $fields);   
     116          
     117     $conditions       = array('Topic.vclassroom_id'=>$vclassroom_id, 'Topic.user_id'=>$user_id); 
     118     $fields           = array('Forum.title', 'Topic.subject'); //null; 
     119     $record['topics'] = $this->Forum->Topic->findAll($conditions, $fields); 
     120      
    129121     $conditions     = array('Participation.vclassroom_id'=>$vclassroom_id, 'Participation.user_id'=>$user_id); 
    130      $fields         = array('Participation.title', 'Participation.points'); //null; 
    131       
    132      $participations = $this->Participation->findAll($conditions, $fields); 
    133       
    134      $points = (int) 0; 
    135  
    136      foreach ($participations as $pr)  
    137      { 
    138        $record .= 'Part title: '. $pr['Participation']['title'] . ' Points '. $pr['Participation']['points'] .'<br />'; 
    139        $points += $pr['Participation']['points'];  
    140      } 
    141      $record .= ' Total participation points: '. $points .'<br />'; 
    142      // die(debug($treasures)); 
     122     $fields         = array('Participation.title', 'Participation.id', 'Participation.points'); //null; 
     123      
     124     $record['participations'] = $this->Participation->findAll($conditions, $fields); 
     125 
     126     $conditions     = array('ResultWebquest.vclassroom_id'=>$vclassroom_id, 'ResultWebquest.user_id'=>$user_id); 
     127     $fields         = array('Webquest.title', 'Webquest.id', 'ResultWebquest.points'); //null; 
     128 
     129     $record['webquests']      = $this->Webquest->ResultWebquest->findAll($conditions, $fields); 
     130      
     131     //die(debug($record)); 
    143132     return $record; 
    144133 } 
    145  
    146  //Check if the user already exist in the classroom 
     134/** 
     135 *  Get student evaluation, return integer 
     136 * 
     137 * @param  integer $user_id  description 
     138 * @param  integer $vclassroom_id  description 
     139 * @return array   $record description 
     140 * @access public 
     141 * @author author Manuel Montoya  
     142 **/ 
     143 public function getEval($user_id, $vclassroom_id) 
     144 { 
     145   return $record; 
     146 } 
     147/** 
     148 *  Check if the student already exist in the classroom 
     149 * 
     150 *  @param  integer $user_id  description 
     151 *  @param  integer $vclassroom_id  description 
     152 *  @return boolean   description 
     153 *  @access public 
     154 *  @author author Manuel Montoya  
     155 **/ 
    147156 public function chkMember($vclassroom_id, $user_id) 
    148157 {  
     
    188197 } 
    189198 
    190  public $validate = array( 
    191       'name'    => VALID_NOT_EMPTY, 
    192       'user_id' => VALID_NOT_EMPTY, 
    193       'status'  => VALID_NOT_EMPTY 
    194    ); 
    195  
    196199  /** 
    197200   * Adds a join record between two records of a hasAndBelongsToMany association 
  • trunk/app/models/webquest.php

    r416 r452  
    1212    public $belongsTo   = 'User'; 
    1313     
     14   public $hasMany = array( 
     15                     'ResultWebquest' => 
     16                   array('className'     => 'ResultWebquest', 
     17                 'conditions'    => null, 
     18                 'order'         => null, 
     19                 'limit'         => null, 
     20                 'foreignKey'    => 'webquest_id', 
     21                 'dependent'     => true, 
     22                 'exclusive'     => false, 
     23                             'finderQuery'   => null 
     24                    )); 
    1425 
    1526    public $hasAndBelongsToMany = array('Vclassroom' => 
     
    2940      'title' => VALID_NOT_EMPTY,         //'/[a-z0-9\_\-]{3,}$/i', 
    3041      'user_id' => VALID_NOT_EMPTY, 
    31       'introduction' => VALID_NOT_EMPTY 
     42      'introduction' => VALID_NOT_EMPTY, 
     43      'points' => VALID_NOT_EMPTY 
    3244   ); 
    3345}