Changeset 416
- Timestamp:
- 04/21/08 13:05:04 (9 months ago)
- Location:
- trunk/app
- Files:
-
- 6 modified
-
config/sql/karamelo_postgres.sql (modified) (1 diff)
-
controllers/components/edublog.php (modified) (2 diffs)
-
controllers/vclassrooms_controller.php (modified) (4 diffs)
-
controllers/webquests_controller.php (modified) (1 diff)
-
models/webquest.php (modified) (1 diff)
-
views/webquests/admin_listing.ctp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/config/sql/karamelo_postgres.sql
r409 r416 522 522 --HABTM 523 523 CREATE TABLE "vclassrooms_webquests" ( 524 "vclassroom_id" int NOT NULL REFERENCES vclassrooms(id), 525 "webquest_id" int NOT NULL REFERENCES webquests(id), 526 PRIMARY KEY ("vclassroom_id", "webquest_id") 527 ); 524 "id" serial PRIMARY KEY, 525 "vclassroom_id" int NOT NULL REFERENCES vclassrooms(id) ON DELETE CASCADE, 526 "webquest_id" int NOT NULL REFERENCES webquests(id) ON DELETE CASCADE, 527 UNIQUE ("vclassroom_id", "webquest_id") 528 ); 529 530 528 531 -- Treasure hunts http://www.gma.org/surfing/imaging/treasure.html 529 532 CREATE TABLE "treasures" ( -
trunk/app/controllers/components/edublog.php
r325 r416 9 9 10 10 App::import('Model','User'); 11 App::import('Model','Vclassroom'); 11 12 12 13 class EdublogComponent extends Object 13 14 { 14 15 15 public function startup(&$controller) 16 16 { … … 106 106 ); 107 107 108 $conditions = array("User.id"=>$user_id, "User.active"=>1);109 $fields = array("User.id", "User.created", "User.name_blog", "User.quote", "User.cv", "User.avatar", "User.username");108 $conditions = array("User.id"=>$user_id, "User.active"=>1); 109 $fields = array("User.id", "User.created", "User.name_blog", "User.quote", "User.cv", "User.avatar", "User.username"); 110 110 111 //return $this->User->findAll($conditions, $fields, null, null, null, 2);111 $this->controller->set('blog', $this->User->find($conditions, $fields, null, 2)); 112 112 113 $this->controller->set('blog', $this->User->find($conditions, $fields, null, 2));113 } 114 114 115 public function setSession($user_id) //set vclassrooms authorized to this student 116 { 117 $this->Vclassroom = new Vclassroom; 118 119 $vclassrooms = $this->Vclassroom->chkVclassrooms($user_id); // check model, what classrooms this student belongs? 120 121 if ($vclassrooms != null) 122 { 123 $this->controller->Session->write('vclassrooms', $vclassrooms); 124 } 125 126 return true; 115 127 } 116 128 -
trunk/app/controllers/vclassrooms_controller.php
r398 r416 52 52 { 53 53 $user_id = (int) $this->Auth->user('id'); 54 $this-> __setSession($user_id);54 $this->Edublog->setSession($user_id); 55 55 } 56 56 } … … 64 64 $conditions = array("Vclassroom.status"=>1, "Vclassroom.id"=>$id); 65 65 66 // temporal lines, move to model later 66 67 $this->Vclassroom->Ecourse->unbindModel(array('hasMany'=>array('Vclassroom'), 'belongsTo'=>array('User'))); 67 68 $this->Vclassroom->Test->unbindModel(array('hasMany'=>array('Question'), 'belongsTo'=>array('User'))); … … 72 73 { 73 74 $user_id = (int) $this->Auth->user('id'); 74 $this-> __setSession($user_id);75 $this->Edublog->setSession($user_id); 75 76 } 76 77 } … … 106 107 } 107 108 } 108 }109 110 private function __setSession($user_id) //set vclassrooms authorized to this student111 {112 $vclassrooms = $this->Vclassroom->chkVclassrooms($user_id); // check model113 114 if ($vclassrooms != null)115 {116 $this->Session->write('vclassrooms', $vclassrooms);117 }118 119 return true;120 109 } 121 110 -
trunk/app/controllers/webquests_controller.php
r340 r416 269 269 $this->msgFlash('Webquest status changed', '/admin/webquests/listing'); 270 270 } 271 } 271 } 272 /** Select classroom to link*/ 273 public function admin_vclassrooms($webquest_id) 274 { 275 $this->pageTitle = $this->Auth->user('username') . '\'s Tests'; 276 277 $this->layout = 'admin'; 278 279 $conditions = array('Vclassroom.user_id'=>$this->Auth->user('id'), 'Vclassroom.status'=>1); 280 281 $this->set('data', $this->Test->Vclassroom->findAll($conditions)); 282 283 $this->Test->unbindModel(array('hasMany'=>array('Question', 'Result'), 'belongsTo'=>array('User'))); 284 285 $this->set('tests',$this->Test->VclassroomsWebquest->findAll(array('VclassroomsWebquest.webquest_id' => $webquest_id))); 286 287 $this->set('webquest_id', $webquest_id); 288 } 289 290 public function admin_link2class() 291 { 292 $this->layout = 'admin'; 293 // add to database 294 if ( !empty($this->data['VclassroomsWebquest']) ) 295 { 296 $this->Sanitize = new Sanitize; 297 298 $this->Sanitize->clean($this->data['VclassroomsWebquest']); 299 300 $this->Test->VclassroomsWebquest->create(); 301 302 if ( $this->Test->VclassroomsWebquest->save($this->data['VclassroomsWebquest'])) 303 { 304 $this->msgFlash('Test assigned', '/admin/tests/vclassrooms/'.$this->data['VclassroomsWebquest']['webquest_id']); 305 } 306 else 307 { 308 die('Something is wrong, please report this bug'); 309 } 310 } 311 } 312 313 public function admin_unlink2class() 314 { 315 $this->layout = 'admin'; 316 // add to database 317 if ( !empty($this->data['VclassroomsWebquest']) ) 318 { 319 $this->Sanitize = new Sanitize; 320 321 $this->Sanitize->clean($this->data['VclassroomsWebquest']); 322 323 if ( $this->Test->VclassroomsWebquest->delete($this->data['VclassroomsWebquest']['id'])) 324 { 325 $this->msgFlash('Test unlinked', '/admin/tests/vclassrooms/'.$this->data['VclassroomsWebquest']['webquest_id']); 326 } 327 else 328 { 329 die('Something is wrong, please report this bug'); 330 } 331 } 332 } 333 272 334 public function admin_delete($id) 273 335 { -
trunk/app/models/webquest.php
r282 r416 12 12 public $belongsTo = 'User'; 13 13 14 15 public $hasAndBelongsToMany = array('Vclassroom' => 16 array('className' => 'Vclassroom', 17 'joinTable' => 'vclassrooms_webquests', 18 'foreignKey' => 'webquest_id', 19 'associationForeignKey' => 'vclassroom_id', 20 'conditions' => null, 21 'order' => null, 22 'limit' => '', 23 'unique' => true, 24 'finderQuery' => '', 25 'deleteQuery' => '' 26 ) 27 ); 14 28 public $validate = array( 15 29 'title' => VALID_NOT_EMPTY, //'/[a-z0-9\_\-]{3,}$/i', -
trunk/app/views/webquests/admin_listing.ctp
r340 r416 1 < div class="title_section"> Webquest </div>1 <?php 2 2 3 <?php 3 echo $html->div('title_section', 'Webquest'); 4 4 5 echo $ajax->div('loading', array("style"=>"display: none")) . $html->image("static/loading.gif", array("alt"=>"Loading")) . $ajax->divEnd('loading'); 5 6 … … 15 16 16 17 echo $ajax->divEnd('envelope'); 17 ?>18 </div>19 <div style="clear:both;"></div>20 <table class="tbadmin">21 <?php22 //die(print_r($data));23 18 24 $th = array ('Edit', 'Title', 'Status', 'Classrooms', 'Delete'); 19 foreach ($data as $val) 20 { 21 $s = ($val['Webquest']['status'] == 1) ? 'Published': 'Draft'; 22 echo '<div class="grayblock">'; 23 echo $html->div('buttonright', $gags->sendEdit($val['Webquest']['id'], 'webquests')); 24 echo $html->div('div_title', $val['Webquest']['title']); 25 26 if ( count($val['Vclassroom']) < 1 ) 27 { 28 29 echo $html->para(null, $html->link( 30 $html->image('admin/vgroups-gray.gif', array( 'alt' =>'There is no class assigned for this test', 31 'title'=>'There is no class assigned for this test' ) ), 32 '/admin/webquests/vclassrooms/'.$val['Webquest']['id'], null, null, false)); 33 } 34 else 35 { 36 echo $html->para(null, $html->link( 37 $html->image('static/vgroups.gif', array( 38 'alt' =>'Assign this test to new class', 39 'title'=>'Assign this test to new class' 40 ) 41 ), 42 '/admin/webquests/vclassrooms/'.$val['Webquest']['id'], null, null, false)); 25 43 26 echo $html->tableHeaders($th); 44 foreach($val['Vclassroom'] as $class): 45 echo $html->para(null,'This test had been assigned to class: '.$html->link($class['name'],'/admin/vclassrooms/members/'.$class['id']) . '</b>'); 46 endforeach; 47 } 27 48 28 foreach ($data as $val) 29 { 30 $status = $gags->setStatus($val['Webquest']['status']); 31 $t="javascript:window.open('/admin/webquest/vclassrooms/'".$val['Webquest']['id'].", 'blank', 'toolbar=no, scrollbars=yes,width=700,height=400')"; 32 33 34 $tr = array ( 35 $gags->sendEdit($val['Webquest']['id'], 'webquests'), 36 $val['Webquest']['title'], 37 $html->link($status, '/admin/webquests/change/'.$val['Webquest']['id'] .'/'. $val['Webquest']['status']), 38 $html->link('Link to Classrooms', '#', array("onclick"=>$t)), 39 $gags->confirmDel($val['Webquest']['id'], 'webquests') 40 ); 41 42 echo $html->tableCells($tr, array("class"=>"altRow", "onmouseover"=>"this.className='highlight'", "onmouseout"=>"this.className='altRow'"), 43 array('class'=>'evenRow',"onmouseover"=>"this.className='highlight'", "onmouseout"=>"this.className='evenRow'")); 49 echo $html->para(null, $html->link($s, '/admin/webquests/change/'.$val['Webquest']['id'].'/'.$val['Webquest']['status'])); 50 echo $html->div('butonright', $gags->confirmDel($val['Webquest']['id'], 'webquests')); 51 echo '</div>'; 44 52 } 45 ?> 46 </table> 47 48 <?php 49 //echo $pagination; 53 54 //echo $pagination; 50 55 ?> 51 56
