Changeset 467
- Timestamp:
- 05/08/08 21:14:33 (8 months ago)
- Location:
- trunk/app
- Files:
-
- 8 modified
-
controllers/tests_controller.php (modified) (1 diff)
-
controllers/treasures_controller.php (modified) (1 diff)
-
controllers/vclassrooms_controller.php (modified) (1 diff)
-
controllers/webquests_controller.php (modified) (1 diff)
-
models/test.php (modified) (2 diffs)
-
models/user.php (modified) (1 diff)
-
models/vclassroom.php (modified) (1 diff)
-
views/vclassrooms/show.ctp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/controllers/tests_controller.php
r466 r467 66 66 public function view($test_id, $vclassroom_id) 67 67 { 68 // student belongst to this class? 69 if ( $this->Auth->user() && $this->Auth->user('group_id') == 3): 70 $this->set('belongs', $this->Test->Vclassroom->belongs($this->Auth->user('id'), $vclassroom_id)); 71 else: 72 $this->set('belongs', false); 73 endif; 68 74 69 if ( $this->Test->chk($test_id, $this->Auth->user('id'), $vclassroom_id) === true ) 70 { 75 if ( $this->Test->chk($test_id, $this->Auth->user('id'), $vclassroom_id) === true ): 71 76 $username = $this->Test->User->field('User.username', array("User.id"=>$user_id)); 72 77 $this->flash('You already have answered this test', '/users/portfolio/'.$username); 73 } 74 75 if ( $this->Auth->user() && $this->Auth->user('group_id') == 3) 76 { 77 $student_id = (int) $this->Auth->user('id'); 78 $this->Edublog->setSession($student_id); //check if user belongs to class 79 } 80 78 endif; 79 81 80 $this->pageTitle = 'Exams'; 82 81 -
trunk/app/controllers/treasures_controller.php
r466 r467 97 97 public function view($treasure_id, $vclassroom_id) 98 98 { 99 if ( $this->Test->chk($test_id, $this->Auth->user('id'), $vclassroom_id) === true ):99 if ( $this->Test->chk($test_id, $this->Auth->user('id'), $vclassroom_id) === true ): 100 100 $username = $this->Test->User->field('User.username', array("User.id"=>$user_id)); 101 101 $this->flash('You already have answered this test', '/users/portfolio/'.$username); 102 endif;102 endif; 103 103 104 if ( $this->Auth->user() && $this->Auth->user('group_id') == 3): 105 $student_id = (int) $this->Auth->user('id'); 106 $this->Edublog->setSession($student_id); //check if user belongs to class 107 endif; 108 109 $conditions = array("Treasure.status"=>1, "Treasure.id"=>$treasure_id); 110 111 $data = $this->Treasure->find($conditions); 104 // student belongs to this class? 105 if ( $this->Auth->user() && $this->Auth->user('group_id') == 3): 106 $this->set('belongs', $this->Treasure->Vclassroom->belongs($this->Auth->user('id'), $vclassroom_id)); 107 else: 108 $this->set('belongs', false); 109 endif; 110 111 $conditions = array("Treasure.status"=>1, "Treasure.id"=>$treasure_id); 112 113 $data = $this->Treasure->find($conditions); 112 114 113 $this->layout = $this->Edublog->layout($data['Treasure']['user_id']);114 115 $this->pageTitle = 'Treasure Hunt';116 117 $this->Edublog->blog($data['Treasure']['user_id']); // blogger elements115 $this->layout = $this->Edublog->layout($data['Treasure']['user_id']); 116 117 $this->pageTitle = 'Treasure Hunt'; 118 119 $this->Edublog->blog($data['Treasure']['user_id']); // blogger elements 118 120 119 $this->set('data', $data);121 $this->set('data', $data); 120 122 } 121 123 -
trunk/app/controllers/vclassrooms_controller.php
r459 r467 71 71 } 72 72 73 public function show($user_id, $id) 74 { 75 $this->pageTitle = 'Classrooms'; 76 $this->layout = $this->Edublog->layout($user_id); 77 $this->Edublog->blog($user_id); 78 79 $conditions = array("Vclassroom.status"=>1, "Vclassroom.id"=>$id); 80 81 // temporal lines, move to model later 82 $this->Vclassroom->Ecourse->unbindModel(array('hasMany'=>array('Vclassroom'), 'belongsTo'=>array('User'))); 83 $this->Vclassroom->Test->unbindModel(array('hasMany'=>array('Question'), 'belongsTo'=>array('User'))); 84 85 $this->set('data', $this->Vclassroom->find($conditions, null, null, 2)); 86 87 if ( $this->Auth->user() && $this->Auth->user('group_id') == 3) 88 { 89 $user_id = (int) $this->Auth->user('id'); 90 $this->Edublog->setSession($user_id); 91 } 73 public function show($user_id, $vclassroom_id) 74 { 75 $this->pageTitle = 'Classrooms'; 76 $this->layout = $this->Edublog->layout($user_id); 77 $this->Edublog->blog($user_id); 78 79 // student belongst to this class? 80 if ( $this->Auth->user() && $this->Auth->user('group_id') == 3): 81 $this->set('belongs', $this->Vclassroom->belongs($this->Auth->user('id'), $vclassroom_id)); 82 else: 83 $this->set('belongs', false); 84 endif; 85 86 $conditions = array("Vclassroom.status"=>1, "Vclassroom.id"=>$vclassroom_id); 87 88 // temporal lines, move to model later 89 $this->Vclassroom->Ecourse->unbindModel(array('hasMany'=>array('Vclassroom'), 'belongsTo'=>array('User'))); 90 $this->Vclassroom->Test->unbindModel(array('hasMany'=>array('Question'), 'belongsTo'=>array('User'))); 91 92 $this->set('data', $this->Vclassroom->find($conditions, null, null, 2)); 92 93 } 93 94 -
trunk/app/controllers/webquests_controller.php
r466 r467 72 72 $this->flash('You already have answered this webquest', '/vclassrooms/show/'.$data['Webquest']['user_id'].'/'.$data['Webquest']['user_id'); 73 73 } 74 75 if ( $this->Auth->user() && $this->Auth->user('group_id') == 3) 76 { 77 $student_id = (int) $this->Auth->user('id'); 78 $this->Edublog->setSession($student_id); //check if user belongs to class 79 } 80 81 $this->layout = $this->Edublog->layout($data['Webquest']['user_id']); 82 83 $this->Edublog->blog($data['Webquest']['user_id']); // blogger elements 84 85 $this->pageTitle = $data['Webquest']['title'] . '\'s Webquest'; 86 87 $this->set('data', $data); 74 75 // student belongst to this class? 76 if ( $this->Auth->user() && $this->Auth->user('group_id') == 3): 77 $this->set('belongs', $this->Webquest->Vclassroom->belongs($this->Auth->user('id'), $vclassroom_id)); 78 else: 79 $this->set('belongs', false); 80 endif; 81 82 $this->layout = $this->Edublog->layout($data['Webquest']['user_id']); 83 84 $this->Edublog->blog($data['Webquest']['user_id']); // blogger elements 85 86 $this->pageTitle = $data['Webquest']['title'] . '\'s Webquest'; 87 88 $this->set('data', $data); 88 89 } 89 90 -
trunk/app/models/test.php
r466 r467 36 36 'dependent' => true, 37 37 'exclusive' => false, 38 'finderQuery' => null38 'finderQuery' => null 39 39 40 40 ) … … 75 75 return $vclassrooms; 76 76 } 77 77 78 /* 78 79 * check if studen already found treasure -
trunk/app/models/user.php
r434 r467 60 60 'email' => VALID_EMAIL 61 61 ); 62 63 62 } 64 63 ?> -
trunk/app/models/vclassroom.php
r460 r467 358 358 } 359 359 } 360 /* 361 * check if studen already found treasure 362 * int treasure_id 363 * int user_id 364 * int vclassroom_id 365 * return boolean 366 */ 367 public function belongs($user_id, $vclassroom_id) 368 { 369 $conditions = array("UsersVclassroom.user_id"=>$user_id, "UsersVclassroom.vclassroom_id"=>$vclassroom_id); 370 371 $data = $this->UsersVclassroom->field('UsersVclassroom.user_id',$conditions); 372 373 if ($data === false ): 374 return false; 375 else: 376 return true; 377 endif; 378 } 379 360 380 } 361 381 ?> -
trunk/app/views/vclassrooms/show.ctp
r466 r467 3 3 echo $javascript->link('fckeditor/fckeditor'); 4 4 5 6 echo '<h1>' . $data['Vclassroom']['name'] . '</h1>'; 5 echo '<h1>' . $data['Vclassroom']['name'] . '</h1>'; 7 6 8 $auth = false; 9 10 if ( $session->check('vclassrooms') ) 11 { 12 $auth = ( in_array($data['Vclassroom']['id'], $session->read('vclassrooms'))) ? true : false; // students belongs this vclass ? 13 } 14 15 if ( $auth === true ) 16 { 7 if ( $belongs === true ) 8 { 17 9 echo $html->para(null, 'Welcome! <b>'. $cU['User']['username'].'</b>'); 18 10 echo $html->para(null, '<b>Created:</b> ' . $data['Vclassroom']['created']); … … 70 62 71 63 72 if ( isset( $cU['User']['id'] ) && $cU['User']['group_id'] == 3 && $auth === false) // a student is login in so, show "Join" button 73 { 64 if ( isset( $cU['User']['id'] ) && $cU['User']['group_id'] == 3 && $belongs === false): // a student is login in so, show "Join" button 74 65 echo $ajax->form(); 75 66 … … 84 75 // empty ajax div 85 76 echo $ajax->div('updater') . $ajax->divEnd('updater'); 86 } 87 elseif ( !isset( $cU['User']) ) 88 { 89 echo $html->link('Login to join this group', '/users/login'); 90 } 77 78 elseif ( !isset( $cU['User']) ): 79 e($html->link('Login to join this group', '/users/login')); 80 endif; 91 81 ?> 92 82 <div id="charging" style="display:none;"><?php echo $html->image('static/loading.gif', array("alt"=>"Loading")); ?></div>
