diff --git a/styles/choice.css b/styles/choice.css index d4f31aa..3da28f8 100644 --- a/styles/choice.css +++ b/styles/choice.css @@ -60,6 +60,11 @@ border-radius: 5px; } +.h5p-choices-user.h5p-choices-answered.h5p-choices-user-correct.h5p-choices-no-correct { + background-color: #186df7; + border: none; +} + .h5p-choices-user.h5p-choices-answered.h5p-choices-user-correct:before { font-family: 'h5p-reporting-icons'; content: "\e90c"; diff --git a/type-processors/choice-processor.class.php b/type-processors/choice-processor.class.php index 4ae1946..9c4b5ad 100644 --- a/type-processors/choice-processor.class.php +++ b/type-processors/choice-processor.class.php @@ -24,7 +24,8 @@ public function generateHTML($description, $crp, $response, $extras = NULL, $sco // We need some style for our report $this->setStyle('styles/choice.css'); - $correctAnswers = explode('[,]', $crp[0]); + // choice type exercises lack correct reponses pattern if there's no right/wrong answer + $correctAnswers = (isset($crp)) ? explode('[,]', $crp[0]) : NULL; $responses = explode('[,]', $response); $headerHtml = $this->generateHeader($description, $scoreSettings); @@ -77,19 +78,22 @@ private function generateDescription($description) { * @return string Table element */ private function generateTable($extras, $correctAnswers, $responses) { + $hasNoRightOrWrong = !isset($correctAnswers); $choices = $extras->choices; $tableHeader = '' . - 'Answers' . + 'Answers'; + $tableHeader .= ($hasNoRightOrWrong) ? + 'Chosen' : 'Your Answer' . - 'Correct' . - ''; + 'Correct'; + $tableHeader .= ''; $rows = ''; foreach($choices as $choice) { $choiceID = $choice->id; - $isCRP = in_array($choiceID, $correctAnswers); + $isCRP = !$hasNoRightOrWrong && in_array($choiceID, $correctAnswers); $isAnswered = in_array($choiceID, $responses); $userClasses = 'h5p-choices-user'; @@ -97,6 +101,9 @@ private function generateTable($extras, $correctAnswers, $responses) { if ($isAnswered) { $userClasses .= ' h5p-choices-answered'; } + if ($hasNoRightOrWrong) { + $userClasses .= ' h5p-choices-user-correct h5p-choices-no-correct'; + } if ($isCRP) { $userClasses .= ' h5p-choices-user-correct'; $crpClasses .= ' h5p-choices-crp-correct'; @@ -108,10 +115,13 @@ private function generateTable($extras, $correctAnswers, $responses) { '' . '' . '' . - '' . - '' . - '' . ''; + if (!$hasNoRightOrWrong) { + $row .= + '' . + '' . + ''; + } $rows .= '' . $row . ''; }