Changeset 666 for trunk/app/controllers

Show
Ignore:
Timestamp:
07/22/08 17:08:42 (4 months ago)
Author:
aarkerio
Message:

Exmans and vclass

Location:
trunk/app/controllers
Files:
3 modified

Legend:

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

    r540 r666  
    2525 public function admin_add()  
    2626 { 
    27    if (!empty($this->data["Answer"])) 
    28    {   
    29     //die(print_r($this->data)); 
     27   if (!empty($this->data["Answer"])):   
    3028         
    31    $this->Sanitize = new Sanitize; 
     29     $this->Sanitize = new Sanitize; 
    3230         
    33    $this->Sanitize->clean($this->data["Answer"]); 
     31     $this->Sanitize->clean($this->data["Answer"]); 
    3432         
    35    $this->data["Answer"]['user_id'] = $this->Auth->user('id'); 
    36  
    37    $this->Answer->create(); 
     33     $this->data["Answer"]['user_id'] = $this->Auth->user('id'); 
    3834         
    39    if ( $this->Answer->save($this->data['Answer']) )  
    40    { 
    41      $conditions = array("Answer.question_id" => $this->data['Answer']['question_id']); 
    42      $fields     = array("Answer.id", "Answer.answer", "Answer.correct", "Answer.question_id"); 
    43      $order      = "Answer.id"; 
    44                      
    45      $this->set('data', $this->Answer->findAll($conditions, $fields, $order)); 
    46                      
    47      $this->render('questions', 'ajax'); 
    48    } 
    49    else 
    50    { 
     35     if ( $this->Answer->save($this->data) ): 
     36         $conditions = array("Answer.question_id" => $this->data['Answer']['question_id']); 
     37         $fields     = array("Answer.id", "Answer.answer", "Answer.correct", "Answer.question_id"); 
     38         $order      = "Answer.id";            
     39         $this->set('data', $this->Answer->findAll($conditions, $fields, $order)); 
     40         $this->render('questions', 'ajax'); 
     41   else: 
    5142     echo "Ajax error, check with the company's computer guy..."; 
    52    } 
    53   } 
     43   endif; 
     44  endif; 
    5445 } 
    5546 
  • trunk/app/controllers/questions_controller.php

    r575 r666  
    55*  GPLv3 manuel<arroba>mononeurona<punto>org 
    66*/  
    7 //File: /app/controllers/quotes_controller.php 
     7//File: /app/controllers/questions_controller.php 
    88 
    99uses('Sanitize'); 
     
    2929         
    3030    $this->data["Question"]['user_id'] = $this->Auth->user('id'); 
    31  
    32     $this->Question->create(); 
    3331         
    34     if ( $this->Question->save( $this->data['Question'] ) ): 
     32    if ( $this->Question->save( $this->data ) ): 
    3533      $conditions = array('Question.test_id' => $this->data['Question']['test_id']); 
    3634      $fields     = array('Question.id','Question.question','Question.hint','Question.worth','Question.explanation','Question.test_id'); 
     
    5048 { 
    5149    $this->layout = 'admin'; 
    52     // adds new vote to database 
    53     if ( !empty($this->data["Question"]) ) 
    54     {          
    55         $this->Sanitize = new Sanitize; 
     50    
     51    if ( !empty($this->data["Question"]) ):          
     52         $this->Sanitize = new Sanitize; 
    5653         
    57         $this->Sanitize->clean($this->data["Question"]); 
     54         $this->Sanitize->clean($this->data["Question"]); 
    5855                 
    59          if ( $this->Question->save( $this->data['Question'] ) )  
    60          { 
    61               $this->msgFlash('Question saved', '/admin/tests/questions/'.$this->data['Question']['test_id']); 
    62          } 
    63          else 
    64          { 
    65                 echo "Ajax error, check with the company's computer guy..."; 
    66          } 
    67      } 
    68      else 
    69      {   
     56     if ( $this->Question->save( $this->data ) ):  
     57             $this->msgFlash(__('Question saved', true), '/admin/tests/questions/'.$this->data['Question']['test_id']); 
     58     else: 
     59             echo "Ajax error, check with the company's computer guy..."; 
     60     endif; 
     61     else:   
    7062        $this->data = $this->Question->read(null, $question_id); 
    71      } 
     63     endif; 
    7264  } 
    7365   
     
    7668        $this->layout    = 'admin'; 
    7769         
    78         $this->pageTitle = 'Questions'; 
     70        $this->pageTitle = __('Questions', true); 
    7971         
    8072        $conditions = array("Question.user_id"=>$this->Auth->user('id')); 
  • trunk/app/controllers/tests_controller.php

    r578 r666  
    2929        $this->Auth->allow(array('view', 'display', 'result')); 
    3030   endif; 
    31    // L10n 
    32    $this->L10n = new L10n(); 
    33    $this->L10n->get("en"); 
    34   
    35    Configure::write('Config.language', "en"); 
    3631 } 
    3732 
    3833 public function display($username, $user_id) 
    3934 { 
    40     $this->pageTitle = 'Exams'; 
     35    $this->pageTitle = __('Tests', true); 
    4136           
    4237    $this->layout    = $this->Edublog->layout($user_id); 
     
    5348    $user_id = $this->Test->field('Test.user_id', array("Test.id"=>$test_id)); 
    5449     
    55     $this->pageTitle = 'Exam'; 
     50    $this->pageTitle = __('Test', true); 
    5651     
    5752    $this->layout    = $this->Edublog->layout($user_id); 
     
    189184   $this->layout    = 'admin'; 
    190185         
    191    $this->pageTitle = 'Tests'; 
     186   $this->pageTitle = __('Tests', true); 
    192187         
    193188   $conditions = array('Test.user_id'=>$this->Auth->user('id'));