Changeset 372

Show
Ignore:
Timestamp:
04/07/08 15:54:44 (9 months ago)
Author:
aarkerio
Message:

Tests fixed

Location:
trunk/app
Files:
2 added
5 modified

Legend:

Unmodified
Added
Removed
  • trunk/app/controllers/ecourses_controller.php

    r354 r372  
    3737        
    3838       $conditions   =  array("user_id"=>$this->Auth->user('id')); 
    39        $fields       =  array('id', 'title', 'access',  'status', 'description'); 
     39       $fields       =  array('id', 'title', 'access',  'status'); 
    4040       $order        =  "Ecourse.title DESC"; 
    4141        
  • trunk/app/controllers/tests_controller.php

    r368 r372  
    1414 public $helpers    = array('Ajax', 'Gags'); 
    1515   
    16  public $components = array('Edublog'); 
     16 public $components = array('Edublog', 'Security'); 
    1717  
    1818 public $paginate = array( 
     
    145145 } 
    146146 
    147  private function getResults($questions) 
     147 private function get_results($questions) 
    148148 { 
    149149    $this->Test->unbindModel(array('belongsTo'=>array('User'))); //just few data 
     
    169169 public function admin_vclassrooms($test_id) 
    170170 {     
    171    $this->pageTitle = $this->Auth->user('username') . '\'s Classrooms'; 
     171   $this->pageTitle = $this->Auth->user('username') . '\'s Tests'; 
    172172       
    173173   $this->layout = 'admin'; 
     
    180180 
    181181   $this->set('tests',$this->Test->TestsVclassroom->findAll(array('TestsVclassroom.test_id' => $test_id))); 
     182    
     183   $this->set('test_id', $test_id); 
    182184 } 
    183185     
     
    188190   $this->pageTitle = 'Tests'; 
    189191         
    190    $conditions = array('Vclassroom.user_id'=>$this->Auth->user('id')); 
     192   $conditions = array('Test.user_id'=>$this->Auth->user('id')); 
    191193         
    192194   $fields     = array('Test.id', 'Test.user_id', 'Test.title', 'Test.description', 'Test.status'); 
     
    197199       
    198200   $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   } 
    199245 } 
    200246  
  • trunk/app/views/ecourses/admin_listing.ctp

    r352 r372  
    1212foreach ($data as $val) 
    1313{ 
    14  
    1514      $tmp  = $html->div('butonright', $gags->sendEdit($val['Ecourse']['id'], 'ecourses')); 
    1615      $tmp .= $html->link($val['Ecourse']['title'], '/admin/ecourses/vclassrooms/'.$val['Ecourse']['id']); 
    17       $tmp .= $html->para(null, $val['Ecourse']['description']); 
    1816      $tmp .= $html->div('butonright', $gags->confirmDel($val['Ecourse']['id'], 'ecourses')); 
    1917      echo $html->div('grayblock', $tmp); 
  • trunk/app/views/tests/admin_listing.ctp

    r368 r372  
    11<?php 
    22//die( debug( $data )); 
    3 ?> 
    4 <div class="title_section">Tests</div> 
    53 
    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> 
     4echo $html->div('title_section', 'Tests'); 
    75 
    8 <?php 
     6echo $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 
    910//die(print_r($data)); 
    1011 
     
    1314  $s  =  ($val['Test']['status'] == 1) ? 'Published': 'Draft'; 
    1415 
    15   echo '<div style="padding:6px 3px 28px 4px;margin:10px 0 5px 0;border:1px dotted gray;">'; 
     16  echo '<div class="grayblock">'; 
    1617         echo $html->div('butonright', $gags->sendEdit($val['Test']['id'], 'tests')); 
    1718         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 
    1821         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 />'; 
    1924 
    20          if ( count($val['Vclassroom']) < 1 )  
     25 
     26         if ( count($val['Vclassroom']) < 0 )  
    2127         { 
    2228           echo $html->para(null, $html->link( 
    2329                                              $html->image('admin/vgroups-gray.gif', array( 
    24                                                                                            'alt'  =>'There is no Classroom assigned for this test',  
    25                                                                                            'title'=>'There is no Classroom assigned for this test' 
     30                                                                                           'alt'  =>'There is no class assigned for this test',  
     31                                                                                           'title'=>'There is no class assigned for this test' 
    2632                                                                                           ) 
    2733                                                           ),  
    2834                                              '/admin/tests/vclassrooms/'.$val['Test']['id'], null,  null, false)); 
    2935         } 
    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 
    3351         echo $html->para(null, $html->link($s, '/admin/tests/change/'.$val['Test']['id'].'/'.$val['Test']['status'])); 
    3452         echo $html->div('butonright',  $gags->confirmDel($val['Test']['id'], 'tests')); 
  • trunk/app/views/tests/admin_vclassrooms.ctp

    r368 r372  
    11<?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 ) ); 
    36 
    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 
     9foreach ( $tests as $test): 
     10     $vclasses[$test['TestsVclassroom']['id']] = $test['TestsVclassroom']['vclassroom_id']; 
     11endforeach; 
     12 
     13//die( debug( $vclasses ) );  
     14 
     15foreach ( $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'); 
    1122   
    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 
     43endforeach; 
    1544?>