function template_preprocess_opigno_answer__opigno_scorm__full in Opigno module 8
Same name and namespace in other branches
- 3.x ActivityTypes/opigno_scorm_activity/opigno_scorm_activity.theme.inc \template_preprocess_opigno_answer__opigno_scorm__full()
Prepares variables for Answer templates.
Default template: opigno-answer--opigno-scorm--full.html.twig.
Parameters
array $variables: An associative array containing:
- elements: An associative array containing the user information and any
- attributes: HTML attributes for the containing element.
File
- ActivityTypes/
opigno_scorm_activity/ opigno_scorm_activity.theme.inc, line 83 - Contains opigno_scorm_activity.theme.inc.
Code
function template_preprocess_opigno_answer__opigno_scorm__full(array &$variables) {
foreach (Element::children($variables['elements']) as $key) {
$variables['content'][$key] = $variables['elements'][$key];
}
$answer = $variables['elements']['#opigno_answer'];
$answer_service = \Drupal::service('plugin.manager.activity_answer');
$answer_instance = $answer_service
->createInstance('opigno_scorm');
$answer_data = $answer_instance
->getAnswerResultItemData($answer);
if ($answer_data) {
$scormReport = ScormReport::getInstance();
$table = $scormReport
->generateHtml($answer_data, TRUE);
$variables['#attached']['library'][] = 'opigno_module/module_results_page';
$variables['#attached']['library'][] = 'opigno_h5p/opigno_h5p.choice';
$variables['#attached']['library'][] = 'opigno_h5p/opigno_h5p.true-false';
}
else {
$table = '<div class="h5p-reporting-container h5p-choices-container result-item">' . t('No interactions') . '</div>';
}
$variables['content']['table'] = [
'#markup' => $table,
];
}