Changeset 422
- Timestamp:
- 04/23/08 19:07:23 (9 months ago)
- Location:
- trunk/app
- Files:
-
- 11 modified
-
controllers/components/edublog.php (modified) (1 diff)
-
controllers/messages_controller.php (modified) (8 diffs)
-
controllers/results_controller.php (modified) (2 diffs)
-
controllers/tests_controller.php (modified) (6 diffs)
-
models/test.php (modified) (1 diff)
-
views/questions/admin_answers.ctp (modified) (1 diff)
-
views/tests/admin_questions.ctp (modified) (1 diff)
-
views/tests/view.ctp (modified) (3 diffs)
-
views/vclassrooms/admin_listing.ctp (modified) (1 diff)
-
views/vclassrooms/admin_members.ctp (modified) (1 diff)
-
views/webquests/view.ctp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/controllers/components/edublog.php
r416 r422 118 118 119 119 $vclassrooms = $this->Vclassroom->chkVclassrooms($user_id); // check model, what classrooms this student belongs? 120 120 121 121 if ($vclassrooms != null) 122 122 { -
trunk/app/controllers/messages_controller.php
r342 r422 85 85 86 86 if ($this->Message->save($this->data["Message"])) 87 {88 $this->sendMail($this->data["Message"]["user_id"], $this->data["Message"]["username"], $this->data["Message"]["title"]);87 { 88 $this->__sendMail($this->data["Message"]["user_id"], $this->data["Message"]["username"], $this->data["Message"]["title"]); 89 89 90 90 if ( isset($this->data["Message"]["admin"])) … … 95 95 { 96 96 $this->render('sent', 'ajax'); 97 }97 } 98 98 } 99 99 } 100 100 } 101 private function sendMail($user_id, $username, $title) 102 { 103 $this->User = new User; 104 105 $fields = array('email', 'username'); 106 107 $data = $this->User->find(array("User.id"=>$user_id), $fields); 108 //exit($data["User"]["email"]); 109 $this->Email->sender = '::MonoNeurona.org::'; 110 $this->Email->to = $data["User"]["email"]; 111 $this->Email->subject = '::MonoNeurona.org:: New message from '. $username; 112 $this->Email->sendAs = 'html'; 113 $this->Email->template = null; 114 $this->Email->from = 'noreply@mononeurona.org'; 115 //$this->set('foo', 'Cake tastes good today'); 116 //Set the body of the mail as we send it. 117 //Note: the text can be an array, each element will appear as a 118 //seperate line in the message body. 119 $url = '<img src="http://www.mononeurona.org/img/admin/new_user.jpg" alt="MonoNeurona" title="MonoNeurona" /><br />'; 120 $url .= '<h2>'.$data["User"]["username"].'</h2><p>You have a new message from '. $username; 121 $url .= '<a href="http://'.$_SERVER['SERVER_NAME'].'/admin/messages/listing/">'.$title.'</a></p>'; 122 123 //die($url); 124 125 if ( $this->Email->send($url) ) 126 { 127 return true; 128 } 129 else 130 { 131 132 exit("Error!!"); 133 } 101 102 /* == PRIVATE == **/ 103 private function __sendMail($email) 104 { 105 $this->layout = 'default'; 106 $this->Email->to = $email; 107 108 // this could be just a string too 109 $this->Email->subject = 'Karamelo e-Learning:: New message'; 110 $this->Email->replyTo = 'support@karamelo.org'; 111 $this->Email->from = 'Chipotle-software.com'; 112 $this->Email->template = 'message'; 113 $this->Email->sendAs = 'text'; // because we like to send pretty mail 114 //Do not pass any args to send() 115 if ( $this->Email->send() ) 116 { 117 return true; 118 } 119 else 120 { 121 return false; 122 } 134 123 } 135 124 … … 178 167 179 168 if ($this->Message->save($this->data["Message"])) 180 {169 { 181 170 $j++; 182 }171 } 183 172 else 184 173 { … … 187 176 } 188 177 $this->msgFlash($j . ' messages sent', '/admin/messages/listing'); 189 }178 } 190 179 } 191 180 … … 225 214 public function admin_add() 226 215 { 227 $this->layout = 'admin';228 229 if (!empty($this->data["Message"]))230 {231 $this->Sanitize = new Sanitize;232 233 $this->Sanitize->html($this->data["Message"]["title"]);234 235 $this->Sanitize->html($this->data["Message"]["body"]);236 237 if ( isset( $this->data["Message"]["message_id"] ) )238 {216 $this->layout = 'admin'; 217 218 if (!empty($this->data["Message"])) 219 { 220 $this->Sanitize = new Sanitize; 221 222 $this->Sanitize->html($this->data["Message"]["title"]); 223 224 $this->Sanitize->html($this->data["Message"]["body"]); 225 226 if ( isset( $this->data["Message"]["message_id"] ) ) 227 { 239 228 $this->change($this->data["Message"]["message_id"], 2); 240 }241 242 $this->Message->create();243 244 if ($this->Message->save($this->data["Message"]))245 {229 } 230 231 $this->Message->create(); 232 233 if ($this->Message->save($this->data["Message"])) 234 { 246 235 $this->sendMail($this->data["Message"]["user_id"], $this->data["Message"]["username"], $this->data["Message"]["title"]); 247 236 $this->render('send','ajax'); 248 } 249 } 237 } 250 238 } 239 } 251 240 252 public function admin_display($message_id)253 {241 public function admin_display($message_id) 242 { 254 243 $this->pageTitle = 'Message'; 255 244 … … 291 280 } 292 281 } 293 } 294 295 public function admin_delete($id=null) 296 { 297 if ( isset($this->data["Message"]["several"]) ) 298 { 282 } 283 284 public function admin_write($user_id) 285 { 286 $this->layout = 'admin'; 287 288 $this->pageTitle = 'Write Message'; 289 290 $this->set('user_id', $user_id); 291 } 292 293 public function admin_deliver() 294 { 295 if (!empty($this->data['Message'])) 296 { 297 $this->Sanitize = new Sanitize; 298 299 $this->Sanitize->html($this->data['Message']['title']); 300 301 $this->Sanitize->html($this->data['Message']['body']); 302 303 $this->data['Message']['sender'] = $this->Auth->user('id'); 304 //die(debug($this->data)); 305 $this->Message->create(); 306 307 if ($this->Message->save($this->data['Message'])) 308 { 309 $email = $this->Message->User->field('email', array('id'=>$this->data['Message']['user_id'])); 310 if ( $this->__sendMail($email) ) 311 { 312 $this->msgFlash('Message sent','/admin/messages/listing'); 313 } 314 } 315 } 316 } 317 318 public function admin_delete($id=null) 319 { 320 if ( isset($this->data["Message"]["several"]) ) 321 { 299 322 //exit(print_r($this->data["Message"]["id"])); 300 323 foreach ($this->data["Message"]["id"] as $v) … … 307 330 308 331 $this->msgFlash('The message has been deleted.','/admin/messages/listing'); 309 }310 else311 {332 } 333 else 334 { 312 335 if ( isset( $this->data["Message"]["id"] ) ) 313 336 { … … 315 338 } 316 339 317 $this->Message->del($id);318 }319 $this->msgFlash('Message has been deleted.','/admin/messages/listing');340 $this->Message->del($id); 341 } 342 $this->msgFlash('Message has been deleted.','/admin/messages/listing'); 320 343 } 321 344 } -
trunk/app/controllers/results_controller.php
r421 r422 12 12 uses('sanitize'); 13 13 14 class EntriesController extends AppController {14 class ResultsController extends AppController { 15 15 16 16 public $helpers = array('Ajax', 'Fck', 'Gags'); … … 37 37 38 38 public function result() 39 { 40 $this->layout = 'rss'; 39 { 40 die(debug($this->data)); 41 42 $this->pageTitle = 'Results'; 43 44 $this->layout = $this->Edublog->layout($user_id); 45 46 $this->Edublog->blog($user_id); // set edublog components 47 48 49 $answers = $this->Resukts->Question->findAll($conditions, $fields, $order); 41 50 42 51 $conditions = array("Result.status"=>1, "Result.user_id"=>$user_id); -
trunk/app/controllers/tests_controller.php
r419 r422 66 66 public function view($test_id, $user_id) 67 67 { 68 // the student alredy answer ?68 // the student alredy answered this test? 69 69 $already = $this->Test->Result->field('Result.id', array("Result.user_id"=>$this->Auth->user('id'), "Result.test_id"=>$test_id)); 70 70 … … 78 78 if ( $this->Auth->user() && $this->Auth->user('group_id') == 3) 79 79 { 80 $ user_id = (int) $this->Auth->user('id');81 $this->Edublog->setSession($ user_id);80 $student_id = (int) $this->Auth->user('id'); 81 $this->Edublog->setSession($student_id); //check if user belongs to class 82 82 } 83 83 … … 90 90 $conditions = array("Test.id"=>$test_id, "Test.status"=>1); 91 91 92 $this->set('data', $this->Test->find($conditions, null, null, 2)); 92 $fields = null; // array('Test.id', 'Test.title', 'Question.id'); 93 94 $order = null; 95 96 $this->set('data', $this->Test->find($conditions, $fields, $order, 2)); 93 97 } 94 98 … … 109 113 $this->Sanitize->clean($this->data['Result']); 110 114 111 $this->data['Result']['results'] = $this-> getResults($this->data['Result']);115 $this->data['Result']['results'] = $this->Test->($this->data['Result']); 112 116 113 117 $this->data['Result']['test_id'] = $this->data['Question']['test_id']; … … 126 130 { 127 131 echo "Caught my exception\n" . $e; 128 } 129 130 } 131 132 private function chk($user_id) 132 } 133 } 134 135 private function chk($user_id) // preview tests before send 133 136 { 134 137 try { … … 152 155 } 153 156 154 private function get_results($questions)155 {156 $this->Test->unbindModel(array('belongsTo'=>array('User'))); //just few data157 158 $result = 0;159 160 foreach($questions as $q_id => $a_id) // question id and answer id161 {162 $correct_answer = $this->Test->Question->Answer->field('Answer.correct', array('Answer.id'=>$a_id)); // answer was correct?163 164 if ($correct_answer == 1)165 {166 $worth = $this->Test->Question->field('Question.worth', array('Question.id'=>$q_id)); // how many points167 $result += $worth;168 }169 }170 //exit('Result was:' . $result);171 return $result;172 }173 157 174 158 /** === ADMIN METHODS ==== **/ -
trunk/app/models/test.php
r373 r422 74 74 75 75 return $vclassrooms; 76 } 77 78 private function chkAnswers($answers) 79 { 80 $this->Test->unbindModel(array('belongsTo'=>array('User'))); //just few data 81 82 $result = 0; 83 84 foreach($questions as $q_id => $a_id) // question id and answer id 85 { 86 $correct_answer = $this->Test->Question->Answer->field('Answer.correct', array('Answer.id'=>$a_id)); // answer was correct? 87 88 if ($correct_answer == 1) 89 { 90 $worth = $this->Test->Question->field('Question.worth', array('Question.id'=>$q_id)); // how many points 91 $result += $worth; 92 } 93 } 94 //exit('Result was:' . $result); 95 return $result; 76 96 } 77 97 } -
trunk/app/views/questions/admin_answers.ctp
r363 r422 1 1 <?php 2 //die(debug($data)); 2 3 echo $html->addCrumb('Control Tools', '/admin/entries/start'); 3 4 echo $html->addCrumb('Tests', '/admin/tests/listing'); 5 echo $html->addCrumb($data['Test']['title'], '/admin/tests/questions/'.$data['Test']['id']); 4 6 echo $html->getCrumbs(' / '); 5 7 -
trunk/app/views/tests/admin_questions.ctp
r421 r422 10 10 </div> 11 11 <?php 12 echo $html->para(null, $html->link('Edit', '/admin/tests/edit/'.$data['Test']['id'])) . ' '; 13 echo $data['Test']['title'] . " " . $data['Test']['description']; 12 echo $html->para(null, $html->link('Edit', '/admin/tests/edit/'.$data['Test']['id']).' '.$html->link('Assign to class', '/admin/tests/vclassrooms/'.$data['Test']['id'])); 13 14 echo '<b>Description:</b> '. $data['Test']['title'] . " " . $data['Test']['description']; 14 15 echo " ". count($data["Question"]) . " questions"; 15 16 -
trunk/app/views/tests/view.ctp
r420 r422 1 1 <?php 2 // die(debug($data));2 // die(debug($data)); 3 3 4 4 $auth = false; 5 5 6 6 if ( $session->check('vclassrooms') ): 7 7 foreach($data['Vclassroom'] as $v): 8 $auth = ( in_array($v['id'], $session->read('vclassrooms'))) ? true : false; // students belongs this vclass ? 8 if ( in_array($v['id'], $session->read('vclassrooms'))): 9 $auth = true; 10 break; 11 endif; 9 12 endforeach; 10 13 endif; … … 24 27 //exit(var_dump($val)); 25 28 echo '<div>'; 26 echo $html->div(null, $val['question'] .' '. $val['worth'], array('style'=>'font-size:14pt;margin:5px 0 6px 0'));27 29 28 30 $options = array(); // to build options radio buttons … … 32 34 endforeach; 33 35 34 echo $form->radio('Result.'. $val['id'], $options);36 echo $form->radio('Result.'. $val['worth'] .' points, '.$val['question'], $options); 35 37 36 38 echo $html->para(null, $val['hint']); -
trunk/app/views/vclassrooms/admin_listing.ctp
r396 r422 10 10 <?php 11 11 12 $th = array ('Edit', 'Virtual classroom', ' View students', 'Status', 'Delete');12 $th = array ('Edit', 'Virtual classroom', 'Status'); 13 13 echo $html->tableHeaders($th); 14 14 foreach ($data as $val) 15 15 { 16 $st = ( $val['Vclassroom']['status'] == 1 ) ? ' Active' : 'Filed';16 $st = ( $val['Vclassroom']['status'] == 1 ) ? 'Enabled' : 'Filed'; 17 17 $tr = array ( 18 18 $gags->sendEdit($val['Vclassroom']['id'], 'vclassrooms'), 19 $html->link($val['Vclassroom']['name'], '/admin/ecourses/vclassrooms/'.$val['Vclassroom']['id']) . ' <span class="petit">'.$val['Ecourse']['title'].'</span>', 20 $html->link('View students','/admin/vclassrooms/start/'.$val['Vclassroom']['id']), 21 $html->link('File','/admin/vclassrooms/change/'.$val['Vclassroom']['id'].'/'.$val['Vclassroom']['status']), 22 $gags->confirmDel($val['Vclassroom']['id'], 'vclassrooms') 19 $html->link($val['Vclassroom']['name'], '/admin/vclassrooms/members/'.$val['Vclassroom']['id']) . ' <span class="petit">'.$val['Ecourse']['title'].'</span>', 20 $html->link($st,'/admin/vclassrooms/change/'.$val['Vclassroom']['id'].'/'.$val['Vclassroom']['status']) 21 //$gags->confirmDel($val['Vclassroom']['id'], 'vclassrooms') 23 22 ); 24 23 -
trunk/app/views/vclassrooms/admin_members.ctp
r375 r422 41 41 } 42 42 43 foreach ($data['User'] as $val) 44 { 45 // die(debug($val)); 46 $tmp = '<b>Name</b>: ' . $val['name'] . ' ' . '<b> Username</b>:' . $val['username'] . '<br />'; 47 $tmp .= 'Email: ' . $html->link($val['email'], 'mailto:'.$val['email']) . '<br />'; 48 $tmp .= $html->div('butonright', $gags->confirmDel($val['id'], 'Vclassroom')); 49 50 echo $html->div('divgray', $tmp); 51 } 52 43 echo '<table class="tbadmin">'; 44 //die(print_r($data)); 45 46 $th = array ('Name', 'Username', 'Send Message', 'Email', 'Undettach'); 47 echo $html->tableHeaders($th); 48 foreach ($data['User'] as $val): 49 $tr = array ( 50 $val['name'], 51 $val['username'], 52 $html->link($val['email'], 'mailto:'.$val['email']), 53 $html->link('Compose', '/admin/messages/write/'.$val['id']), 54 $html->link('Undetach', '/admin/vclassroom/unlink/'.$val['id'].'/'.$data['Vclassroom']['id']) 55 ); 56 57 echo $html->tableCells($tr, array("class"=>"altRow", "onmouseover"=>"this.className='highlight'", "onmouseout"=>"this.className='altRow'"), array('class'=>'evenRow',"onmouseover"=>"this.className='highlight'", "onmouseout"=>"this.className='evenRow'")); 58 endforeach; 53 59 ?> 60 </table> -
trunk/app/views/webquests/view.ctp
r419 r422 2 2 //die(debug($data)); 3 3 $auth = false; 4 4 5 5 if ( $session->check('vclassrooms') ): 6 6 foreach($data['Vclassroom'] as $v): 7 $auth = ( in_array($v['id'], $session->read('vclassrooms'))) ? true : false; // students belongs this vclass ? 7 if ( in_array($v['id'], $session->read('vclassrooms'))): 8 $auth = true; 9 break; 10 endif; 8 11 endforeach; 9 12 endif; … … 37 40 echo '</div>'; 38 41 42 echo $form->create('Result', array('onsubmit'=>'return chkForm()')); 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'); 47 39 48 else: 40 49 echo $html->link('Login to join this group', '/users/login');
