Changeset 419
- Timestamp:
- 04/22/08 23:03:55 (9 months ago)
- Location:
- trunk/app
- Files:
-
- 9 modified
-
controllers/questions_controller.php (modified) (4 diffs)
-
controllers/tests_controller.php (modified) (1 diff)
-
controllers/webquests_controller.php (modified) (1 diff)
-
views/questions/questions.ctp (modified) (1 diff)
-
views/tests/admin_questions.ctp (modified) (1 diff)
-
views/tests/view.ctp (modified) (1 diff)
-
views/vclassrooms/show.ctp (modified) (1 diff)
-
views/webquests/admin_edit.ctp (modified) (3 diffs)
-
views/webquests/view.ctp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/controllers/questions_controller.php
r363 r419 43 43 if ( $this->Question->save( $this->data['Question'] ) ) 44 44 { 45 $conditions = array( "Question.test_id"=> $this->data['Question']['test_id']);46 $fields = array( "Question.id", "Question.question", "Question.hint", "Question.worth", "Question.explanation");45 $conditions = array('Question.test_id' => $this->data['Question']['test_id']); 46 $fields = array('Question.id','Question.question','Question.hint','Question.worth','Question.explanation','Question.test_id'); 47 47 $order = "Question.id"; 48 48 … … 50 50 51 51 $this->render('questions', 'ajax'); 52 }53 else54 {52 } 53 else 54 { 55 55 echo "Ajax error, please report this bug"; 56 }56 } 57 57 } 58 58 } … … 70 70 if ( $this->Question->save( $this->data['Question'] ) ) 71 71 { 72 $this->msgFlash('Question saved', '/admin/tests/questions/'.$this->data[ "Question"]["test_id"]);72 $this->msgFlash('Question saved', '/admin/tests/questions/'.$this->data['Question']['test_id']); 73 73 } 74 74 else … … 124 124 } 125 125 126 public function admin_delete( $id)126 public function admin_delete() 127 127 { 128 // deletes from database 129 130 if ( $this->Question->del($id) ) 131 { 132 $this->redirect('/admin/tests/listing'); 133 } 134 else 135 { 128 if ( $this->Question->del($this->data['Question']['id']) ): 129 $this->redirect('/admin/tests/questions/'.$this->data['Question']['test_id']); 130 else: 136 131 $this->flash('Database error!', '/admin/tests/listing'); 137 }132 endif; 138 133 } 139 134 } -
trunk/app/controllers/tests_controller.php
r373 r419 66 66 public function view($test_id, $user_id) 67 67 { 68 $already = $this->Test->Result->field('Result.id', array("Result.user_id"=>$this->Auth->user('id'), "Result.test_id"=>$test_id)); 69 70 if ($already != null) 71 { 68 // the student alredy answer? 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) 72 { 72 73 $username = $this->Test->User->field('User.username', array("User.id"=>$user_id)); 73 74 $this->flash('You already have answered this test', '/users/portfolio/'.$username); 74 75 exit(); 76 } 77 78 if ( $this->Auth->user() && $this->Auth->user('group_id') == 3) 79 { 80 $user_id = (int) $this->Auth->user('id'); 81 $this->Edublog->setSession($user_id); 75 82 } 76 83 -
trunk/app/controllers/webquests_controller.php
r418 r419 60 60 } 61 61 62 public function view($username, $webquest_id) 63 { 64 $conditions = array("status"=>1); 65 66 if ($username != null) 67 { 68 $user_id = $this->Webquest->User->field('id', array("username"=>$username)); 69 70 $conditions["Webquest.user_id"] = $user_id; 71 72 $conditions["Webquest.id"] = $webquest_id; 73 } 74 else 75 { 76 $this->redirect('/'); // go away 77 } 78 79 $this->layout = $this->Edublog->layout($user_id); 80 81 $this->Edublog->blog($user_id); // blogger elements 82 83 $this->pageTitle = $username . '\'s Webquests'; 84 85 $fields = array("id", "title", "introduction", "tasks", "process", "evaluation", "conclusion", "created", "roles"); 86 87 $this->set('username',$username); 88 $this->set('data', $this->Webquest->find($conditions, $fields)); 62 public function view($webquest_id) 63 { 64 if ( $this->Auth->user() && $this->Auth->user('group_id') == 3) 65 { 66 $user_id = (int) $this->Auth->user('id'); 67 $this->Edublog->setSession($user_id); 68 } 69 70 $conditions = array("Webquest.status"=>1, "Webquest.id"=>$webquest_id); 71 72 $data = $this->Webquest->find($conditions); 73 74 $this->layout = $this->Edublog->layout($data['Webquest']['user_id']); 75 76 $this->Edublog->blog($data['Webquest']['user_id']); // blogger elements 77 78 $this->pageTitle = $data['Webquest']['title'] . '\'s Webquest'; 79 80 $this->set('data', $data); 89 81 } 90 82 -
trunk/app/views/questions/questions.ctp
r363 r419 6 6 foreach ($data as $val) 7 7 { 8 $answers = count($val[ "Answer"]);8 $answers = count($val['Answer']); 9 9 $i++; 10 10 echo '<div style="padding:5px;border:1px dotted gray;margin:auto;width:60%"><b>' . $i . '.-</b> '; 11 11 echo $html->div('butonright', $gags->sendEdit($val['Question']['id'], 'Question')); 12 echo $html->div('butonright', $gags->confirmDel($val['Question']['id'], 'Question')); 12 echo $html->div('butonright', 13 $form->create('Question', array('action'=>'delete', 'onsubmit'=>'return confirm("are you sure?")')). 14 $form->hidden('Question.id', array('value'=>$val['Question']['id'])).$form->hidden('Question.test_id', array('value'=>$val['Question']['test_id'])).$form->end('Delete')); 15 13 16 echo "Question: " . $val['Question']['question'] . "<br />"; 14 17 echo "Hint: " . $val['Question']['hint'] . "<br />"; -
trunk/app/views/tests/admin_questions.ctp
r363 r419 57 57 foreach ($data["Question"] as $val) 58 58 { 59 $answers = count($val[ "Answer"]);59 $answers = count($val['Answer']); 60 60 $i++; 61 61 echo '<div style="padding:5px;border:1px dotted gray;margin:auto;width:60%"><b>' . $i . '.-</b> '; 62 62 echo $html->div('butonright', $gags->sendEdit($val['id'], 'Question')); 63 echo $html->div('butonright', $gags->confirmDel($val['id'], 'Question')); 63 echo $html->div('butonright', 64 $form->create('Question', array('action'=>'delete', 'onsubmit'=>'return confirm("are you sure?")')). 65 $form->hidden('Question.id', array('value'=>$val['id'])).$form->hidden('Question.test_id', array('value'=>$val['test_id'])).$form->end('Delete')); 66 64 67 echo "Question: " . $val["question"] . "<br />"; 65 68 echo "Hint: " . $val["hint"] . "<br />"; 66 69 echo "Explanation: " . $val["explanation"] . "<br />"; 67 70 echo "Worth: " . $val["worth"] . "<br /><br />"; 68 echo $html->link('View answers ('.$answers.')', '/admin/questions/answers/'.$val[ "id"]);71 echo $html->link('View answers ('.$answers.')', '/admin/questions/answers/'.$val['id']); 69 72 echo '</div>'; 70 73 } -
trunk/app/views/tests/view.ctp
r398 r419 2 2 //die(debug($data)); 3 3 4 echo $html->div('title', $blog['User']['username'] .'s Exam'); 5 6 if ( $cU['User'] ) 7 { 8 echo '<h1>'. $data['Test']['title'] . '</h1>'; 9 echo '<p>'. $data['Test']['description'] . '</p>'; 10 11 echo $form->create('Test', array('action'=>'/tests/result/', 'onsubmit'=>"return confirm('Are you sure?')")); 12 echo $form->hidden('Question.test_id', array('value'=>$data['Test']['id'])); 13 14 foreach ($data['Question'] as $val) 15 { 16 //exit(var_dump($val)); 17 echo '<div>'; 18 echo '<div style="font-size:14pt;margin:5px 0 6px 0">' . $val['question'] .' '. $val['worth'] .'</div>'; 19 20 $options = array(); 21 22 foreach ($val["Answer"] as $v) 23 { 24 $options[$v['id']] = $v['answer']; 25 } 26 27 echo $form->radio('Result.'.$val['id'], $options, '<br />'); 28 29 echo '<br /><b>Hint</b>: <i>' . $val['hint'] . '</i><br /><br />'; 30 echo '</div>'; 31 } 32 33 echo $form->end('Send'); 34 35 } 36 else 37 { 38 echo $html->para(null, 'You must be logged to see this exam'); 39 } 4 $auth = false; 5 6 if ( $session->check('vclassrooms') ): 7 foreach($data['Vclassroom'] as $v): 8 $auth = ( in_array($v['id'], $session->read('vclassrooms'))) ? true : false; // students belongs this vclass ? 9 endforeach; 10 endif; 11 12 if ( $auth === true ): 13 echo $html->para(null, 'hi! '.$cU['User']['username'], array('style'=>'font-weight:bold;font-size:12pt;')); 14 echo $html->div('title', $blog['User']['username'] .'s Exam'); 40 15 41 16 17 echo '<h1>'. $data['Test']['title'] . '</h1>'; 18 echo '<p>'. $data['Test']['description'] . '</p>'; 42 19 20 echo $form->create('Test', array('action'=>'result', 'onsubmit'=>"return chkTest()")); 21 //echo $form->hidden('Result.test_id', array('value'=>$data['Test']['id'])); 22 23 foreach ($data['Question'] as $val): 24 //exit(var_dump($val)); 25 echo '<div>'; 26 echo $html->div(null, $val['question'] .' '. $val['worth'], array('style'=>'font-size:14pt;margin:5px 0 6px 0')); 27 28 $options = array(); // to build options radio buttons 29 30 foreach ($val['Answer'] as $v): 31 $options[$v['id']] = $v['answer']; 32 endforeach; 33 34 echo $form->radio('Result.'.$val['id'], $options); 35 36 echo $html->para(null, $val['hint']); 37 echo '</div>'; 38 endforeach; 39 40 echo $form->end('Send'); 41 42 else: 43 echo $html->para(null, 'You must belong to class to see this exam'); 44 endif; 45 46 ?> 47 48 <script type="text/javascript"> 49 50 function chkTest() 51 { 52 // set var radio_choice to false 53 var radio_choice = false; 54 55 // Loop from zero to the one minus the number of radio button selections 56 for (counter = 0; counter < radio_form.radio_button.length; counter++) 57 { 58 // If a radio button has been selected it will return true 59 // (If not it will return false) 60 if (radio_form.radio_button[counter].checked) 61 radio_choice = true; 62 } 63 64 if (!radio_choice) 65 { 66 // If there were no selections made display an alert box 67 alert("Please select a letter.") 68 return false; 69 } 70 71 var answer = confirm("Are you sure?") 72 73 if (answer) 74 return true 75 else 76 return false 77 78 return true; 79 } 80 </script> -
trunk/app/views/vclassrooms/show.ctp
r415 r419 27 27 foreach($data['Test'] as $t) 28 28 { 29 echo $html->para(null, $html->link($t['title'], '/ vclassrooms/test/'.$t['id']));29 echo $html->para(null, $html->link($t['title'], '/tests/view/'.$t['id'].'/'.$t['user_id'])); 30 30 } 31 31 } -
trunk/app/views/webquests/admin_edit.ctp
r418 r419 12 12 <?php 13 13 echo $form->create('Webquest'); 14 echo $form->input('Webquest.title', array('size'=>60,'maxlength'=>160,'value'=>$wq_title ));15 echo $form->hidden('Webquest.id' , array('value'=>$id));14 echo $form->input('Webquest.title', array('size'=>60,'maxlength'=>160,'value'=>$wq_title,'style'=>'font-size:7pt')); 15 echo $form->hidden('Webquest.id'); 16 16 echo $form->end('Save'); 17 17 ?> … … 32 32 33 33 <div style="width:800px;text-align:center;height:20px;font-size:14pt" id="menu"> 34 <div class="tab"> 35 <?php echo $ajax->link('Introduction', '/admin/webquests/get/introduction/'.$id, array("update" => "setform", 36 "loading"=>"Element.show('loading');", "complete"=>"Element.hide('loading');Effect.Appear('setform')")); 37 ?> 38 </div> 39 <div class="tab"> 40 <?php echo $ajax->link('Tasks', '/admin/webquests/get/tasks/'.$id, array("update" => "setform", 41 "loading"=>"Element.show('loading');", "complete"=>"Element.hide('loading');Effect.Appear('setform')")); 42 ?> 43 </div> 44 <div class="tab"> 45 <?php echo $ajax->link('Process', '/admin/webquests/get/process/'.$id, array("update" => "setform", 46 "loading"=>"Element.show('loading');", "complete"=>"Element.hide('loading');Effect.Appear('setform')")); 47 ?> 48 </div> 49 <div class="tab"> 50 <?php echo $ajax->link('Roles', '/admin/webquests/get/roles/'.$id, array("update" => "setform", 51 "loading"=>"Element.show('loading');", "complete"=>"Element.hide('loading');Effect.Appear('setform')")); 52 ?> 53 </div> 54 <div class="tab"> 55 <?php echo $ajax->link('Evaluation', '/admin/webquests/get/evaluation/'.$id, array("update" => "setform", 56 "loading"=>"Element.show('loading');", "complete"=>"Element.hide('loading');Effect.Appear('setform')")); 57 ?> 58 </div> 59 <div class="tab"> 60 <?php echo $ajax->link('Conclusion', '/admin/webquests/get/conclusion/'.$id, array("update" => "setform", 61 "loading"=>"Element.show('loading');", "complete"=>"Element.hide('loading');Effect.Appear('setform')")); 62 ?> 63 </div> 34 <?php 35 echo $html->div('tab', $ajax->link('Introduction', '/admin/webquests/get/introduction/'.$id, array("update" => "setform", 36 "loading"=>"Element.show('loading');", "complete"=>"Element.hide('loading');Effect.Appear('setform')"))); 37 38 echo $html->div('tab', $ajax->link('Tasks', '/admin/webquests/get/tasks/'.$id, array("update" => "setform", 39 "loading"=>"Element.show('loading');", "complete"=>"Element.hide('loading');Effect.Appear('setform')"))); 40 41 echo $html->div('tab', $ajax->link('Process', '/admin/webquests/get/process/'.$id, array("update" => "setform", 42 "loading"=>"Element.show('loading');", "complete"=>"Element.hide('loading');Effect.Appear('setform')"))); 43 44 echo $html->div('tab', $ajax->link('Roles', '/admin/webquests/get/roles/'.$id, array("update" => "setform", 45 "loading"=>"Element.show('loading');", "complete"=>"Element.hide('loading');Effect.Appear('setform')"))); 46 47 echo $html->div('tab', $ajax->link('Evaluation', '/admin/webquests/get/evaluation/'.$id, array("update" => "setform", 48 "loading"=>"Element.show('loading');", "complete"=>"Element.hide('loading');Effect.Appear('setform')"))); 49 50 echo $html->div('tab', $ajax->link('Conclusion', '/admin/webquests/get/conclusion/'.$id, array("update" => "setform", 51 "loading"=>"Element.show('loading');", "complete"=>"Element.hide('loading');Effect.Appear('setform')"))); 52 53 echo $html->div('tab', $ajax->link('Points', '/admin/webquests/get/points/'.$id, array("update" => "setform", 54 "loading"=>"Element.show('loading');", "complete"=>"Element.hide('loading');Effect.Appear('setform')"))); 55 ?> 64 56 </div> 65 57 … … 80 72 else 81 73 Div.style.display = 'none'; 82 83 74 } 84 75 --> -
trunk/app/views/webquests/view.ctp
r270 r419 1 <?php 2 //die(debug($data)); 3 $auth = false; 4 5 if ( $session->check('vclassrooms') ): 6 foreach($data['Vclassroom'] as $v): 7 $auth = ( in_array($v['id'], $session->read('vclassrooms'))) ? true : false; // students belongs this vclass ? 8 endforeach; 9 endif; 10 11 if ( $auth === true ): 12 echo $html->para(null, 'hi! '.$cU['User']['username'], array('style'=>'font-weight:bold;font-size:12pt;')); 13 ?> 1 14 <h1><?php echo $data['Webquest']['title']; ?></h1> 2 15 … … 23 36 echo '<p>Created: <b>'. $data['Webquest']['created'].'</b></p>'; 24 37 echo '</div>'; 25 ?> 38 39 else: 40 echo $html->link('Login to join this group', '/users/login'); 41 endif;
