- Timestamp:
- 09/01/08 12:14:13 (3 months ago)
- Location:
- trunk/app
- Files:
-
- 7 modified
-
config/sql/postgresql/results.sql (modified) (1 diff)
-
controllers/tests_controller.php (modified) (2 diffs)
-
controllers/vclassrooms_controller.php (modified) (2 diffs)
-
models/test.php (modified) (1 diff)
-
models/vclassroom.php (modified) (1 diff)
-
views/vclassrooms/admin_record.ctp (modified) (2 diffs)
-
webroot/js/admin.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/config/sql/postgresql/results.sql
r576 r745 6 6 test_id int NOT NULL REFERENCES tests(id) ON DELETE CASCADE, 7 7 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 10 9 PRIMARY KEY (user_id, test_id, vclassroom_id, question_id) 11 10 ); 12 13 -- CREATE TABLE results ( -- tests student results14 -- 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 ends24 -
trunk/app/controllers/tests_controller.php
r732 r745 107 107 if ( $res['Answer']['correct'] == 1): // is the answer correct? 108 108 $points += (int) $res['Question']['worth']; //sum good points 109 $this->data['Result']['correct'] = 1;110 else:111 $this->data['Result']['correct'] = 0;112 109 endif; 113 110 $this->data['Result']['question_id'] = $k; … … 185 182 186 183 /** === 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*/ 188 189 public function admin_vclassrooms($test_id) 189 190 { -
trunk/app/controllers/vclassrooms_controller.php
r739 r745 321 321 public function admin_record($student_id, $vclassroom_id) 322 322 { 323 $this->layout = 'admin';324 325 $this->pageTitle = __('Student record', true);323 $this->layout = 'admin'; 324 325 $this->pageTitle = __('Student record', true); 326 326 327 $this->set('data', $this->Vclassroom->studentRecord($student_id, $vclassroom_id));327 $this->set('data', $this->Vclassroom->studentRecord($student_id, $vclassroom_id)); 328 328 } 329 329 330 330 public function admin_points($student_id, $vclassroom_id) 331 331 { 332 $this->layout = 'ajax';332 $this->layout = 'ajax'; 333 333 334 $this->set('points', $this->Vclassroom->studentPoints($student_id, $vclassroom_id));334 $this->set('points', $this->Vclassroom->studentPoints($student_id, $vclassroom_id)); 335 335 336 $this->render('points', 'ajax');336 $this->render('points', 'ajax'); 337 337 } 338 338 … … 340 340 { 341 341 if (empty($this->data['Vclassroom'])): 342 $this->layout = 'admin'; 343 342 $this->layout = 'admin'; 344 343 $this->data = $this->Vclassroom->read(null, $vclassroom_id); 345 344 else: 346 345 347 346 $this->Sanitize = new Sanitize; 348 349 347 $this->Sanitize->clean($this->data['Vclassroom']); 350 348 -
trunk/app/models/test.php
r578 r745 54 54 ) 55 55 ); 56 public $validate = array( 57 'title' => VALID_NOT_EMPTY, 58 'description' => VALID_NOT_EMPTY, 59 'user_id' => VALID_NOT_EMPTY 60 ); 56 public $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 ); 61 66 /* 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); 87 94 88 95 $vclassrooms = array(); -
trunk/app/models/vclassroom.php
r741 r745 418 418 endif; 419 419 } 420 420 421 public function studentPoints($user_id, $vclassroom_id) 421 422 { 422 423 try{ 423 $points = (int) 0; 424 $points = (int) 0; // student total points in eCourse 424 425 425 426 // 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 432 435 // Consult Treasure Model 433 436 $conditions = array('ResultTreasure.vclassroom_id'=>$vclassroom_id, 'ResultTreasure.user_id'=>$user_id); -
trunk/app/views/vclassrooms/admin_record.ctp
r744 r745 9 9 echo $html->div('title_section', $data['User']['name']); 10 10 echo $html->div(null, $html->link($data['User']['email'], $data['User']['email'])); 11 // send message ||send record to student11 // send message && send record to student 12 12 echo $html->para(null, 13 13 $ajax->link($html->image('admin/compose_on.gif', array('alt'=>'Compose', 'title'=>'Compose Message')) , … … 44 44 echo $html->link($t['TestsVclassroom']['title'], '#'.$div_id, array('title'=>'View test', 'onclick'=> 45 45 "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); */59 46 e('</div>'); 60 47 endif; -
trunk/app/webroot/js/admin.js
r738 r745 2 2 window.onload = preloader; 3 3 4 // preload images in Control Panel 4 5 function preloader() 5 6 {
