示例#1
0
 /**
  * Updates the progress summary for the given area.
  * 
  * @param Connection $conn
  * @param AbstractTestResult $result
  * @param TestTrial $trial
  */
 public function updateResults(Connection $conn, AbstractTestResult $result, TestTrial $trial)
 {
     $this->refresh($conn);
     if ($trial->getResult() == Question::RESULT_CORRECT) {
         $this->passedCourseNum++;
     } elseif ($trial->getResult() == Question::RESULT_INVALID) {
         $this->failedCourseNum++;
     }
     if ($result->getResult() == Question::RESULT_INVALID) {
         $this->failedCourseNum--;
     } elseif ($result->getResult() == Question::RESULT_CORRECT) {
         $this->passedCourseNum--;
     }
     $conn->update(CourseTables::COURSE_PROGRESS_TBL, ['passedCourseNum' => $this->passedCourseNum, 'failedCourseNum' => $this->failedCourseNum], ['areaId' => $this->area->getId()]);
 }
示例#2
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);
 }