You are here

private function FillInProcessor::getCRPHtml 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::getCRPHtml()

Generate HTML from a single correct response pattern.

Parameters

array $singleCRP: Single CRP.

string $response: User response.

bool $caseSensitive: Case sensivity flag.

Return value

string CRP html.

1 call to FillInProcessor::getCRPHtml()
FillInProcessor::getPlaceholderReplacements in ActivityTypes/opigno_h5p/src/TypeProcessors/FillInProcessor.php
Process correct responses patterns and user responses.

File

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

Class

FillInProcessor
Class FillInProcessor.

Namespace

Drupal\opigno_h5p\TypeProcessors

Code

private function getCRPHtml(array $singleCRP, $response, $caseSensitive) {
  $html = [];
  foreach ($singleCRP as $value) {

    // Compare lower cases if not case sensitive.
    $comparisonCRP = $value;
    $comparisonResponse = $response;
    if (isset($caseSensitive) && $caseSensitive === FALSE) {
      $comparisonCRP = strtolower($value);
      $comparisonResponse = strtolower($response);
    }

    // Skip showing answers that user gave.
    if ($comparisonCRP === $comparisonResponse) {
      continue;
    }
    $html[] = $value;
  }
  return implode(self::CRP_REPORT_SEPARATOR, $html);
}