Changeset 419

Show
Ignore:
Timestamp:
04/22/08 23:03:55 (9 months ago)
Author:
aarkerio
Message:

Fixed

Location:
trunk/app
Files:
9 modified

Legend:

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

    r363 r419  
    4343   if ( $this->Question->save( $this->data['Question'] ) )  
    4444   { 
    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'); 
    4747     $order      = "Question.id"; 
    4848                     
     
    5050                     
    5151     $this->render('questions', 'ajax'); 
    52     } 
    53     else 
    54     { 
     52    } 
     53    else 
     54    { 
    5555            echo "Ajax error, please report this bug"; 
    56     } 
     56    } 
    5757  } 
    5858 } 
     
    7070         if ( $this->Question->save( $this->data['Question'] ) )  
    7171         { 
    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']); 
    7373         } 
    7474         else 
     
    124124  } 
    125125   
    126   public function admin_delete($id)  
     126  public function admin_delete()  
    127127  { 
    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:  
    136131            $this->flash('Database error!', '/admin/tests/listing'); 
    137       } 
     132    endif; 
    138133  } 
    139134} 
  • trunk/app/controllers/tests_controller.php

    r373 r419  
    6666  public function view($test_id, $user_id) 
    6767  { 
    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     { 
    7273         $username = $this->Test->User->field('User.username', array("User.id"=>$user_id)); 
    7374     $this->flash('You already have answered this test', '/users/portfolio/'.$username); 
    7475         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); 
    7582    } 
    7683 
  • trunk/app/controllers/webquests_controller.php

    r418 r419  
    6060 } 
    6161 
    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);  
    8981 } 
    9082  
  • trunk/app/views/questions/questions.ctp

    r363 r419  
    66foreach ($data as $val)  
    77{       
    8     $answers = count($val["Answer"]); 
     8    $answers = count($val['Answer']); 
    99    $i++; 
    1010    echo '<div style="padding:5px;border:1px dotted gray;margin:auto;width:60%"><b>' . $i . '.-</b> '; 
    1111    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 
    1316       echo "Question: "    . $val['Question']['question']       . "<br />"; 
    1417       echo "Hint: "        . $val['Question']['hint']           . "<br />"; 
  • trunk/app/views/tests/admin_questions.ctp

    r363 r419  
    5757foreach ($data["Question"] as $val)  
    5858{       
    59     $answers = count($val["Answer"]); 
     59    $answers = count($val['Answer']); 
    6060    $i++; 
    6161    echo '<div style="padding:5px;border:1px dotted gray;margin:auto;width:60%"><b>' . $i . '.-</b> '; 
    6262    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 
    6467       echo "Question: "    . $val["question"]       . "<br />"; 
    6568       echo "Hint: "        . $val["hint"]           . "<br />"; 
    6669       echo "Explanation: " . $val["explanation"]    . "<br />"; 
    6770       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']); 
    6972    echo '</div>'; 
    7073} 
  • trunk/app/views/tests/view.ctp

    r398 r419  
    22//die(debug($data)); 
    33 
    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  
     6if ( $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; 
     10endif; 
     11  
     12if ( $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'); 
    4015 
    4116 
     17  echo '<h1>'. $data['Test']['title'] . '</h1>'; 
     18  echo '<p>'.  $data['Test']['description'] . '</p>'; 
    4219 
     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 
     42else: 
     43   echo $html->para(null, 'You must belong to class to see this exam'); 
     44endif; 
     45 
     46?> 
     47 
     48<script type="text/javascript"> 
     49 
     50function 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  
    2727       foreach($data['Test'] as $t) 
    2828       { 
    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'])); 
    3030       } 
    3131     } 
  • trunk/app/views/webquests/admin_edit.ctp

    r418 r419  
    1212<?php 
    1313echo $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)); 
     14echo $form->input('Webquest.title', array('size'=>60,'maxlength'=>160,'value'=>$wq_title,'style'=>'font-size:7pt')); 
     15echo $form->hidden('Webquest.id'); 
    1616echo $form->end('Save'); 
    1717?>   
     
    3232 
    3333<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?> 
    6456</div> 
    6557 
     
    8072    else  
    8173             Div.style.display = 'none'; 
    82        
    8374 } 
    8475--> 
  • trunk/app/views/webquests/view.ctp

    r270 r419  
     1<?php 
     2//die(debug($data)); 
     3$auth = false; 
     4  
     5if ( $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; 
     9endif; 
     10  
     11if ( $auth === true ): 
     12  echo $html->para(null, 'hi! '.$cU['User']['username'], array('style'=>'font-weight:bold;font-size:12pt;')); 
     13?>  
    114<h1><?php echo $data['Webquest']['title']; ?></h1> 
    215 
     
    2336   echo '<p>Created: <b>'. $data['Webquest']['created'].'</b></p>'; 
    2437echo '</div>'; 
    25 ?> 
     38 
     39else: 
     40     echo $html->link('Login to join this group', '/users/login'); 
     41endif;