H5PReport.php in Opigno module 8
File
ActivityTypes/opigno_h5p/src/H5PReport.php
View source
<?php
namespace Drupal\opigno_h5p;
class H5PReport {
private static $processorMap = [
'compound' => 'Drupal\\opigno_h5p\\TypeProcessors\\CompoundProcessor',
'fill-in' => 'Drupal\\opigno_h5p\\TypeProcessors\\FillInProcessor',
'true-false' => 'Drupal\\opigno_h5p\\TypeProcessors\\TrueFalseProcessor',
'matching' => 'Drupal\\opigno_h5p\\TypeProcessors\\MatchingProcessor',
'choice' => 'Drupal\\opigno_h5p\\TypeProcessors\\ChoiceProcessor',
'long-choice' => 'Drupal\\opigno_h5p\\TypeProcessors\\LongChoiceProcessor',
];
private $processors = [];
public function generateReport($xapiData, $forcedProcessor = NULL, $disableScoring = TRUE) {
$interactionType = isset($forcedProcessor) ? $forcedProcessor : $xapiData->interaction_type;
if (!isset(self::$processorMap[$interactionType])) {
return '';
}
if (!isset($this->processors[$interactionType])) {
$this->processors[$interactionType] = new self::$processorMap[$interactionType]();
}
return $this->processors[$interactionType]
->generateReport($xapiData, $disableScoring);
}
public function getStylesUsed() {
$styles = [];
foreach ($this->processors as $processor) {
$style = $processor
->getStyle();
if (!empty($style)) {
$styles[] = $style;
}
}
return $styles;
}
public static function getInstance() {
static $instance;
if (!$instance) {
$instance = new H5PReport();
}
return $instance;
}
}