Changeset 745

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

Little Bugs fixed

Location:
trunk/app
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • trunk/app/config/sql/postgresql/results.sql

    r576 r745  
    66   test_id int NOT NULL REFERENCES tests(id) ON DELETE CASCADE, 
    77   vclassroom_id int NOT NULL REFERENCES vclassrooms(id) ON DELETE CASCADE, 
    8    created timestamp(0) with time zone DEFAULT now() NOT NULL, 
    9    correct smallint NOT NULL, 
     8   created timestamp(0) with time zone DEFAULT now() NOT NULL 
    109   PRIMARY KEY (user_id, test_id, vclassroom_id, question_id) 
    1110); 
    12  
    13 -- CREATE TABLE results (  -- tests student results 
    14 --   id serial NOT NULL UNIQUE, 
    15 --   user_id int NOT NULL REFERENCES users(id) ON DELETE CASCADE, 
    16 --   results smallint NOT NULL, 
    17 --   test_id int NOT NULL REFERENCES tests(id) ON DELETE CASCADE, 
    18 --   vclassroom_id int NOT NULL REFERENCES vclassrooms(id) ON DELETE CASCADE, 
    19 --   created timestamp(0) with time zone DEFAULT now() NOT NULL, 
    20 --   percentage decimal NOT NULL, 
    21 --   PRIMARY KEY (user_id, test_id, vclassroom_id) 
    22 -- ); 
    23 -- Test model tables ends 
    24  
  • trunk/app/controllers/tests_controller.php

    r732 r745  
    107107         if ( $res['Answer']['correct'] == 1):    // is the answer correct? 
    108108         $points += (int) $res['Question']['worth'];   //sum good points         
    109          $this->data['Result']['correct'] = 1; 
    110          else: 
    111          $this->data['Result']['correct'] = 0; 
    112109     endif; 
    113110         $this->data['Result']['question_id']  = $k; 
     
    185182   
    186183 /**   === ADMIN METHODS ====  **/ 
    187  /** Select classroom to link*/ 
     184 public function admin_tempo() 
     185  {      // test_id, user_id vclassroom_id 
     186   $data  = $this->Test->getPoints(2, 4, 2); 
     187 } 
     188 /** Select classrooms to link*/ 
    188189 public function admin_vclassrooms($test_id) 
    189190 {     
  • trunk/app/controllers/vclassrooms_controller.php

    r739 r745  
    321321 public function admin_record($student_id, $vclassroom_id)  
    322322 { 
    323     $this->layout    = 'admin'; 
    324  
    325     $this->pageTitle = __('Student record', true); 
     323   $this->layout    = 'admin'; 
     324 
     325   $this->pageTitle = __('Student record', true); 
    326326     
    327     $this->set('data', $this->Vclassroom->studentRecord($student_id, $vclassroom_id)); 
     327   $this->set('data', $this->Vclassroom->studentRecord($student_id, $vclassroom_id)); 
    328328 } 
    329329 
    330330 public function admin_points($student_id, $vclassroom_id)  
    331331 { 
    332     $this->layout    = 'ajax'; 
     332   $this->layout    = 'ajax'; 
    333333     
    334     $this->set('points', $this->Vclassroom->studentPoints($student_id, $vclassroom_id)); 
     334   $this->set('points', $this->Vclassroom->studentPoints($student_id, $vclassroom_id)); 
    335335     
    336     $this->render('points', 'ajax'); 
     336   $this->render('points', 'ajax'); 
    337337 } 
    338338 
     
    340340 { 
    341341  if (empty($this->data['Vclassroom'])): 
    342         $this->layout = 'admin'; 
    343          
     342        $this->layout = 'admin';      
    344343        $this->data = $this->Vclassroom->read(null, $vclassroom_id); 
    345344  else: 
    346345     
    347346       $this->Sanitize = new Sanitize; 
    348         
    349347       $this->Sanitize->clean($this->data['Vclassroom']); 
    350348        
  • 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); 
  • trunk/app/views/vclassrooms/admin_record.ctp

    r744 r745  
    99 echo $html->div('title_section', $data['User']['name']); 
    1010 echo $html->div(null, $html->link($data['User']['email'], $data['User']['email'])); 
    11  // send message || send record to student    
     11 // send message && send record to student    
    1212 echo $html->para(null,  
    1313                 $ajax->link($html->image('admin/compose_on.gif', array('alt'=>'Compose', 'title'=>'Compose Message')) , 
     
    4444      echo $html->link($t['TestsVclassroom']['title'], '#'.$div_id, array('title'=>'View test', 'onclick'=> 
    4545        "window.open('/admin/tests/see/".$data['User']['id']."/".$t['TestsVclassroom']['test_id']."/".$data['Vclassroom']['id']."','mywin','left=20,top=10,width=700,height=700,scrollbars=1,toolbar=0,resizable=1')")) . '  '; 
    46 /* 
    47       echo $ajax->link($html->image('static/adownmod.png', array('alt'=>'Points down', 'title'=>'Points down')), 
    48                            '/admin/tests/points/'.$t['TestsVclassroom']['test_id'], 
    49                         array('update'  => $div_id, 
    50                               'loading '=>"Element.show('loadingre');", 
    51                                   'after'   =>'tp('.$data['User']['id'].','.$data['Vclassroom']['id'].')', 
    52                           'complete'=>"Element.hide('loadingre');Effect.Appear(".$div_id.")"),null,false); 
    53       echo $ajax->link($html->image('static/aupmod.png', array('alt'=>'Points up', 'title'=>'Points up')), 
    54                            '/admin/tests/points/'.$t['TestsVclassroom']['test_id'], 
    55                         array('update'  => $div_id, 
    56                                   'after'   =>'tp('.$data['User']['id'].','.$data['Vclassroom']['id'].')', 
    57                               'loading '=>"Element.show('loadingre')", 
    58                           'complete'=>"Element.hide('loadingre');Effect.Appear(".$div_id.")"),null,false); */ 
    5946        e('</div>'); 
    6047      endif; 
  • trunk/app/webroot/js/admin.js

    r738 r745  
    22window.onload = preloader; 
    33 
     4// preload images in Control Panel 
    45function preloader()  
    56{