You are here

public function FillInProcessor::generateHTML in Opigno module 8

Same name and namespace in other branches
  1. 3.x ActivityTypes/opigno_h5p/src/TypeProcessors/FillInProcessor.php \Drupal\opigno_h5p\TypeProcessors\FillInProcessor::generateHTML()

Options for interaction and generates a human readable HTML report.

Overrides TypeProcessor::generateHTML

File

ActivityTypes/opigno_h5p/src/TypeProcessors/FillInProcessor.php, line 34

Class

FillInProcessor
Class FillInProcessor.

Namespace

Drupal\opigno_h5p\TypeProcessors

Code

public function generateHTML($description, $crp, $response, $extras, $scoreSettings = NULL) {

  // We need some style for our report.
  $this
    ->setStyle('opigno_h5p/opigno_h5p.fill-in');

  // Generate interaction options.
  $caseMatters = $this
    ->determineCaseMatters($crp[0]);
  if (!empty($crp)) {

    // Process correct responses and user responses patterns.
    $processedCRPs = $this
      ->processCRPs($crp, $caseMatters['nextIndex']);
    $processedResponse = $this
      ->processResponse($response);
    $header = $this
      ->generateHeader($scoreSettings);

    // Build report from description, correct responses and user responses.
    $report = $this
      ->buildReportOutput($description, $processedCRPs, $processedResponse, $caseMatters['caseSensitive']);
    $footer = $this
      ->generateFooter();
  }
  else {

    // If CPRs aren't available, display the question and the response.
    $header = '<div class="h5p-reporting-description">' . Xss::filter($description) . '</div>';
    $report = '<div class="h5p-fill-in-user-response">' . Xss::filter($response) . '</div>';

    // Footer information are not necessary if CRPs are not set.
    $footer = NULL;
  }
  $container = '<div class="h5p-reporting-container h5p-fill-in-container">' . $header . $report . '</div>';
  return $container . $footer;
}