public static function fromID($vID)
 {
     //Start by making sure the appropriate record exists
     $db = Zend_Registry::get("db");
     $result = $db->query("SELECT * FROM question_attempt where attempt_id='" . addslashes($vID) . "'");
     $row = $result->fetch();
     if ($row['attempt_id'] == null) {
         return null;
         //No corresponding record found in database
     }
     //Assuming we have the appropriate records
     $vReturn = new Model_Quiz_QuestionAttempt();
     $vReturn->attempt_id = $row['attempt_id'];
     $vReturn->initial_result = $row['initial_result'];
     $vReturn->secondary_result = $row['secondary_result'];
     $vReturn->question_basequestion_id = Model_Quiz_QuestionBase::fromID($row['question_basequestion_id']);
     $vReturn->attempted_on = strtotime($row['attempted_on']);
     $vReturn->time_started = strtotime($row['time_started']);
     $vReturn->time_finished = strtotime($row['time_finished']);
     $vReturn->quiz_attemptquiz_attempt_id = Model_Quiz_QuizAttempt::fromID($row['quiz_attemptquiz_attempt_id']);
     $vReturn->generated_questionsgenerated_id = Model_Quiz_GeneratedQuestion::fromID($row['generated_questionsgenerated_id']);
     return $vReturn;
     //Return the result
 }
예제 #2
0
파일: Quiz.php 프로젝트: sutantyo/itec810
 public function getQuizAttempts()
 {
     $db = Zend_Registry::get("db");
     $vReturn = array();
     $result = $db->query("SELECT * FROM quiz_attempt WHERE quizquiz_id=" . $db->quote($this->quiz_id));
     $rows = $result->fetchAll();
     foreach ($rows as $row) {
         $vReturn[] = Model_Quiz_QuizAttempt::fromID($row['quiz_attempt_id']);
     }
     return $vReturn;
 }
예제 #3
0
 public static function getHighestMarkQuiz($vUser, $vQuiz)
 {
     My_Logger::log("In " . __METHOD__ . " quiz id is " . $vQuiz->getID());
     $db = Zend_Registry::get("db");
     $result = $db->query("SELECT * FROM quiz_attempt WHERE ad_user_cachesamaccountname=" . $db->quote($vUser) . " AND quizquiz_id=" . $vQuiz->getID() . " ORDER BY total_score DESC");
     $row = $result->fetch();
     return Model_Quiz_QuizAttempt::fromID($row['quiz_attempt_id']);
 }