Changeset 467

Show
Ignore:
Timestamp:
05/08/08 21:14:33 (8 months ago)
Author:
aarkerio
Message:

Forums and topics improveds

Location:
trunk/app
Files:
8 modified

Legend:

Unmodified
Added
Removed
  • trunk/app/controllers/tests_controller.php

    r466 r467  
    6666  public function view($test_id, $vclassroom_id) 
    6767  { 
     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; 
    6874        
    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 ): 
    7176         $username = $this->Test->User->field('User.username', array("User.id"=>$user_id)); 
    7277     $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     
    8180    $this->pageTitle = 'Exams'; 
    8281                
  • trunk/app/controllers/treasures_controller.php

    r466 r467  
    9797 public function view($treasure_id, $vclassroom_id) 
    9898 {     
    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 ): 
    100100         $username = $this->Test->User->field('User.username', array("User.id"=>$user_id)); 
    101101     $this->flash('You already have answered this test', '/users/portfolio/'.$username); 
    102    endif; 
     102  endif; 
    103103     
    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); 
    112114     
    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 elements 
     115  $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 
    118120             
    119    $this->set('data', $data);  
     121  $this->set('data', $data);  
    120122 } 
    121123 
  • trunk/app/controllers/vclassrooms_controller.php

    r459 r467  
    7171 } 
    7272 
    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)); 
    9293 } 
    9394 
  • trunk/app/controllers/webquests_controller.php

    r466 r467  
    7272    $this->flash('You already have answered this webquest', '/vclassrooms/show/'.$data['Webquest']['user_id'].'/'.$data['Webquest']['user_id'); 
    7373   } 
    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);  
    8889 } 
    8990  
  • trunk/app/models/test.php

    r466 r467  
    3636               'dependent'     => true, 
    3737               'exclusive'     => false, 
    38                              'finderQuery'   => null 
     38                           'finderQuery'   => null 
    3939 
    4040               ) 
     
    7575    return $vclassrooms; 
    7676 } 
     77 
    7778/* 
    7879 *  check if studen already found treasure 
  • trunk/app/models/user.php

    r434 r467  
    6060      'email'    => VALID_EMAIL 
    6161   );  
    62  
    6362} 
    6463?> 
  • trunk/app/models/vclassroom.php

    r460 r467  
    358358    } 
    359359  } 
     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 
    360380} 
    361381?> 
  • trunk/app/views/vclassrooms/show.ctp

    r466 r467  
    33echo $javascript->link('fckeditor/fckeditor');  
    44 
    5  
    6  echo  '<h1>' . $data['Vclassroom']['name']      . '</h1>'; 
     5echo  '<h1>' . $data['Vclassroom']['name']      . '</h1>'; 
    76   
    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 {   
    179     echo  $html->para(null, 'Welcome! <b>'. $cU['User']['username'].'</b>'); 
    1810     echo  $html->para(null, '<b>Created:</b> ' . $data['Vclassroom']['created']); 
     
    7062 
    7163 
    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    
    7465     echo $ajax->form(); 
    7566      
     
    8475     // empty ajax div 
    8576     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; 
    9181?> 
    9282<div id="charging" style="display:none;"><?php echo $html->image('static/loading.gif', array("alt"=>"Loading")); ?></div>