Пример #1
0
 function hasPendingPrerequisite($username)
 {
     $prereq = $this->getPrerequisite();
     if (!$prereq) {
         return false;
     }
     $prereq_question = Model_Quiz_Quiz::fromID($prereq);
     // have the user attempted the prerequisites?
     $attempt = Model_Quiz_QuizAttempt::fromQuizAndUser($prereq, $username);
     if (!$attempt) {
         return true;
         //prerequisite has not even been attempted
     }
     // if yes, of all the attempts, has the best score passed the quiz requirement?
     if ($attempt->getDate_finished()) {
         $best_attempt = Model_Quiz_QuizAttempt::getHighestMarkQuiz($username, $prereq_question);
         return !$best_attempt->hasPassedQuiz();
     }
     return true;
     /*
     		if ($attempt->getDate_finished()==null){
     			$vQuizStatus = Model_Quiz_Quiz::QUIZ_INPROGRESS;
     			if($vQuiz->getClose_date() < strtotime("now")){
     				echo "\t\t<td>In Progress (Late)</td>\n";
     			}
     			else{
     				echo "\t\t<td>In Progress</td>\n";
     			}
     
     		}else{
     			$vQuizStatus = Model_Quiz_Quiz::QUIZ_COMPLETED;
     			echo "\t\t<td>Completed</td>\n";
     		}
     */
 }
Пример #2
0
 /**
  * Shows Available Quizzes for the logged in User
  *
  * @return void
  * @author Ben Evans
  */
 public function availableAction()
 {
     $this->view->headTitle("Available Quizzes");
     $outstanding = $this->_getParam("outstanding");
     $vQuizzes = Model_Quiz_Quiz::getAll(true);
     $vAvailable = array();
     $auth_model = Model_Auth_General::getAuthModel();
     $identity = Zend_Auth::getInstance()->getIdentity();
     /*	Make sure you have permission	*/
     foreach ($vQuizzes as $vQuiz) {
         if ($this->view->is_admin) {
             $vAvailable[] = $vQuiz;
         } else {
             if ($auth_model->userInGroup($this->view->username, $vQuiz->getPermissions_group()) && $vQuiz->getOpen_date() <= strtotime("now")) {
                 $vAvailable[] = $vQuiz;
             }
         }
     }
     if (isset($outstanding)) {
         $this->view->title = "Outstanding Quizzes";
         $vOutstanding = array();
         foreach ($vAvailable as $vQuiz) {
             $vQuizAttempt = Model_Quiz_QuizAttempt::fromQuizAndUser($vQuiz, $identity->username);
             if ($vQuizAttempt == null) {
                 $vOutstanding[] = $vQuiz;
             } else {
                 //Have an end time?
                 if ($vQuizAttempt->getDate_finished() == null) {
                     $vOutstanding[] = $vQuiz;
                 }
             }
         }
         //Make the new 'available quizzes' the quizzes that aren't complete yet
         $vAvailable = $vOutstanding;
     } else {
         $this->view->title = "Available Quizzes";
     }
     $this->view->available = $vAvailable;
 }