Beispiel #1
0
 /**
  * Completes solving the test and saves the results to the database. If this is the first passed trial
  * among all of the members of the given area, it the result is saved as the result for the entire area, too.
  * 
  * @param Connection $conn
  * @param Area $area Area the user taking the trial is a member of
  * @param TestTrial $trial
  * @return CourseProgress|boolean
  * @throws Exception
  */
 public function completeTrial(Connection $conn, Area $area, TestTrial $trial)
 {
     $this->refresh($conn);
     $limit = $this->startedAt;
     $limit += $trial->getTimeLimitInMinutes() * 60;
     if ($limit < time()) {
         throw new CourseTestException('TestTimeHasPassedMsg');
     }
     $this->result = $trial->getResult();
     $this->totalQuestions = $trial->getQuestionNumber();
     $this->passedQuestions = $trial->countPassedQuestions();
     $this->completedAt = time();
     $this->save($conn);
     return $this->tryRecordingAreaResult($conn, $area, $trial);
 }