Changeset 466
- Timestamp:
- 05/08/08 19:18:13 (8 months ago)
- Location:
- trunk/app
- Files:
-
- 7 modified
-
controllers/tests_controller.php (modified) (2 diffs)
-
controllers/treasures_controller.php (modified) (2 diffs)
-
controllers/webquests_controller.php (modified) (2 diffs)
-
models/test.php (modified) (2 diffs)
-
models/treasure.php (modified) (1 diff)
-
models/webquest.php (modified) (1 diff)
-
views/vclassrooms/show.ctp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/controllers/tests_controller.php
r464 r466 64 64 } 65 65 66 public function view($test_id, $ user_id)66 public function view($test_id, $vclassroom_id) 67 67 { 68 // the student alredy answered this test? 69 $already = $this->Test->Result->field('Result.id', array("Result.user_id"=>$this->Auth->user('id'), "Result.test_id"=>$test_id)); 70 71 if ($already != null) 68 69 if ( $this->Test->chk($test_id, $this->Auth->user('id'), $vclassroom_id) === true ) 72 70 { 73 71 $username = $this->Test->User->field('User.username', array("User.id"=>$user_id)); … … 77 75 if ( $this->Auth->user() && $this->Auth->user('group_id') == 3) 78 76 { 79 $student_id = (int) $this->Auth->user('id');77 $student_id = (int) $this->Auth->user('id'); 80 78 $this->Edublog->setSession($student_id); //check if user belongs to class 81 79 } -
trunk/app/controllers/treasures_controller.php
r441 r466 34 34 return false; // go away !! 35 35 } 36 37 /* 38 * check if tresure string is OK, if so, save student data on ResultTreasure model 39 * 40 */ 41 36 42 public function chksw() 37 43 { … … 89 95 } 90 96 91 public function view($treasure_id )97 public function view($treasure_id, $vclassroom_id) 92 98 { 93 $conditions = array("Treasure.status"=>1, "Treasure.id"=>$treasure_id); 94 95 $data = $this->Treasure->find($conditions); 99 if ( $this->Test->chk($test_id, $this->Auth->user('id'), $vclassroom_id) === true ): 100 $username = $this->Test->User->field('User.username', array("User.id"=>$user_id)); 101 $this->flash('You already have answered this test', '/users/portfolio/'.$username); 102 endif; 103 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); 96 112 97 $this->layout = $this->Edublog->layout($data['Treasure']['user_id']);98 99 $this->pageTitle = 'Treasure Hunt';100 101 $this->Edublog->blog($data['Treasure']['user_id']); // blogger elements113 $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 102 118 103 $this->set('data', $data); 104 } 105 119 $this->set('data', $data); 120 } 106 121 107 122 /** === ADMIN METHODS === **/ -
trunk/app/controllers/webquests_controller.php
r464 r466 60 60 } 61 61 62 public function view($webquest_id )62 public function view($webquest_id, $vclassroom_id) 63 63 { 64 64 $conditions = array("Webquest.status"=>1, "Webquest.id"=>$webquest_id); … … 67 67 68 68 // the student alredy answered this webquest? 69 if ($this->Webquest->chk($webquest_id, $this->Auth->user('id') ) === true)69 if ($this->Webquest->chk($webquest_id, $this->Auth->user('id'), $vclassroom_id) === true) 70 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', '/users/portfolio/'.$username);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 73 } 74 74 -
trunk/app/models/test.php
r428 r466 75 75 return $vclassrooms; 76 76 } 77 /* 78 * check if studen already found treasure 79 * int treasure_id 80 * int user_id 81 * int vclassroom_id 82 * return boolean 83 */ 84 public function chk($test_id, $user_id, $vclassroom_id) 85 { 86 $conditions = array("Result.user_id"=>$user_id, "Result.test_id"=>$test_id, "Result.vclassroom_id"=>$vclassroom_id); 87 $data = $this->Result->field('Result.id', $conditions); 88 89 if ($data != null ): 90 return false; 91 else: 92 return true; 93 endif; 94 } 77 95 78 96 public function chkAnswers($answers, $test_id) … … 82 100 $result = 0; 83 101 84 foreach($questions as $q_id => $a_id) // question id and answer id 85 { 102 foreach($questions as $q_id => $a_id): // question id and answer id 86 103 $correct_answer = $this->Test->Question->Answer->field('Answer.correct', array('Answer.id'=>$a_id)); // answer was correct? 87 104 88 if ($correct_answer == 1) 89 { 105 if ($correct_answer == 1): 90 106 $worth = $this->Test->Question->field('Question.worth', array('Question.id'=>$q_id)); // how many points 91 107 $result += $worth; 92 }93 }94 //exit('Result was:' . $result) ;108 endif; 109 endforeach; 110 //exit('Result was:' . $result)e 95 111 return $result; 96 112 } -
trunk/app/models/treasure.php
r465 r466 42 42 * int treasure_id 43 43 * int user_id 44 * int vclassroom_id 44 45 * return boolean 45 46 */ 46 public function chk($treasure_id, $user_id )47 public function chk($treasure_id, $user_id, $vclassroom_id) 47 48 { 48 49 49 $conditons = array("ResultTreasure.user_id"=>$user_id, "ResultTreasure.treasure_id"=>$treasure_id );50 $conditons = array("ResultTreasure.user_id"=>$user_id, "ResultTreasure.treasure_id"=>$treasure_id, "ResultTreasure.vclassroom_id"=>$vclassroom_id); 50 51 51 $data = $this->ResultTreasure->field('ResultTreasure.id', $conditions) );52 $data = $this->ResultTreasure->field('ResultTreasure.id', $conditions); 52 53 53 54 if ($data != null ): -
trunk/app/models/webquest.php
r465 r466 50 50 * return boolean 51 51 */ 52 public function chk($webquest_id, $user_id)53 {54 $conditions = array("ResultWebquest.user_id"=>$user_id, "ResultWebquest.webquest_id"=>$webquest_id );52 public function chk($webquest_id, $user_id, $vclassroom_id) 53 { 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 56 -
trunk/app/views/vclassrooms/show.ctp
r461 r466 19 19 echo $html->para(null, '<b>Subject</b>: ' . $data['Ecourse']['title']); 20 20 echo $html->para(null, '<b>Course description</b>:'. $data['Ecourse']['description']); 21 22 if ( count($data['Test']) > 0) 23 { 21 22 // Forums 23 if ( count($data['Forum']) > 0): 24 echo $html->div('titentry', 'Forums'); 25 26 foreach($data['Forum'] as $f): 27 echo $html->para(null, $html->link($f['title'], '/forums/display/'.$f['id'])); 28 endforeach; 29 endif; 30 31 // Tests 32 if ( count($data['Test']) > 0): 24 33 echo $html->div('titentry', 'Quizz Tests'); 25 34 26 foreach($data['Test'] as $t) 27 { 28 echo $html->para(null, $html->link($t['title'], '/tests/view/'.$t['id'].'/'.$t['user_id'])); 29 } 30 } 35 foreach($data['Test'] as $t): 36 echo $html->para(null, $html->link($t['title'], '/tests/view/'.$t['id'].'/'.$data['Vclassroom']['id'])); 37 endforeach; 38 endif; 31 39 32 if ( count($data['Forum']) > 0) 33 { 34 echo $html->div('titentry', 'Forums'); 35 36 foreach($data['Forum'] as $f) 37 { 38 echo $html->para(null, $html->link($f['title'], '/forums/display/'.$f['id'])); 39 } 40 } 41 42 if ( count($data['Webquest']) > 0) 43 { 40 // Webquests 41 if ( count($data['Webquest']) > 0): 44 42 echo $html->div('titentry', 'Webquests'); 45 43 46 foreach($data['Webquest'] as $wq) 47 { 48 echo $html->para(null, $html->link($wq['title'], '/webquests/view/'.$wq['id'])); 49 } 50 } 44 foreach($data['Webquest'] as $wq): 45 echo $html->para(null, $html->link($wq['title'], '/webquests/view/'.$wq['id'].'/'.$data['Vclassroom']['id'])); 46 endforeach; 47 endif; 51 48 52 if ( count($data['Treasure']) > 0) 53 { 49 if ( count($data['Treasure']) > 0): 54 50 echo $html->div('titentry', 'Treasure Hunts'); 55 51 56 foreach($data['Treasure'] as $t)57 {58 echo $html->para(null, $html->link($t['title'], '/treasures/view/'.$t['id']));59 }60 } 61 echo $ajax->form();52 foreach($data['Treasure'] as $t): 53 echo $html->para(null, $html->link($t['title'], '/treasures/view/'.$t['id'].'/'.$data['Vclassroom']['id'])); 54 endforeach; 55 endif; 56 57 echo $ajax->form(); 62 58 63 echo $form->hidden('Participation.vclassroom_id', array('value'=>$data['Vclassroom']['id']));64 echo $form->hidden('Participation.blogger_id', array('value'=>$blog['User']['id'])); // this to return65 echo $ajax->submit('Start participating', array("url" => "/vclassrooms/participation/",59 echo $form->hidden('Participation.vclassroom_id', array('value'=>$data['Vclassroom']['id'])); 60 echo $form->hidden('Participation.blogger_id', array('value'=>$blog['User']['id'])); // this to return 61 echo $ajax->submit('Start participating', array("url" => "/vclassrooms/participation/", 66 62 "update"=>"setform", 67 63 "loading" => "Element.show('charging');Element.hide('setform')", 68 64 "complete" => "Element.hide('charging');Effect.Appear('setform')" 69 65 )); 70 echo '</form>';71 // empty ajax div72 echo $ajax->div('setform') . $ajax->divEnd('setform');66 echo '</form>'; 67 // empty ajax div 68 echo $ajax->div('setform') . $ajax->divEnd('setform'); 73 69 } 74 70
