private function FillInProcessor::processCRPs in Opigno module 3.x
Same name and namespace in other branches
- 8 ActivityTypes/opigno_h5p/src/TypeProcessors/FillInProcessor.php \Drupal\opigno_h5p\TypeProcessors\FillInProcessor::processCRPs()
Massages correct responses patterns data.
The result is a two dimensional array sorted on placeholder order.
Parameters
array $crp: Correct responses pattern.
int $strStartIndex: Start index of actual response pattern. Any data before this index is options applied to the tasks, and should not be processed as part of the correct responses pattern.
Return value
array Two dimensional array. The first array dimensions is sorted on placeholder order, and the second separates between correct answer alternatives.
1 call to FillInProcessor::processCRPs()
- FillInProcessor::generateHTML in ActivityTypes/
opigno_h5p/ src/ TypeProcessors/ FillInProcessor.php - Options for interaction and generates a human readable HTML report.
File
- ActivityTypes/
opigno_h5p/ src/ TypeProcessors/ FillInProcessor.php, line 122
Class
- FillInProcessor
- Class FillInProcessor.
Namespace
Drupal\opigno_h5p\TypeProcessorsCode
private function processCRPs(array $crp, $strStartIndex) {
// CRPs sorted by placeholder order.
$sortedCRP = [];
foreach ($crp as $crpString) {
// Remove options.
$pattern = substr($crpString, $strStartIndex);
// Process correct responses pattern into array.
$answers = explode(self::RESPONSES_SEPARATOR, $pattern);
foreach ($answers as $index => $value) {
// Create array of correct alternatives at placeholder index.
if (!isset($sortedCRP[$index])) {
$sortedCRP[$index] = [];
}
// Add alternative to placeholder index.
if (!in_array($value, $sortedCRP[$index])) {
$sortedCRP[$index][] = $value;
}
}
}
return $sortedCRP;
}