Changeset 416

Show
Ignore:
Timestamp:
04/21/08 13:05:04 (9 months ago)
Author:
aarkerio
Message:

Discussions fixed

Location:
trunk/app
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • trunk/app/config/sql/karamelo_postgres.sql

    r409 r416  
    522522--HABTM 
    523523CREATE 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 
    528531-- Treasure hunts         http://www.gma.org/surfing/imaging/treasure.html 
    529532CREATE TABLE "treasures" ( 
  • trunk/app/controllers/components/edublog.php

    r325 r416  
    99 
    1010App::import('Model','User'); 
     11App::import('Model','Vclassroom'); 
    1112 
    1213class EdublogComponent extends Object 
    1314{ 
    14   
    1515 public function startup(&$controller) 
    1616 { 
     
    106106                 ); 
    107107   
    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"); 
    110110 
    111  //return $this->User->findAll($conditions, $fields, null, null, null, 2); 
     111  $this->controller->set('blog', $this->User->find($conditions, $fields, null, 2));   
    112112 
    113  $this->controller->set('blog', $this->User->find($conditions, $fields, null, 2));   
     113 } 
    114114 
     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; 
    115127 } 
    116128 
  • trunk/app/controllers/vclassrooms_controller.php

    r398 r416  
    5252      { 
    5353       $user_id = (int) $this->Auth->user('id'); 
    54            $this->__setSession($user_id); 
     54           $this->Edublog->setSession($user_id); 
    5555      } 
    5656 } 
     
    6464      $conditions = array("Vclassroom.status"=>1, "Vclassroom.id"=>$id); 
    6565       
     66      // temporal lines, move to model later 
    6667      $this->Vclassroom->Ecourse->unbindModel(array('hasMany'=>array('Vclassroom'), 'belongsTo'=>array('User'))); 
    6768      $this->Vclassroom->Test->unbindModel(array('hasMany'=>array('Question'), 'belongsTo'=>array('User'))); 
     
    7273      { 
    7374       $user_id = (int) $this->Auth->user('id'); 
    74            $this->__setSession($user_id); 
     75           $this->Edublog->setSession($user_id); 
    7576      } 
    7677 } 
     
    106107        } 
    107108    } 
    108  } 
    109  
    110  private function __setSession($user_id) //set vclassrooms authorized to this student 
    111  { 
    112    $vclassrooms = $this->Vclassroom->chkVclassrooms($user_id); // check model 
    113  
    114    if ($vclassrooms != null) 
    115    { 
    116      $this->Session->write('vclassrooms', $vclassrooms); 
    117    } 
    118     
    119    return true; 
    120109 } 
    121110   
  • trunk/app/controllers/webquests_controller.php

    r340 r416  
    269269           $this->msgFlash('Webquest status changed', '/admin/webquests/listing'); 
    270270     } 
    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 
    272334 public function admin_delete($id) 
    273335 { 
  • trunk/app/models/webquest.php

    r282 r416  
    1212    public $belongsTo   = 'User'; 
    1313     
     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                            );      
    1428    public $validate = array( 
    1529      '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 
    22 
    3 <?php 
     3echo $html->div('title_section', 'Webquest'); 
     4 
    45echo $ajax->div('loading', array("style"=>"display: none")) . $html->image("static/loading.gif", array("alt"=>"Loading")) . $ajax->divEnd('loading'); 
    56 
     
    1516 
    1617echo $ajax->divEnd('envelope'); 
    17 ?> 
    18 </div> 
    19 <div style="clear:both;"></div> 
    20 <table class="tbadmin"> 
    21 <?php 
    22 //die(print_r($data)); 
    2318 
    24 $th = array ('Edit', 'Title', 'Status', 'Classrooms', 'Delete'); 
     19foreach ($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)); 
    2543 
    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     } 
    2748 
    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')); 
     51echo '</div>'; 
    4452} 
    45 ?> 
    46 </table> 
    47  
    48 <?php  
    49 //echo $pagination;  
     53  
     54//echo $pagination; 
    5055?> 
    5156