private function MatchingQuestion::customShuffle in Quiz 8.5
Same name and namespace in other branches
- 8.6 question_types/quiz_matching/src/Plugin/quiz/QuizQuestion/MatchingQuestion.php \Drupal\quiz_matching\Plugin\quiz\QuizQuestion\MatchingQuestion::customShuffle()
- 6.x question_types/quiz_matching/src/Plugin/quiz/QuizQuestion/MatchingQuestion.php \Drupal\quiz_matching\Plugin\quiz\QuizQuestion\MatchingQuestion::customShuffle()
Shuffles an array, but keep the keys.
Parameters
array $array: Array to be shuffled
Return value
array A shuffled version of the array with keys preserved.
1 call to MatchingQuestion::customShuffle()
- MatchingQuestion::getAnsweringForm in question_types/
quiz_matching/ src/ Plugin/ quiz/ QuizQuestion/ MatchingQuestion.php - Implementation of getAnsweringForm().
File
- question_types/
quiz_matching/ src/ Plugin/ quiz/ QuizQuestion/ MatchingQuestion.php, line 98 - Matching classes.
Class
- MatchingQuestion
- @QuizQuestion ( id = "matching", label = Plugin annotation @Translation("Matching question"), handlers = { "response" = "\Drupal\quiz_matching\Plugin\quiz\QuizQuestion\MatchingResponse" } )
Namespace
Drupal\quiz_matching\Plugin\quiz\QuizQuestionCode
private function customShuffle(array $array = array()) {
$new_array = array();
while (count($array)) {
$element = array_rand($array);
$new_array[$element] = $array[$element];
unset($array[$element]);
}
return $new_array;
}