You are here

private function FillInProcessor::isResponseCorrect in Opigno module 3.x

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

Determine if a user response is correct.

Parameters

string $response: User response.

array $crp: Correct responses pattern.

bool $caseSensitive: Case sensitivity.

Return value

bool True if user response is correct.

1 call to FillInProcessor::isResponseCorrect()
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 303

Class

FillInProcessor
Class FillInProcessor.

Namespace

Drupal\opigno_h5p\TypeProcessors

Code

private function isResponseCorrect($response, array $crp, $caseSensitive) {
  $userResponse = $response;
  $matchingPattern = $crp;

  // Make user response and matching pattern lower case if case insensitive.
  if (isset($caseSensitive) && $caseSensitive === FALSE) {
    $userResponse = strtolower($response);
    $matchingPattern = array_map('strtolower', $crp);
  }
  return in_array($userResponse, $matchingPattern);
}