Changeset 745 for trunk/app/models

Show
Ignore:
Timestamp:
09/01/08 12:14:13 (3 months ago)
Author:
aarkerio
Message:

Little Bugs fixed

Location:
trunk/app/models
Files:
2 modified

Legend:

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

    r578 r745  
    5454                         ) 
    5555                            );    
    56     public $validate = array( 
    57       'title' => VALID_NOT_EMPTY, 
    58       'description' => VALID_NOT_EMPTY, 
    59       'user_id' => VALID_NOT_EMPTY 
    60    );  
     56public $validate = array( 
     57              'title' => array( 
     58                          'rule' => array('minLength', '4'), 
     59                                      'message' => 'Mimimum 4 characters long' 
     60                       ), 
     61              'description' => array( 
     62                             'rule' => array('minLength', '4'), 
     63                                         'message' => 'Mimimum 4 characters long' 
     64                            )        
     65                ); 
    6166/* 
    62 public $validate = array( 
    63         'login' => array('alphanumeric' => array( 
    64                                                  'rule' => 'alphaNumeric', 
    65                                              'required' => true, 
    66                                                          'message' => 'Alphabets and numbers only' 
    67                                    ), 
    68                                 'between' => array( 
    69                                            'rule' => array('between', 5, 15), 
    70                                                                                'message' => 'Between 5 to 15 characters' 
    71                                            ) 
    72                                 ), 
    73                        'password' => array( 
    74                                    'rule' => array('minLength', '8'), 
    75                                                                'message' => 'Mimimum 8 characters long' 
    76                                    ), 
    77                        'email' => 'email', 
    78                        'born' => array( 
    79                                'rule' => 'date', 
    80                                'message' => 'Enter a valid date', 
    81                                                            'allowEmpty' => true 
    82                                ) 
    83                        ); */    
    84   public function linkClassroom($test_id, $user_id) 
    85   { 
    86     $condition = array('Test.status'=>1, 'Test.user_id'=>$user_id, 'Test.id'=>$test_id); 
     67 *  getPoints  returns points from already answered test by student 
     68 *   
     69 */ 
     70 public function getPoints($test_id, $user_id, $vclassroom_id) 
     71 { 
     72  $points = (int) 0; 
     73 
     74  $conditions = array('Result.test_id'=>$test_id, 'Result.user_id'=>$user_id, 'Result.vclassroom_id'=>$vclassroom_id); 
     75   
     76  $this->Result->unbindAll();  // removeds unnecesary stuff 
     77 
     78  $answers    = $this->Result->findAll($conditions);  // get the answers gived by student 
     79   
     80  foreach($answers as $a): 
     81    $question = $this->Question->find(array('Question.id'=>$a['Result']['question_id']), array('worth')); // how much points question have? 
     82    foreach($question['Answer'] as $qa): 
     83        if ($qa['id'] == $a['Result']['answer_id'] && $qa['question_id'] == $a['Result']['question_id'] && $qa['correct'] == 1): 
     84            $points += (int) $question['Question']['worth'];   
     85    endif; 
     86     endforeach; 
     87  endforeach; 
     88   
     89  return $points; 
     90 } 
     91 public function linkClassroom($test_id, $user_id) 
     92 { 
     93    $conditions = array('Test.status'=>1, 'Test.user_id'=>$user_id, 'Test.id'=>$test_id); 
    8794     
    8895    $vclassrooms = array(); 
  • trunk/app/models/vclassroom.php

    r741 r745  
    418418   endif;  
    419419 } 
     420 
    420421 public function studentPoints($user_id, $vclassroom_id) 
    421422 { 
    422423  try{    
    423      $points  = (int) 0; 
     424     $points  = (int) 0; // student total points in eCourse  
    424425    
    425426     // Consult Test Model  
    426      /*$conditions     = array('Result.vclassroom_id'=>$vclassroom_id, 'Result.user_id'=>$user_id); 
    427      $fields         = array('Result.percentage');  //null; 
    428      $tests          = $this->Test->Result->findAll($conditions, $fields); 
    429      foreach ($tests as $t): 
    430             $points = $t['Test']['']; 
    431      endforeach; */ 
     427     /* $conditions = array('Result.vclassroom_id'=>$vclassroom_id, 'Result.user_id'=>$user_id); 
     428     $fields     = array('Result.points'); 
     429     $tests      = $this->Test->Result->findAll($conditions, $fields); 
     430     foreach ($tests as $test): 
     431            $points += (int) $this->Test->getPoints($test['test']['id'], $user_id, $vclassroom_id); 
     432     endforeach; 
     433     die('pints  '. $points);*/ 
     434      
    432435     // Consult Treasure Model 
    433436     $conditions = array('ResultTreasure.vclassroom_id'=>$vclassroom_id, 'ResultTreasure.user_id'=>$user_id);