Changeset 372
- Timestamp:
- 04/07/08 15:54:44 (9 months ago)
- Location:
- trunk/app
- Files:
-
- 2 added
- 5 modified
-
controllers/ecourses_controller.php (modified) (1 diff)
-
controllers/tests_controller.php (modified) (6 diffs)
-
views/ecourses/admin_listing.ctp (modified) (1 diff)
-
views/tests/admin_listing.ctp (modified) (2 diffs)
-
views/tests/admin_vclassrooms.ctp (modified) (1 diff)
-
webroot/img/admin/link.gif (added)
-
webroot/img/admin/unlink.gif (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/controllers/ecourses_controller.php
r354 r372 37 37 38 38 $conditions = array("user_id"=>$this->Auth->user('id')); 39 $fields = array('id', 'title', 'access', 'status' , 'description');39 $fields = array('id', 'title', 'access', 'status'); 40 40 $order = "Ecourse.title DESC"; 41 41 -
trunk/app/controllers/tests_controller.php
r368 r372 14 14 public $helpers = array('Ajax', 'Gags'); 15 15 16 public $components = array('Edublog' );16 public $components = array('Edublog', 'Security'); 17 17 18 18 public $paginate = array( … … 145 145 } 146 146 147 private function get Results($questions)147 private function get_results($questions) 148 148 { 149 149 $this->Test->unbindModel(array('belongsTo'=>array('User'))); //just few data … … 169 169 public function admin_vclassrooms($test_id) 170 170 { 171 $this->pageTitle = $this->Auth->user('username') . '\'s Classrooms';171 $this->pageTitle = $this->Auth->user('username') . '\'s Tests'; 172 172 173 173 $this->layout = 'admin'; … … 180 180 181 181 $this->set('tests',$this->Test->TestsVclassroom->findAll(array('TestsVclassroom.test_id' => $test_id))); 182 183 $this->set('test_id', $test_id); 182 184 } 183 185 … … 188 190 $this->pageTitle = 'Tests'; 189 191 190 $conditions = array(' Vclassroom.user_id'=>$this->Auth->user('id'));192 $conditions = array('Test.user_id'=>$this->Auth->user('id')); 191 193 192 194 $fields = array('Test.id', 'Test.user_id', 'Test.title', 'Test.description', 'Test.status'); … … 197 199 198 200 $this->set('data', $this->Test->findAll($conditions, $fields, $order)); 201 } 202 203 public function admin_link2class() 204 { 205 $this->layout = 'admin'; 206 // add to database 207 if ( !empty($this->data['TestsVclassroom']) ) 208 { 209 $this->Sanitize = new Sanitize; 210 211 $this->Sanitize->clean($this->data['TestsVclassroom']); 212 213 $this->Test->TestsVclassroom->create(); 214 215 if ( $this->Test->TestsVclassroom->save($this->data['TestsVclassroom'])) 216 { 217 $this->msgFlash('Test assigned', '/admin/tests/vclassrooms/'.$this->data['TestsVclassroom']['test_id']); 218 } 219 else 220 { 221 die('Something is wrong, please report this bug'); 222 } 223 } 224 } 225 226 public function admin_unlink2class() 227 { 228 $this->layout = 'admin'; 229 // add to database 230 if ( !empty($this->data['TestsVclassroom']) ) 231 { 232 $this->Sanitize = new Sanitize; 233 234 $this->Sanitize->clean($this->data['TestsVclassroom']); 235 236 if ( $this->Test->TestsVclassroom->delete($this->data['TestsVclassroom']['id'])) 237 { 238 $this->msgFlash('Test unlinked', '/admin/tests/vclassrooms/'.$this->data['TestsVclassroom']['test_id']); 239 } 240 else 241 { 242 die('Something is wrong, please report this bug'); 243 } 244 } 199 245 } 200 246 -
trunk/app/views/ecourses/admin_listing.ctp
r352 r372 12 12 foreach ($data as $val) 13 13 { 14 15 14 $tmp = $html->div('butonright', $gags->sendEdit($val['Ecourse']['id'], 'ecourses')); 16 15 $tmp .= $html->link($val['Ecourse']['title'], '/admin/ecourses/vclassrooms/'.$val['Ecourse']['id']); 17 $tmp .= $html->para(null, $val['Ecourse']['description']);18 16 $tmp .= $html->div('butonright', $gags->confirmDel($val['Ecourse']['id'], 'ecourses')); 19 17 echo $html->div('grayblock', $tmp); -
trunk/app/views/tests/admin_listing.ctp
r368 r372 1 1 <?php 2 2 //die( debug( $data )); 3 ?>4 <div class="title_section">Tests</div>5 3 6 <p><?php echo $html->link($html->image('actions/new.png', array("alt"=>"Add entry", "title"=>"Add entry")), '/admin/tests/add', null, false, false) ?></p> 4 echo $html->div('title_section', 'Tests'); 7 5 8 <?php 6 echo $html->para(null, 7 $html->link($html->image('actions/new.png', array("alt"=>"Add entry", "title"=>"Add entry")), '/admin/tests/add', null, false, false) 8 ); 9 9 10 //die(print_r($data)); 10 11 … … 13 14 $s = ($val['Test']['status'] == 1) ? 'Published': 'Draft'; 14 15 15 echo '<div style="padding:6px 3px 28px 4px;margin:10px 0 5px 0;border:1px dotted gray;">';16 echo '<div class="grayblock">'; 16 17 echo $html->div('butonright', $gags->sendEdit($val['Test']['id'], 'tests')); 17 18 echo $html->link($val['Test']['title'], '/admin/tests/vclassrooms/'.$val['Test']['id']) . '<br /><br />'; 19 echo $html->para(null, '<b>Test description:</b> '.$val['Test']['description']); 20 18 21 echo $html->link('Questions', '/admin/tests/questions/'.$val['Test']['id']); 22 echo $html->link($html->image('admin/questions_icon.gif', array('alt'=>'Questions', 'title'=>'Questions')), 23 '/admin/tests/questions/'.$val['Test']['id'], null, null, false) . '<br />'; 19 24 20 if ( count($val['Vclassroom']) < 1 ) 25 26 if ( count($val['Vclassroom']) < 0 ) 21 27 { 22 28 echo $html->para(null, $html->link( 23 29 $html->image('admin/vgroups-gray.gif', array( 24 'alt' =>'There is no Classroomassigned for this test',25 'title'=>'There is no Classroomassigned for this test'30 'alt' =>'There is no class assigned for this test', 31 'title'=>'There is no class assigned for this test' 26 32 ) 27 33 ), 28 34 '/admin/tests/vclassrooms/'.$val['Test']['id'], null, null, false)); 29 35 } 30 echo $html->link($html->image('admin/questions_icon.gif', array('alt'=>'Questions')), 31 '/admin/tests/questions/'.$val['Test']['id'], null, null, false) . '<br />'; 32 echo $html->para(null, $val['Test']['description']); 36 else 37 { 38 echo $html->para(null, $html->link( 39 $html->image('static/vgroups.gif', array( 40 'alt' =>'Assign this test to new class', 41 'title'=>'Assign this test to new class' 42 ) 43 ), 44 '/admin/tests/vclassrooms/'.$val['Test']['id'], null, null, false)); 45 46 foreach($val['Vclassroom'] as $class): 47 echo $html->para(null, 'This test had been assigned to class: '. $html->link($class['name'], '/admi/ecourses/vclassroom/'.$class['id']) . '</b>'); 48 endforeach; 49 } 50 33 51 echo $html->para(null, $html->link($s, '/admin/tests/change/'.$val['Test']['id'].'/'.$val['Test']['status'])); 34 52 echo $html->div('butonright', $gags->confirmDel($val['Test']['id'], 'tests')); -
trunk/app/views/tests/admin_vclassrooms.ctp
r368 r372 1 1 <?php 2 die( debug($tests)); 2 echo $html->addCrumb('Control Tools', '/admin/entries/start'); 3 echo $html->addCrumb('Courses', '/admin/tests/listing'); 4 echo $html->getCrumbs(' / '); 5 //die( debug( $data ) ); 3 6 4 foreach ( $data as $val) 5 { 6 $tmp = $html->para(null, $val['Vclassroom']['name']); 7 $tmp .= $form->create('Test', array('action'=>'linkvclassroom')); 8 $tmp .= $form->hidden('Test.test_id', array('value'=>$val['Test']['id'])); 9 $tmp .= $form->hidden('Vclassroom.test_id', array('value'=>$val['Test']['id'])); 10 $tmp .= $form->end('Assign this test'); 7 $vclasses = array(); // contains vclassroom already linked to this test 8 9 foreach ( $tests as $test): 10 $vclasses[$test['TestsVclassroom']['id']] = $test['TestsVclassroom']['vclassroom_id']; 11 endforeach; 12 13 //die( debug( $vclasses ) ); 14 15 foreach ( $data as $val): 16 if ( !in_array($val['Vclassroom']['id'], $vclasses) ): 17 $tmp = $html->para(null, $html->image('admin/link.gif').$val['Vclassroom']['name']); 18 $tmp .= $form->create('Test', array('action'=>'link2class')); 19 $tmp .= $form->hidden('TestsVclassroom.test_id', array('value'=>$test_id)); 20 $tmp .= $form->hidden('TestsVclassroom.vclassroom_id', array('value'=>$val['Vclassroom']['id'])); 21 $tmp .= $form->end('Assign this test'); 11 22 12 13 echo $html->div('divblock', $tmp); 14 } 23 else: 24 25 $tmp = $html->para(null, $html->image('admin/unlink.gif').'This test is already assigned to <b>'.$val['Vclassroom']['name'].'</b>'); 26 27 foreach ( $tests as $test): 28 if ($test['TestsVclassroom']['vclassroom_id'] == $val['Vclassroom']['id']) 29 { 30 $testsvclasroom_id = $test['TestsVclassroom']['id']; 31 } 32 endforeach; 33 34 35 $tmp .= $form->create('Test', array('action'=>'unlink2class')); 36 $tmp .= $form->hidden('TestsVclassroom.id', array('value'=>$testsvclasroom_id)); 37 $tmp .= $form->hidden('TestsVclassroom.test_id', array('value'=>$test_id)); 38 $tmp .= $form->end('Unlink this test'); 39 endif; 40 41 echo $html->div('grayblock', $tmp); // print 42 43 endforeach; 15 44 ?>
