| 56 | | public $validate = array( |
| 57 | | 'title' => VALID_NOT_EMPTY, |
| 58 | | 'description' => VALID_NOT_EMPTY, |
| 59 | | 'user_id' => VALID_NOT_EMPTY |
| 60 | | ); |
| | 56 | public $validate = array( |
| | 57 | 'title' => array( |
| | 58 | 'rule' => array('minLength', '4'), |
| | 59 | 'message' => 'Mimimum 4 characters long' |
| | 60 | ), |
| | 61 | 'description' => array( |
| | 62 | 'rule' => array('minLength', '4'), |
| | 63 | 'message' => 'Mimimum 4 characters long' |
| | 64 | ) |
| | 65 | ); |
| 62 | | public $validate = array( |
| 63 | | 'login' => array('alphanumeric' => array( |
| 64 | | 'rule' => 'alphaNumeric', |
| 65 | | 'required' => true, |
| 66 | | 'message' => 'Alphabets and numbers only' |
| 67 | | ), |
| 68 | | 'between' => array( |
| 69 | | 'rule' => array('between', 5, 15), |
| 70 | | 'message' => 'Between 5 to 15 characters' |
| 71 | | ) |
| 72 | | ), |
| 73 | | 'password' => array( |
| 74 | | 'rule' => array('minLength', '8'), |
| 75 | | 'message' => 'Mimimum 8 characters long' |
| 76 | | ), |
| 77 | | 'email' => 'email', |
| 78 | | 'born' => array( |
| 79 | | 'rule' => 'date', |
| 80 | | 'message' => 'Enter a valid date', |
| 81 | | 'allowEmpty' => true |
| 82 | | ) |
| 83 | | ); */ |
| 84 | | public function linkClassroom($test_id, $user_id) |
| 85 | | { |
| 86 | | $condition = array('Test.status'=>1, 'Test.user_id'=>$user_id, 'Test.id'=>$test_id); |
| | 67 | * getPoints returns points from already answered test by student |
| | 68 | * |
| | 69 | */ |
| | 70 | public function getPoints($test_id, $user_id, $vclassroom_id) |
| | 71 | { |
| | 72 | $points = (int) 0; |
| | 73 | |
| | 74 | $conditions = array('Result.test_id'=>$test_id, 'Result.user_id'=>$user_id, 'Result.vclassroom_id'=>$vclassroom_id); |
| | 75 | |
| | 76 | $this->Result->unbindAll(); // removeds unnecesary stuff |
| | 77 | |
| | 78 | $answers = $this->Result->findAll($conditions); // get the answers gived by student |
| | 79 | |
| | 80 | foreach($answers as $a): |
| | 81 | $question = $this->Question->find(array('Question.id'=>$a['Result']['question_id']), array('worth')); // how much points question have? |
| | 82 | foreach($question['Answer'] as $qa): |
| | 83 | if ($qa['id'] == $a['Result']['answer_id'] && $qa['question_id'] == $a['Result']['question_id'] && $qa['correct'] == 1): |
| | 84 | $points += (int) $question['Question']['worth']; |
| | 85 | endif; |
| | 86 | endforeach; |
| | 87 | endforeach; |
| | 88 | |
| | 89 | return $points; |
| | 90 | } |
| | 91 | public function linkClassroom($test_id, $user_id) |
| | 92 | { |
| | 93 | $conditions = array('Test.status'=>1, 'Test.user_id'=>$user_id, 'Test.id'=>$test_id); |