class TrueFalseProcessor in Opigno module 8
Same name and namespace in other branches
- 3.x ActivityTypes/opigno_h5p/src/TypeProcessors/TrueFalseProcessor.php \Drupal\opigno_h5p\TypeProcessors\TrueFalseProcessor
Class FillInProcessor.
Processes and generates HTML report for 'fill-in' interaction type.
Hierarchy
- class \Drupal\opigno_h5p\TypeProcessors\TypeProcessor
- class \Drupal\opigno_h5p\TypeProcessors\TrueFalseProcessor
Expanded class hierarchy of TrueFalseProcessor
File
- ActivityTypes/
opigno_h5p/ src/ TypeProcessors/ TrueFalseProcessor.php, line 10
Namespace
Drupal\opigno_h5p\TypeProcessorsView source
class TrueFalseProcessor extends TypeProcessor {
/**
* Options for interaction and generates a human readable HTML report.
*
* @inheritdoc
*/
public function generateHTML($description, $crp, $response, $extras = NULL, $scoreSettings = NULL) {
// We need some style for our report.
$this
->setStyle('opigno_h5p/opigno_h5p.true-false');
return $this
->getContent($description, $crp, $response, $scoreSettings) . $this
->generateFooter();
}
/**
* Get report content.
*/
private function getContent($description, $crp, $response, $scoreSettings) {
$isCorrectClass = $response === $crp[0] ? 'h5p-true-false-user-response-correct' : 'h5p-true-false-user-response-wrong';
$header = $this
->generateHeader($description, $scoreSettings);
return '<div class="h5p-reporting-container h5p-true-false-container">' . $header . '<p class="h5p-true-false-task"><span class="h5p-true-false-correct-responses-pattern">' . $crp[0] . '</span><span class="' . $isCorrectClass . '">' . $response . '</span></p>' . '</div>';
}
/**
* Generate header element.
*/
private function generateHeader($description, $scoreSettings) {
$descriptionHtml = "<p class='h5p-reporting-description h5p-true-false-task-description'>{$description}</p>";
$scoreHtml = $this
->generateScoreHtml($scoreSettings);
return "<div class='h5p-choices-header'>{$descriptionHtml}{$scoreHtml}</div>";
}
/**
* Generate footer.
*/
public function generateFooter() {
return '<div class="h5p-true-false-footer">' . '<span class="h5p-true-false-correct-responses-pattern">' . t('Correct Answer') . '</span>' . '<span class="h5p-true-false-user-response-correct">' . t('Your correct answer') . '</span>' . '<span class="h5p-true-false-user-response-wrong">' . t('Your incorrect answer') . '</span>' . '</div>';
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
TrueFalseProcessor:: |
public | function | Generate footer. | |
TrueFalseProcessor:: |
private | function | Generate header element. | |
TrueFalseProcessor:: |
public | function |
Options for interaction and generates a human readable HTML report. Overrides TypeProcessor:: |
|
TrueFalseProcessor:: |
private | function | Get report content. | |
TypeProcessor:: |
protected | property | ||
TypeProcessor:: |
private | property | ||
TypeProcessor:: |
protected | property | ||
TypeProcessor:: |
public | function | Generate HTML for report. | |
TypeProcessor:: |
protected | function | Generate score html. | |
TypeProcessor:: |
protected | function | Decode and retrieve Correct Responses Pattern from xAPI data. | |
TypeProcessor:: |
protected | function | Decode and retrieve 'en-US' description from xAPI data. | |
TypeProcessor:: |
protected | function | Decode extras from xAPI data. | |
TypeProcessor:: |
protected | function | Decode and retrieve user response from xAPI data. | |
TypeProcessor:: |
protected | function | Get score settings. | |
TypeProcessor:: |
public | function | Get style used by processor if used. | |
TypeProcessor:: |
protected | function | Set style used by the processor. |