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

Exmans and vclass

Files:
1 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