Changeset 468
- Timestamp:
- 05/09/08 00:41:41 (8 months ago)
- Location:
- trunk/app
- Files:
-
- 13 modified
-
config/sql/postgresql/result_webquests.sql (modified) (1 diff)
-
controllers/forums_controller.php (modified) (1 diff)
-
controllers/tests_controller.php (modified) (3 diffs)
-
controllers/vclassrooms_controller.php (modified) (1 diff)
-
controllers/webquests_controller.php (modified) (4 diffs)
-
models/test.php (modified) (1 diff)
-
models/treasure.php (modified) (1 diff)
-
models/webquest.php (modified) (2 diffs)
-
views/forums/display.ctp (modified) (2 diffs)
-
views/tests/view.ctp (modified) (2 diffs)
-
views/vclassrooms/show.ctp (modified) (2 diffs)
-
views/webquests/display.ctp (modified) (1 diff)
-
views/webquests/view.ctp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/config/sql/postgresql/result_webquests.sql
r444 r468 1 1 CREATE TABLE result_webquests ( -- webquests student results 2 2 id serial NOT NULL UNIQUE, 3 answer text NOT NULL, 3 4 user_id int NOT NULL REFERENCES users(id) ON DELETE CASCADE, 4 5 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, 6 7 vclassroom_id int NOT NULL REFERENCES vclassrooms(id) ON DELETE CASCADE, 7 8 PRIMARY KEY (user_id, webquest_id, vclassroom_id) -
trunk/app/controllers/forums_controller.php
r463 r468 53 53 } 54 54 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 57 64 $conditions = array('Forum.id'=>$forum_id, 'Forum.status'=>1); 58 65 -
trunk/app/controllers/tests_controller.php
r467 r468 66 66 public function view($test_id, $vclassroom_id) 67 67 { 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 68 76 // student belongst to this class? 69 77 if ( $this->Auth->user() && $this->Auth->user('group_id') == 3): … … 74 82 75 83 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); 78 88 endif; 79 89 80 $this->pageTitle = 'Exams';81 82 $this->layout = $this->Edublog->layout($user_id);83 84 $this->Edublog->blog($user_id); // set edublog components85 90 86 91 $conditions = array("Test.id"=>$test_id, "Test.status"=>1); … … 89 94 90 95 $order = null; 91 96 92 97 $this->set('data', $this->Test->find($conditions, $fields, $order, 2)); 98 99 $this->set('vclassroom_id', $vclassroom_id); 93 100 } 94 101 -
trunk/app/controllers/vclassrooms_controller.php
r467 r468 77 77 $this->Edublog->blog($user_id); 78 78 79 // student belongs tto this class?79 // student belongs to this class? 80 80 if ( $this->Auth->user() && $this->Auth->user('group_id') == 3): 81 81 $this->set('belongs', $this->Vclassroom->belongs($this->Auth->user('id'), $vclassroom_id)); -
trunk/app/controllers/webquests_controller.php
r467 r468 16 16 public function beforeFilter() 17 17 { 18 $this->Auth->allow(array('display', 'view' ));18 $this->Auth->allow(array('display', 'view', 'result')); 19 19 parent::beforeFilter(); 20 20 } … … 36 36 $conditions = array("Webquest.status"=>1); 37 37 38 if ($username != null) 39 { 38 if ($username != null): 40 39 $user_id = $this->Webquest->User->field('id', array("username"=>$username)); 41 40 42 41 $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; 48 45 49 46 $this->layout = $this->Edublog->layout($user_id); … … 62 59 public function view($webquest_id, $vclassroom_id) 63 60 { 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 68 71 // 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; 74 77 75 78 // student belongst to this class? … … 80 83 endif; 81 84 82 $this->layout = $this->Edublog->layout($data['Webquest']['user_id']);83 84 $this->Edublog->blog($data['Webquest']['user_id']); // blogger elements85 86 $this->pageTitle = $data['Webquest']['title'] . '\'s Webquest';87 88 85 $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 } 91 113 /** ADMIN METHODS**/ 92 114 public function admin_listing() -
trunk/app/models/test.php
r467 r468 88 88 $data = $this->Result->field('Result.id', $conditions); 89 89 90 if ($data != null):90 if ($data == false ): 91 91 return false; 92 92 else: -
trunk/app/models/treasure.php
r466 r468 52 52 $data = $this->ResultTreasure->field('ResultTreasure.id', $conditions); 53 53 54 if ( $data != null):54 if ( $data == false ): 55 55 return false; 56 56 else: -
trunk/app/models/webquest.php
r466 r468 45 45 46 46 /* 47 * check if studen already found treasure47 * check if studen already found webquest 48 48 * int treasure_id 49 49 * int user_id … … 54 54 $conditions = array("ResultWebquest.user_id"=>$user_id, "ResultWebquest.webquest_id"=>$webquest_id, "ResultWebquest.vclassroom_id"=>$vclassroom_id); 55 55 $data = $this->ResultWebquest->field('ResultWebquest.id', $conditions); 56 57 if ($data != null):56 57 if ($data == false ): 58 58 return false; 59 59 else: -
trunk/app/views/forums/display.ctp
r462 r468 1 1 <?php 2 2 //die(debug($data)); 3 4 if ( $belongs === true ): 3 5 echo $html->div(null, 'Category: ' . $data['Catforum']['title'], array('style'=>'font-weight:bold;')); 4 6 … … 49 51 echo '</table>'; 50 52 51 if ( ! isset( $cU ) ) 52 { 53 echo $html->div(null, $this->renderElement('login')); 54 } 53 echo $html->para(null, 'Legend:'); 55 54 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 />'; 57 58 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); 60 else: 61 e($html->para(null, 'You must be logged and belogs to this class to see the forum')); 62 endif; 63 63 ?> -
trunk/app/views/tests/view.ctp
r457 r468 1 1 <?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)); 3 if ( $already === true ): 4 e($html->para(null, 'You already have answered this test')); 14 5 endif; 15 6 16 // die(var_dump($auth));17 7 18 if ( $ auth === true):8 if ( $belongs === true && $already === false): 19 9 echo $html->para(null, 'hi! '.$cU['User']['username'], array('style'=>'font-weight:bold;font-size:12pt;')); 20 10 echo $html->div('title', $blog['User']['username'] .'s Exam'); … … 53 43 echo $form->end('Send'); 54 44 55 else: 56 echo $html->para(null, 'You must belong to class to see this exam'); 45 endif; 46 47 if ( !isset($cU) ): 48 e($html->para(null, 'You must belong to class to see this exam')); 57 49 endif; 58 50 -
trunk/app/views/vclassrooms/show.ctp
r467 r468 17 17 18 18 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'])); 20 20 endforeach; 21 21 endif; … … 75 75 // empty ajax div 76 76 echo $ajax->div('updater') . $ajax->divEnd('updater'); 77 78 elseif ( !isset( $cU['User']) ): 77 endif; 78 79 if ( !isset( $cU['User']) ): 79 80 e($html->link('Login to join this group', '/users/login')); 80 endif;81 endif; 81 82 ?> 82 83 <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 5 5 { 6 6 echo '<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>'; 8 8 echo '<div>' . $v['Webquest']['introduction'].'</div>'; 9 9 echo '</div>'; -
trunk/app/views/webquests/view.ctp
r422 r468 1 1 <?php 2 //die(debug($data)); 3 $auth = false; 2 //die(debug($blog)); 4 3 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; 4 if ( $already === true ): 5 e($html->para(null, 'You already have answered this webquest')); 12 6 endif; 13 14 if ( $auth === true ): 7 8 if ( $belongs === true && $already === false): 9 15 10 echo $html->para(null, 'hi! '.$cU['User']['username'], array('style'=>'font-weight:bold;font-size:12pt;')); 16 11 ?> … … 40 35 echo '</div>'; 41 36 42 echo $form->create('Result', array('onsubmit'=>'return chkForm()')); 37 echo '<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'])); 43 43 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'); 47 echo '</fieldset>'; 47 48 48 else:49 echo $html->link('Login to join this group', '/users/login');50 49 endif; 50 51 if ( !isset($cU) ): 52 e($html->para(null, 'You must belong to class to see this exam')); 53 endif; 54 55 ?>
