public function findTotalIndividualResultsForArea(Area $area)
 {
     $items = $this->conn->fetchAll('SELECT c.`id` AS `courseId`, c.`name` AS `courseName`, u.`id` AS `userId`, u.`name` AS `userName`, u.`avatar`, ' . 'ur.`result`, ur.`totalQuestions`, ur.`passedQuestions`, ur.`completedAt`, ur.`trialNumber` ' . 'FROM `' . CourseTables::COURSE_TBL . '` c ' . 'INNER JOIN `' . CoreTables::AREA_MEMBER_TBL . '` m ON m.`areaId` = :areaId ' . 'INNER JOIN `' . CoreTables::USER_TBL . '` u ON u.`id` = m.`userId` ' . 'LEFT JOIN `' . CourseTables::COURSE_RESULT_TBL . '` ur ON ur.`userId` = u.`id` AND c.`id` = ur.`courseId` ' . 'WHERE c.`isPublished` = 1 AND u.`active` = 1 AND c.`projectId` = :projectId ' . 'ORDER BY c.`displayOrder`, u.`name`', [':areaId' => $area->getId(), ':projectId' => $area->getProject()->getId()]);
     foreach ($items as &$item) {
         TestResult::processResults($item);
     }
     return $items;
 }
Example #2
0
 public function testPassedTestAfterPreviousFails()
 {
     // Given
     $this->createResultForUserAndArea($this->user, $this->area, Question::RESULT_INVALID, 12, 4);
     $testResult = TestResult::fetchResult(self::$conn, $this->anotherUser, $this->course);
     $testResult->setStartedAt(time());
     $trial = $this->getTestTrial(Question::RESULT_CORRECT, 12, 12, 10);
     $this->fillRecord($this->area, 2, 1, 1);
     // When
     $testResult->completeTrial(self::$conn, $this->area, $trial);
     // Then
     $this->assertEquals(Question::RESULT_CORRECT, $testResult->getResult());
     $this->assertEquals(12, $testResult->getTotalQuestions());
     $this->assertEquals(12, $testResult->getPassedQuestions());
     $this->expectTestResult($this->user, Question::RESULT_INVALID, 1, 12, 4);
     $this->expectTestResult($this->anotherUser, Question::RESULT_CORRECT, 1, 12, 12);
     $this->expectAreaResult($this->anotherUser);
     $this->expectCourseProgress($this->area, 2, 2, 0);
 }
Example #3
0
 public function completeTrial(TestResult $result, Area $area, TestTrial $trial)
 {
     $this->transaction->requestTransaction();
     try {
         $output = $result->completeTrial($this->conn, $area, $trial);
         $this->spawnActivationEvent($area, $output);
     } catch (Exception $ex) {
         $this->transaction->requestRollback();
         throw $ex;
     }
 }