/** * Reads data for an event. * @param [String => Mixed] $opts * @return [String => Mixed] * @override AttemtStarted */ public function read(array $opts) { $end = (new \DateTime())->setTimestamp($opts['attempt']->timestart); $start = (new \DateTime())->setTimestamp($opts['attempt']->timefinish); $duration = date_diff($start, $end)->format('P%YY%MM%DDT%HH%IM%SS'); return array_merge(parent::read($opts), ['recipe' => 'attempt_completed', 'attempt_result' => (double) ($opts['attempt']->sumgrades ?: 0), 'attempt_completed' => $opts['attempt']->state === 'finished', 'attempt_duration' => $duration]); }
/** * Reads data for an event. * @param [String => Mixed] $opts * @return [String => Mixed] * @override AttemtStarted */ public function read(array $opts) { $translatorevents = []; // Push question statements to $translatorevents['events']. foreach ($opts['attempt']->questions as $questionId => $questionAttempt) { array_push($translatorevents, $this->questionStatement(parent::read($opts)[0], $questionAttempt, $opts['questions'][$questionAttempt->questionid])); } return $translatorevents; }
/** * Reads data for an event. * @param [String => Mixed] $opts * @return [String => Mixed] * @override AttemtStarted */ public function read(array $opts) { $seconds = $opts['attempt']->timefinish - $opts['attempt']->timestart; $duration = "PT" . (string) $seconds . "S"; $scoreRaw = (double) ($opts['attempt']->sumgrades ?: 0); $scoreMin = (double) ($opts['grade_items']->grademin ?: 0); $scoreMax = (double) ($opts['grade_items']->grademax ?: 0); $scorePass = (double) ($opts['grade_items']->gradepass ?: null); $success = false; //if there is no passing score then success is unknown. if ($scorePass == null) { $success = null; } elseif ($scoreRaw >= $scorePass) { $success = true; } //Calculate scaled score as the distance from zero towards the max (or min for negative scores). $scoreScaled; if ($scoreRaw >= 0) { $scoreScaled = $scoreRaw / $scoreMax; } else { $scoreScaled = $scoreRaw / $scoreMin; } return [array_merge(parent::read($opts)[0], ['recipe' => 'attempt_completed', 'attempt_score_raw' => $scoreRaw, 'attempt_score_min' => $scoreMin, 'attempt_score_max' => $scoreMax, 'attempt_score_scaled' => $scoreScaled, 'attempt_success' => $success, 'attempt_completed' => $opts['attempt']->state === 'finished', 'attempt_duration' => $duration])]; }
/** * Reads data for an event. * @param [String => Mixed] $opts * @return [String => Mixed] * @override Event */ public function read(array $opts) { return array_merge(parent::read($opts), ['verb' => ['id' => 'http://adlnet.gov/expapi/verbs/completed', 'display' => $this->readVerbDisplay($opts)], 'result' => ['score' => ['raw' => $opts['attempt_result']], 'completion' => $opts['attempt_completed'], 'duration' => $opts['attempt_duration']]]); }