Changeset 468

Show
Ignore:
Timestamp:
05/09/08 00:41:41 (8 months ago)
Author:
aarkerio
Message:

Forums and topics improveds

Location:
trunk/app
Files:
13 modified

Legend:

Unmodified
Added
Removed
  • trunk/app/config/sql/postgresql/result_webquests.sql

    r444 r468  
    11CREATE TABLE result_webquests (  -- webquests student results 
    22   id serial NOT NULL UNIQUE, 
     3   answer text NOT NULL, 
    34   user_id int NOT NULL REFERENCES users(id) ON DELETE CASCADE, 
    45   points smallint NOT NULL, 
    5    webquest_id int NOT NULL REFERENCES tests(id) ON DELETE CASCADE, 
     6   webquest_id int NOT NULL REFERENCES webquests(id) ON DELETE CASCADE, 
    67   vclassroom_id int NOT NULL REFERENCES vclassrooms(id) ON DELETE CASCADE, 
    78   PRIMARY KEY (user_id, webquest_id, vclassroom_id) 
  • trunk/app/controllers/forums_controller.php

    r463 r468  
    5353 } 
    5454  
    55  public function display($forum_id)  
    56  {       
     55 public function display($forum_id, $vclassroom_id)  
     56 {       
     57  // student belongst to this class? 
     58  if ( $this->Auth->user() && $this->Auth->user('group_id') == 3): 
     59             $this->set('belongs', $this->Forum->Vclassroom->belongs($this->Auth->user('id'), $vclassroom_id)); 
     60  else: 
     61             $this->set('belongs', false); 
     62  endif; 
     63 
    5764  $conditions = array('Forum.id'=>$forum_id, 'Forum.status'=>1); 
    5865         
  • trunk/app/controllers/tests_controller.php

    r467 r468  
    6666  public function view($test_id, $vclassroom_id) 
    6767  { 
     68    $user_id = $this->Test->field('Test.user_id', array("Test.id"=>$test_id)); 
     69 
     70    $this->pageTitle = 'Exam'; 
     71                
     72    $this->layout    = $this->Edublog->layout($user_id); 
     73          
     74    $this->Edublog->blog($user_id); // set edublog components 
     75    
    6876    // student belongst to this class? 
    6977    if ( $this->Auth->user() && $this->Auth->user('group_id') == 3): 
     
    7482        
    7583    if ( $this->Test->chk($test_id, $this->Auth->user('id'), $vclassroom_id) === true ): 
    76          $username = $this->Test->User->field('User.username', array("User.id"=>$user_id)); 
    77      $this->flash('You already have answered this test', '/users/portfolio/'.$username); 
     84             $this->set('already', false); 
     85             $this->set('data', false); 
     86     else: 
     87             $this->set('already', true); 
    7888    endif; 
    7989     
    80     $this->pageTitle = 'Exams'; 
    81                 
    82     $this->layout    = $this->Edublog->layout($user_id); 
    83           
    84     $this->Edublog->blog($user_id); // set edublog components 
    8590          
    8691    $conditions = array("Test.id"=>$test_id, "Test.status"=>1); 
     
    8994 
    9095    $order  = null; 
    91  
     96     
    9297    $this->set('data', $this->Test->find($conditions, $fields, $order, 2)); 
     98 
     99    $this->set('vclassroom_id', $vclassroom_id); 
    93100 } 
    94101 
  • trunk/app/controllers/vclassrooms_controller.php

    r467 r468  
    7777   $this->Edublog->blog($user_id); 
    7878    
    79    // student belongst to this class? 
     79   // student belongs to this class? 
    8080   if ( $this->Auth->user() && $this->Auth->user('group_id') == 3): 
    8181             $this->set('belongs', $this->Vclassroom->belongs($this->Auth->user('id'), $vclassroom_id)); 
  • trunk/app/controllers/webquests_controller.php

    r467 r468  
    1616 public function beforeFilter()  
    1717 { 
    18     $this->Auth->allow(array('display', 'view')); 
     18    $this->Auth->allow(array('display', 'view', 'result')); 
    1919    parent::beforeFilter(); 
    2020 } 
     
    3636      $conditions      = array("Webquest.status"=>1); 
    3737       
    38       if ($username != null) 
    39       { 
     38      if ($username != null): 
    4039            $user_id    = $this->Webquest->User->field('id', array("username"=>$username)); 
    4140             
    4241            $conditions["Webquest.user_id"] = $user_id; 
    43       } 
    44       else 
    45       { 
    46           $this->redirect('/');  // go away 
    47       } 
     42      else: 
     43            $this->redirect('/');  // go away 
     44      endif; 
    4845       
    4946      $this->layout    = $this->Edublog->layout($user_id); 
     
    6259 public function view($webquest_id, $vclassroom_id) 
    6360 {  
    64    $conditions      = array("Webquest.status"=>1, "Webquest.id"=>$webquest_id); 
    65   
    66    $data            = $this->Webquest->find($conditions); 
    67       
     61  $conditions      = array("Webquest.status"=>1, "Webquest.id"=>$webquest_id); 
     62  
     63  $data            = $this->Webquest->find($conditions); 
     64 
     65  $this->layout    = $this->Edublog->layout($data['Webquest']['user_id']); 
     66       
     67  $this->Edublog->blog($data['Webquest']['user_id']); // blogger elements 
     68       
     69  $this->pageTitle = $data['Webquest']['title'] . '\'s Webquest';    
     70 
    6871   // the student alredy answered this webquest?    
    69    if ($this->Webquest->chk($webquest_id, $this->Auth->user('id'), $vclassroom_id) === true) 
    70    { 
    71     $username = $this->Webquest->User->field('User.username', array("User.id"=>$data['Webquest']['user_id'])); 
    72     $this->flash('You already have answered this webquest', '/vclassrooms/show/'.$data['Webquest']['user_id'].'/'.$data['Webquest']['user_id'); 
    73    } 
     72  if ($this->Webquest->chk($webquest_id, $this->Auth->user('id'), $vclassroom_id) === true): 
     73         $this->set('already', true); 
     74  else: 
     75         $this->set('already', false); 
     76  endif; 
    7477 
    7578  // student belongst to this class? 
     
    8083  endif; 
    8184            
    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  
    8885  $this->set('data', $data);  
    89  } 
    90   
     86  $this->set('vclassroom_id', $vclassroom_id); 
     87 } 
     88  
     89 public function result() 
     90 {  
     91      // adds new blog entries  
     92      if ( !empty($this->data['ResultWebquest']) )   
     93      { 
     94         $this->Sanitize = new Sanitize; 
     95          
     96         $this->Sanitize->clean($this->data['ResultWebquest']);  
     97 
     98         $this->data['ResultWebquest']['user_id'] = $this->Auth->user('id'); 
     99          
     100         $this->Webquest->ResultWebquest->create(); 
     101          
     102         if ($this->Webquest->ResultWebquest->save($this->data['ResultWebquest'])) 
     103         { 
     104             $this->msgFlash('Webquest saved',  
     105          '/vclassrooms/show/'.$this->data['ResultWebquest']['blogger_id'].'/'.$this->data['ResultWebquest']['vclassroom_id']); 
     106         } 
     107         else  
     108         { 
     109            $this->msgFlash('Database error!', '/admin/webquests/listing'); 
     110         } 
     111      } 
     112 } 
    91113 /** ADMIN METHODS**/ 
    92114 public function admin_listing() 
  • trunk/app/models/test.php

    r467 r468  
    8888    $data       =  $this->Result->field('Result.id', $conditions); 
    8989    
    90     if ($data != null ): 
     90    if ($data == false ): 
    9191          return false;    
    9292    else: 
  • trunk/app/models/treasure.php

    r466 r468  
    5252   $data      = $this->ResultTreasure->field('ResultTreasure.id', $conditions); 
    5353    
    54    if ($data != null ): 
     54   if ( $data == false ): 
    5555          return false;    
    5656   else: 
  • trunk/app/models/webquest.php

    r466 r468  
    4545 
    4646/* 
    47  *  check if studen already found treasure 
     47 *  check if studen already found webquest 
    4848 *  int treasure_id  
    4949 *  int user_id       
     
    5454    $conditions =  array("ResultWebquest.user_id"=>$user_id, "ResultWebquest.webquest_id"=>$webquest_id, "ResultWebquest.vclassroom_id"=>$vclassroom_id); 
    5555    $data       =  $this->ResultWebquest->field('ResultWebquest.id', $conditions); 
    56     
    57     if ($data != null ): 
     56     
     57    if ($data == false ): 
    5858          return false;    
    5959    else: 
  • trunk/app/views/forums/display.ctp

    r462 r468  
    11<?php 
    22//die(debug($data)); 
     3 
     4if ( $belongs === true ): 
    35 echo $html->div(null, 'Category: ' . $data['Catforum']['title'], array('style'=>'font-weight:bold;')); 
    46 
     
    4951       echo '</table>';  
    5052  
    51  if ( ! isset( $cU ) )  
    52  { 
    53          echo $html->div(null, $this->renderElement('login')); 
    54  } 
     53  echo $html->para(null, 'Legend:'); 
    5554 
    56 echo $html->para(null, 'Leyenda del Tema'); 
     55  $tmp  = $html->image('static/board.gif', array("alt"=>"Tema normal", "title"=>"Tema normal")) . ' Tema normal <br />'; 
     56  $tmp .= $html->image('static/locked.gif', array("alt"=>"Tema bloqueado", "title"=>"Tema bloqueado")) . ' Tema bloqueado<br />'; 
     57  $tmp .= $html->image('static/new.gif', array("alt"=>"Comentario nuevo", "title"=>"Comentario nuevo")). ' Comentario nuevo<br />'; 
    5758 
    58 $tmp  = $html->image('static/board.gif', array("alt"=>"Tema normal", "title"=>"Tema normal")) . ' Tema normal <br />'; 
    59 $tmp .= $html->image('static/locked.gif', array("alt"=>"Tema bloqueado", "title"=>"Tema bloqueado")) . ' Tema bloqueado<br />'; 
    60 $tmp .= $html->image('static/new.gif', array("alt"=>"Comentario nuevo", "title"=>"Comentario nuevo")). ' Comentario nuevo<br />'; 
    61  
    62 echo $html->para(null, $tmp); 
     59  echo $html->para(null, $tmp); 
     60else: 
     61  e($html->para(null, 'You must be logged and belogs to this class to see the forum')); 
     62endif; 
    6363?> 
  • trunk/app/views/tests/view.ctp

    r457 r468  
    11<?php 
    2 //die(debug($data)); 
    3  
    4 $auth = false; 
    5 // esto lo tengo que cambiar porque esta de la verch 
    6 if ( $session->check('vclassrooms') ): 
    7    foreach($data['Vclassroom'] as $v): 
    8        if ( in_array($v['id'], $session->read('vclassrooms'))): 
    9               $auth = true; 
    10               $vclassroom_id = $v['id'];  
    11           break; 
    12        endif; 
    13    endforeach; 
     2//die(debug($already));   
     3if ( $already === true ): 
     4      e($html->para(null, 'You already have answered this test')); 
    145endif; 
    156 
    16 // die(var_dump($auth)); 
    177 
    18 if ( $auth === true ): 
     8if ( $belongs === true && $already === false): 
    199  echo $html->para(null, 'hi! '.$cU['User']['username'], array('style'=>'font-weight:bold;font-size:12pt;')); 
    2010  echo $html->div('title', $blog['User']['username'] .'s Exam'); 
     
    5343  echo $form->end('Send'); 
    5444 
    55 else: 
    56    echo $html->para(null, 'You must belong to class to see this exam'); 
     45endif; 
     46 
     47if ( !isset($cU) ): 
     48      e($html->para(null, 'You must belong to class to see this exam')); 
    5749endif; 
    5850 
  • trunk/app/views/vclassrooms/show.ctp

    r467 r468  
    1717 
    1818        foreach($data['Forum'] as $f): 
    19              echo $html->para(null, $html->link($f['title'], '/forums/display/'.$f['id'])); 
     19             echo $html->para(null, $html->link($f['title'], '/forums/display/'.$f['id'].'/'.$data['Vclassroom']['id'])); 
    2020        endforeach; 
    2121    endif; 
     
    7575     // empty ajax div 
    7676     echo $ajax->div('updater') . $ajax->divEnd('updater');  
    77     
    78  elseif ( !isset( $cU['User']) ): 
     77endif; 
     78 
     79if ( !isset( $cU['User']) ): 
    7980     e($html->link('Login to join this group', '/users/login')); 
    80  endif; 
     81endif; 
    8182?> 
    8283<div id="charging" style="display:none;"><?php echo $html->image('static/loading.gif', array("alt"=>"Loading")); ?></div> 
  • trunk/app/views/webquests/display.ctp

    r270 r468  
    55{ 
    66echo '<div style="margin:10px;padding:5px;background-color:yellow;border:1px dotted red;">';  
    7    echo '<div>'.$html->link($v['Webquest']['title'], '/webquests/view/'.$blog['User']['username'].'/'.$v['Webquest']['id']) . '</div>'; 
     7   echo '<div>'.$v['Webquest']['title'] . '</div>'; 
    88   echo '<div>' . $v['Webquest']['introduction'].'</div>'; 
    99echo '</div>'; 
  • trunk/app/views/webquests/view.ctp

    r422 r468  
    11<?php 
    2 //die(debug($data)); 
    3 $auth = false; 
     2//die(debug($blog)); 
    43 
    5 if ( $session->check('vclassrooms') ): 
    6    foreach($data['Vclassroom'] as $v): 
    7        if ( in_array($v['id'], $session->read('vclassrooms'))): 
    8               $auth = true; 
    9           break; 
    10        endif; 
    11    endforeach; 
     4if ( $already === true ): 
     5      e($html->para(null, 'You already have answered this webquest')); 
    126endif; 
    13   
    14 if ( $auth === true ): 
     7 
     8if ( $belongs === true && $already === false): 
     9 
    1510  echo $html->para(null, 'hi! '.$cU['User']['username'], array('style'=>'font-weight:bold;font-size:12pt;')); 
    1611?>  
     
    4035echo '</div>'; 
    4136 
    42 echo $form->create('Result', array('onsubmit'=>'return chkForm()')); 
     37echo '<fieldset>'; 
     38  echo $form->create('Webquest', array('action'=>'result', 'onsubmit'=>'return chkForm()')); 
     39  echo $form->hidden('ResultWebquest.points', array('value'=>$data['Webquest']['points'])); 
     40  echo $form->hidden('ResultWebquest.webquest_id', array('value'=>$data['Webquest']['id'])); 
     41  echo $form->hidden('ResultWebquest.vclassroom_id', array('value'=>$vclassroom_id)); 
     42  echo $form->hidden('ResultWebquest.blogger_id', array('value'=>$blog['User']['id'])); 
    4343 
    44 echo $form->label('Result.answer', 'Answer:').'<br />'; 
    45 echo $form->textarea('Result.answer', array('cols'=>60, 'rows'=>20)); 
    46 echo $form->end('Send'); 
     44  echo $form->label('ResultWebquest.answer', 'Answer:').'<br />'; 
     45  echo $form->textarea('ResultWebquest.answer', array('cols'=>50, 'rows'=>20)); 
     46  echo $form->end('Send'); 
     47echo '</fieldset>'; 
    4748 
    48 else: 
    49      echo $html->link('Login to join this group', '/users/login'); 
    5049endif; 
     50 
     51if ( !isset($cU) ): 
     52      e($html->para(null, 'You must belong to class to see this exam')); 
     53endif; 
     54 
     55?>