Show
Ignore:
Timestamp:
05/08/08 19:18:13 (8 months ago)
Author:
aarkerio
Message:

Forums and topics improveds

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/app/models/test.php

    r428 r466  
    7575    return $vclassrooms; 
    7676 } 
     77/* 
     78 *  check if studen already found treasure 
     79 *  int treasure_id  
     80 *  int user_id       
     81 *  int vclassroom_id 
     82 *  return boolean 
     83 */ 
     84 public function chk($test_id, $user_id, $vclassroom_id) 
     85 { 
     86    $conditions =  array("Result.user_id"=>$user_id, "Result.test_id"=>$test_id, "Result.vclassroom_id"=>$vclassroom_id); 
     87    $data       =  $this->Result->field('Result.id', $conditions); 
     88    
     89    if ($data != null ): 
     90          return false;    
     91    else: 
     92          return true; 
     93    endif; 
     94 } 
    7795 
    7896 public function chkAnswers($answers, $test_id) 
     
    82100    $result = 0; 
    83101     
    84     foreach($questions as $q_id => $a_id)  // question id and answer id 
    85     { 
     102    foreach($questions as $q_id => $a_id):  // question id and answer id 
    86103         $correct_answer = $this->Test->Question->Answer->field('Answer.correct', array('Answer.id'=>$a_id));   // answer was correct? 
    87104          
    88          if ($correct_answer == 1) 
    89          { 
     105           if ($correct_answer == 1): 
    90106              $worth   = $this->Test->Question->field('Question.worth', array('Question.id'=>$q_id));         // how many points 
    91107              $result += $worth; 
    92          } 
    93     } 
    94     //exit('Result was:' . $result); 
     108           endif; 
     109     endforeach; 
     110    //exit('Result was:' . $result)e 
    95111    return $result;  
    96112  }