Changeset 361
- Timestamp:
- 04/02/08 13:19:24 (9 months ago)
- Location:
- trunk/app
- Files:
-
- 4 added
- 11 modified
-
controllers/answers_controller.php (modified) (3 diffs)
-
controllers/newsletters_controller.php (modified) (1 diff)
-
controllers/podcasts_controller.php (modified) (5 diffs)
-
controllers/questions_controller.php (modified) (2 diffs)
-
controllers/tests_controller.php (modified) (7 diffs)
-
locale/eng/LC_MESSAGES/default.po (added)
-
locale/spa (added)
-
locale/spa/default.po (added)
-
views/podcasts/admin_add.ctp (modified) (1 diff)
-
views/questions/admin_answers.ctp (modified) (4 diffs)
-
views/questions/admin_edit.ctp (modified) (1 diff)
-
views/tests/admin_edit.ctp (modified) (1 diff)
-
views/tests/admin_listing.ctp (modified) (1 diff)
-
views/tests/admin_questions.ctp (modified) (2 diffs)
-
webroot/img/admin/questions_icon.gif (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/controllers/answers_controller.php
r339 r361 3 3 * Karamelo E-Learning Platform 4 4 * Chipotle Software 2002-2008 5 * GPL manuel<at>mononeurona<punto>org5 * GPLv3 manuel<arroba>mononeurona<punto>org 6 6 */ 7 7 //File: /app/controllers/quotes_controller.php … … 45 45 46 46 if ( $this->Answer->save($this->data['Answer']) ) 47 {47 { 48 48 $conditions = array("Answer.question_id" => $this->data['Answer']['question_id']); 49 49 $fields = array("Answer.id", "Answer.answer", "Answer.correct"); … … 112 112 $this->set('data', $this->Answer->findAll($conditions, $fields, $order)); 113 113 } 114 115 public function admin_change($answer_id, $correct, $question_id) 116 { 117 $this->data['Answer']['correct'] = ($correct == 0 ) ? 1 : 0; 118 119 $this->data['Answer']['id'] = $answer_id; 120 121 if ($this->Answer->save($this->data['Answer'])) 122 { 123 $this->msgFlash('Answer updated', '/admin/question/listing/'.$question_id); 124 } 125 } 114 126 115 116 public function admin_delete($id, $question_id) 127 public function admin_delete($answer_id, $question_id) 117 128 { 118 129 // deletes from database 119 130 120 if ( $this->Answer->del($ id) )131 if ( $this->Answer->del($answer_id) ) 121 132 { 122 133 $this->msgFlash('Answer deleted', '/admin/questions/answers/'.$question_id); -
trunk/app/controllers/newsletters_controller.php
r346 r361 1 1 <?php 2 /** 2 /** 3 3 * Karamelo E-Learning Platform 4 4 * Manuel Montoya 2002-2008 -
trunk/app/controllers/podcasts_controller.php
r360 r361 29 29 { 30 30 return true; 31 }31 } 32 32 } 33 return false; // go away !!33 return false; // go away !! 34 34 } 35 35 … … 44 44 $conditions = array("Podcast.status"=>1); 45 45 46 $fields = array('Podcast.id','Podcast.title', 'Podcast.description','Podcast.created','Podcast.filename','Podcast.length','Podcast.duration', 'User.username');46 $fields = array('Podcast.id','Podcast.title', 'Podcast.description','Podcast.created','Podcast.filename', 'Podcast.length','Podcast.duration', 'User.username'); 47 47 48 48 $order = 'Podcast.id DESC'; … … 64 64 $this->Podcast->User->unbindModel(array('hasMany'=>array('Entry', 'Lesson', 'Category', 'Vclassroom', 'Faq', 'Acquaintance'))); 65 65 66 $User = $this->Podcast->User->find(array("User.username"=>$username));67 //die(debug($User));68 $this->set('User', $User);69 70 // die(debug($User));71 72 66 $conditions = array("status"=>1, "user_id"=>$User['User']['id']); 73 67 … … 83 77 public function show($user_id, $id) 84 78 { 85 $this->layout = $this->Edublog->layout($user_id);86 87 $this->set('blog', $this->Edublog->blog($user_id));88 89 $this->pageTitle = 'Podcast';90 91 $conditions = array("Podcast.id"=>$id, "Podcast.status"=>1);92 93 $fields = array("id", "title", "description", "created", "filename", "length", "size", "duration");94 95 $this->set('data', $this->Podcast->findAll($conditions, $fields));96 }79 $this->layout = $this->Edublog->layout($user_id); 80 81 $this->set('blog', $this->Edublog->blog($user_id)); 82 83 $this->pageTitle = 'Podcast'; 84 85 $conditions = array("Podcast.id"=>$id, "Podcast.status"=>1); 86 87 $fields = array("id", "title", "description", "created", "filename", "length", "size", "duration"); 88 89 $this->set('data', $this->Podcast->findAll($conditions, $fields)); 90 } 97 91 98 92 /****** ====ADMIN METHODS==== ***/ … … 100 94 public function admin_listing() 101 95 { 102 $this->pageTitle = $this->Auth->user('username') . '\'s Podcasts';103 104 $this->layout = 'admin';105 106 $conditions = array("Podcast.user_id"=>$this->Auth->user('id'));107 $fields = array('id', 'title', 'description', 'created', 'length', 'status', 'filename');108 $order = "Podcast.id DESC";109 $limit = 12;110 111 $this->set('data', $this->Podcast->findAll($conditions, $fields, $order, $limit, null, 1));96 $this->pageTitle = $this->Auth->user('username') . '\'s Podcasts'; 97 98 $this->layout = 'admin'; 99 100 $conditions = array("Podcast.user_id"=>$this->Auth->user('id')); 101 $fields = array('id', 'title', 'description', 'created', 'length', 'status', 'filename'); 102 $order = "Podcast.id DESC"; 103 $limit = 12; 104 105 $this->set('data', $this->Podcast->findAll($conditions, $fields, $order, $limit, null, 1)); 112 106 } 113 107 -
trunk/app/controllers/questions_controller.php
r328 r361 15 15 public function isAuthorized() 16 16 { 17 if (isset($this->params[Configure::read('Routing.admin')]))18 {19 if ($this->Auth->user('group_id') != 1)20 {21 return false;22 }23 }24 return true;17 if (isset($this->params[Configure::read('Routing.admin')])) 18 { 19 if ($this->Auth->user('group_id') != 1) 20 { 21 return false; 22 } 23 } 24 return true; 25 25 } 26 26 27 /*** 28 === ADMIN METHODS 29 ***/ 30 public function admin_add() 31 { 32 // adds new vote to database 33 if (!empty($this->data["Question"])) 34 { 35 //die(print_r($this->data)); 27 /*** === ADMIN METHODS === ***/ 28 public function admin_add() 29 { 30 // adds new vote to database 31 if (!empty($this->data["Question"])) 32 { 33 //die(print_r($this->data)); 36 34 37 $this->Sanitize = new Sanitize;35 $this->Sanitize = new Sanitize; 38 36 39 $this->Sanitize->clean($this->data['Question']);37 $this->Sanitize->clean($this->data['Question']); 40 38 41 $this->data["Question"]['user_id'] = $this->Auth->user('id');39 $this->data["Question"]['user_id'] = $this->Auth->user('id'); 42 40 43 $this->Question->create();41 $this->Question->create(); 44 42 45 if ( $this->Question->save( $this->data['Question'] ) )46 {47 $conditions = array("Question.test_id" => $this->data['Question']['test_id']);48 $fields = array("Question.id", "Question.question", "Question.hint", "Question.worth", "Question.explanation");49 $order = "Question.id";43 if ( $this->Question->save( $this->data['Question'] ) ) 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"); 47 $order = "Question.id"; 50 48 51 $this->set('data', $this->Question->findAll($conditions, $fields, $order));49 $this->set('data', $this->Question->findAll($conditions, $fields, $order)); 52 50 53 $this->render('questions', 'ajax');51 $this->render('questions', 'ajax'); 54 52 } 55 53 else 56 54 { 57 echo "Ajax error, check with the company's computer guy...";55 echo "Ajax error, check with the company's computer guy..."; 58 56 } 59 }60 57 } 58 } 61 59 62 public function admin_edit($question_id=null)63 {64 $this->layout = 'admin';60 public function admin_edit($question_id=null) 61 { 62 $this->layout = 'admin'; 65 63 // adds new vote to database 66 if (!empty($this->data["Question"])) 67 { 68 64 if ( !empty($this->data["Question"]) ) 65 { 69 66 $this->Sanitize = new Sanitize; 70 67 … … 72 69 73 70 if ( $this->Question->save( $this->data['Question'] ) ) 74 {71 { 75 72 $this->msgFlash('Question saved', '/admin/tests/questions/'.$this->data["Question"]["test_id"]); 76 }77 else78 {73 } 74 else 75 { 79 76 echo "Ajax error, check with the company's computer guy..."; 80 } 81 } 82 else 83 { 84 $this->Question->id = $question_id; 85 86 $this->data = $this->Question->read(); 87 } 77 } 78 } 79 else 80 { 81 $this->data = $this->Question->read(null, $question_id); 82 } 88 83 } 89 84 -
trunk/app/controllers/tests_controller.php
r358 r361 8 8 9 9 uses('Sanitize'); 10 uses('L10n'); 10 11 11 12 class TestsController extends AppController … … 15 16 public $components = array('Edublog'); 16 17 18 public $paginate = array( 19 'limit' => 25, 20 'order' => array( 21 'Test.title' => 'asc' 22 ) 23 ); 24 17 25 public function beforeFilter() 18 26 { 19 27 $this->Auth->allow(array('view', 'display')); 20 28 parent::beforeFilter(); 29 30 // L10n 31 $this->L10n = new L10n(); 32 $this->L10n->get("en"); 33 34 Configure::write('Config.language', "en"); 21 35 } 22 36 … … 151 165 } 152 166 153 /** 154 === ADMIN METHODS ==== 155 **/ 167 /** === ADMIN METHODS ==== **/ 156 168 /** Select classroom to link*/ 157 169 public function admin_vclassrooms() … … 168 180 $this->set('data', $this->Test->findAll($conditions)); 169 181 } 170 171 172 public function admin_listing() 173 { 174 $this->layout = 'admin'; 175 176 $this->pageTitle = 'Tests'; 177 178 $conditions = array("Test.user_id"=>$this->Auth->user('id')); 179 180 $fields = array("Test.id", "Test.user_id", "Test.title", "Test.description", "Test.status"); 181 182 $order = "Test.id DESC"; 183 184 $this->set('data', $this->Test->findAll($conditions, $fields, $order)); 185 } 186 187 public function admin_questions($test_id) 188 { 189 $this->layout = 'admin'; 190 191 $this->pageTitle = 'Tests'; 192 193 $conditions = array("Test.user_id"=>$this->Auth->user('id'), "Test.id"=>$test_id); 194 195 $fields = array("Test.id", "Test.user_id", "Test.title", "Test.description"); 196 197 $this->Test->unbindModel(array("belongsTo"=>array("User"))); 198 199 $this->set('data', $this->Test->find($conditions, $fields, null, 2)); 200 } 201 202 public function admin_add() 203 { 182 183 public function admin_listing() 184 { 185 $this->layout = 'admin'; 186 187 $this->pageTitle = 'Tests'; 188 189 $conditions = array("Test.user_id"=>$this->Auth->user('id')); 190 191 $fields = array("Test.id", "Test.user_id", "Test.title", "Test.description", "Test.status"); 192 193 $order = "Test.id DESC"; 194 195 $this->set('data', $this->Test->findAll($conditions, $fields, $order)); 196 } 197 public function admin_add() 198 { 204 199 $this->layout = 'admin'; 205 200 // add to database … … 223 218 } 224 219 } 225 } 226 public function admin_edit($test_id=null) 227 { 220 } 221 222 public function admin_edit($test_id=null) 223 { 228 224 $this->layout = 'admin'; 229 225 … … 242 238 else 243 239 { 244 $this->Test->id = $test_id; 245 246 $this->data = $this->Test->read(); 240 $this->data = $this->Test->read(null, $test_id); 247 241 } 248 242 } … … 260 254 } 261 255 } 256 257 public function admin_questions($test_id) 258 { 259 $this->layout = 'admin'; 260 261 $this->pageTitle = 'Tests'; 262 263 $conditions = array("Test.user_id"=>$this->Auth->user('id'), "Test.id"=>$test_id); 264 265 $fields = array("Test.id", "Test.user_id", "Test.title", "Test.description"); 266 267 $this->Test->unbindModel(array("belongsTo"=>array("User"))); 268 269 $this->set('data', $this->Test->find($conditions, $fields, null, 2)); 270 } 262 271 263 272 public function admin_delete($id) -
trunk/app/views/podcasts/admin_add.ctp
r359 r361 31 31 echo $form->select('Podcast.subject_id', $subjects, null, null, null, false); 32 32 33 34 33 echo $form->input('Podcast.title', array("size" => 25, "maxlength" => 50)); 35 34 -
trunk/app/views/questions/admin_answers.ctp
r269 r361 1 1 <?php 2 // die(print_r($data)); 3 if ( isset($javascript) ): 4 echo $html->charsetTag('UTF-8'); 5 echo $javascript->link('prototype'); 6 echo $javascript->link('scriptaculous.js?load=effects'); 7 endif; 8 9 echo $html->addCrumb('Control Tools', '/admin/entries/start'); 10 echo $html->addCrumb('Tests', '/admin/tests/listing'); 11 echo $html->getCrumbs(' / '); 2 echo $html->addCrumb('Control Tools', '/admin/entries/start'); 3 echo $html->addCrumb('Tests', '/admin/tests/listing'); 4 echo $html->getCrumbs(' / '); 5 6 echo $html->div('title_section', 'Answers to ' . $data['Question']['question']); 12 7 ?> 13 14 <div class="title_section">Answers to <?php echo $data['Question']['question']; ?></div>15 8 16 9 <div id="loading" style="display: none;"> … … 25 18 26 19 <?php 27 echo $ajax->form( null,'post');28 echo $ html->hiddenTag('Answer/question_id', $data['Question']['id']);20 echo $ajax->form(); 21 echo $form->hidden('Answer.question_id', array('value'=>$data['Question']['id'])); 29 22 ?> 30 <fieldset> 31 <legend>New answer</legend> 32 33 <div class="required"> 34 <?php echo $form->labelTag('Answer/answer', 'Answer:' ); ?> 35 <?php echo $html->input('Answer/answer', array("size" => 55, "maxlength" => 120)); ?> 36 <?php echo $html->tagErrorMsg('Answer/answer', 'Answer is required.'); ?> 37 </div> 38 <div class="required"> 39 <?php echo $form->labelTag('Answer/correct', 'Answer is correct:' ); ?> 40 <?php echo $html->checkbox('Answer/correct', null, array("value" => 1)); ?> 41 </div> 42 <div> 23 <fieldset><legend>New answer</legend> 43 24 <?php 44 echo $ajax->submit('Save', array("url" => "/admin/answers/add", 25 echo $html->div('required',$form->input('Answer.answer', array("size" => 55, "maxlength" => 120))); 26 echo $html->div('required',$form->label('Answer.correct','Answer is correct:').$form->checkbox('Answer.correct', array("value" => 1))); 27 echo $ajax->submit('Save', array("url" => "/admin/answers/add", 45 28 "update"=>"questions", 46 29 "loading" => "Element.hide('questions');Element.hide('addquestion');Element.show('loading')", … … 48 31 )); 49 32 ?> 50 </div>51 33 </fieldset> 52 53 34 </div> 54 35 … … 58 39 { 59 40 $st = ($val["correct"]==1) ? 'Yes' : 'No'; 60 echo '<div style="padding:5px;border:1px dotted gray;margin:4px;">';61 echo '<div class="butonright">' . $html->link('Delete', '/admin/answers/delete/'.$val['id'].'/'.$val['question_id']) . '</div>';62 echo '<div class="butonright">' . $html->link('Edit', '/admin/answers/edit/' .$val['id']) . '</div>';63 echo "Answer: " . $val["answer"]. "<br />";64 echo "Correct: " . $st . "<br />"; 65 echo '</div>';41 $tmp = $html->div(null, $html->link('Delete', '/admin/answers/delete/'.$val['id'].'/'.$val['question_id'])); 42 $tmp .= $html->div(null, $html->link('Edit', '/admin/answers/edit/' .$val['id'])); 43 $tmp .= "Answer: " . $val["answer"] . "<br />"; 44 $tmp .= "Correct: " . $html->link($st, '/admin/answers/changed/'.$val['id'].'/'.$val['question_id']) . "<br />"; 45 46 echo $html->div('adminblock', $tmp); 66 47 } 67 48 ?> -
trunk/app/views/questions/admin_edit.ctp
r269 r361 1 <?php echo $html->addCrumb('Control Tools', '/admin/entries/start'); ?>2 <?php echo $html->addCrumb('Test', '/admin/tests/listing'); ?>3 <?php echo $html->getCrumbs(' / '); ?>4 5 1 <?php 6 echo $html->formTag('/admin/questions/edit','post', array("onsubmit"=>"return validateNew()")); 7 echo $html->hidden('Question/test_id'); 2 echo $html->addCrumb('Control Tools', '/admin/entries/start'); 3 echo $html->addCrumb('Test', '/admin/tests/listing'); 4 echo $html->getCrumbs(' / '); 5 6 echo $form->create('Question', array("onsubmit"=>"return validateNew()")); 7 echo $form->hidden('Question.id'); 8 echo $form->hidden('Question.test_id', array('value'=>$this->data['Question']['test_id'])); 8 9 ?> 9 10 <fieldset> 10 11 <legend>Edit question</legend> 11 < div class="required">12 <?php13 echo $form->labelTag('Question/question', 'Question:' );14 echo $html->input('Question/question', array("size" => 40, "maxlength" => 120));15 echo $html->tagErrorMsg('Question/question', 'Question is required.');16 ?>17 </div> 12 <?php 13 echo $html->div('required',$form->input('Question.question', array("size" => 40, "maxlength" => 120))); 14 15 echo $html->div('required',$form->input('Question.hint', array("size" => 40, "maxlength" => 120))); 16 17 $tmp = $form->label('Question.explanation', 'Explanation:'); 18 $tmp .= $form->textarea('Question.explanation', array("cols" => 50, "rows" => 5)); 18 19 19 <div class="required"> 20 <?php 21 echo $form->labelTag('Question/hint', 'Hint:' ); 22 echo $html->input('Question/hint', array("size" => 40, "maxlength" => 120)); 23 echo $html->tagErrorMsg('Question/hint', 'Hint is required.'); 24 ?> 25 </div> 20 echo $html->div('required',$tmp); 21 22 $t = $form->label('Question.worth', 'Worth:'); 23 $t .= $form->select('Question.worth', array(1,2,3,4,5,6,7,8,9,10), null, null, false, false); 24 echo $html->div('required',$t); 25 ?> 26 </fieldset> 27 <?php echo $form->end('Save'); ?> 26 28 27 <div class="required">28 <?php29 echo $form->labelTag('Question/explanation', 'Explanation:' );30 echo $html->textarea('Question/explanation', array("cols" => 50, "rows" => 5));31 echo $html->tagErrorMsg('Question/explanation', 'Description is required.');32 ?>33 </div>34 35 <div class="required">36 <?php37 echo $form->labelTag( 'Question/status', 'Published:' );38 $options = array(1,2,3,4,5,6,7,8,9,10);39 echo $html->selectTag('Question/value', $options, null, null, false, false);40 ?>41 </div>42 43 <div>44 <?php echo $html->submit('Save'); ?> </form>45 </div>46 </fieldset> -
trunk/app/views/tests/admin_edit.ctp
r264 r361 1 <?php echo $html->addCrumb('Control Tools', '/admin/entries/start'); ?>2 <?php echo $html->addCrumb('Test', '/admin/tests/listing'); ?>3 <?php echo $html->getCrumbs(' / '); ?>4 5 1 <?php 6 echo $html->formTag('/admin/tests/edit','post', array("onsubmit"=>"return validateNew()")); 7 echo $html->hidden('Test/id'); 2 echo $html->addCrumb('Control Tools', '/admin/entries/start'); 3 echo $html->addCrumb('Test', '/admin/tests/listing'); 4 echo $html->getCrumbs(' / '); 5 6 echo $form->create('Test', array("onsubmit"=>"return validateNew()")); 7 echo $form->hidden('Test.id'); 8 8 ?> 9 9 <fieldset> 10 10 <legend>Edit test</legend> 11 <div class="required"> 12 <?php 13 echo $form->labelTag('Test/title', 'Title:' ); 14 echo $html->input('Test/title', array("size" => 40, "maxlength" => 120)); 15 echo $html->tagErrorMsg('Test/title', 'Test is required.'); 16 ?> 17 </div> 11 <?php 12 echo $html->div('required', $form->input('Test.title', array("size" => 40, "maxlength" => 120))); 13 14 echo $html->div('required', $form->label('Test.description', 'Description:') . $form->textarea('Test.description', array("cols" => 50, "rows" => 5))); 15 16 echo $html->div('required', $form->label('Test.status', 'Published:' ) . $form->checkbox('Test.status', array('value'=>1))); 17 18 echo $form->end('Save'); 19 ?> 20 </fieldset> 18 21 19 <div class="required">20 <?php21 echo $form->labelTag('Test/explanation', 'Explanation:' );22 echo $html->textarea('Test/explanation', array("cols" => 50, "rows" => 5));23 echo $html->tagErrorMsg('Test/explanation', 'Description is required.');24 ?>25 </div>26 <div>27 <?php28 echo $form->labelTag('Test/status', 'Published:' );29 echo $html->checkbox('Test/status', null);30 ?>31 </div>32 <div>33 <?php echo $html->submit('Save'); ?> </form>34 </div>
