private function MultichoiceQuestion::shuffle in Quiz 8.5
Same name and namespace in other branches
- 8.6 question_types/quiz_multichoice/src/Plugin/quiz/QuizQuestion/MultichoiceQuestion.php \Drupal\quiz_multichoice\Plugin\quiz\QuizQuestion\MultichoiceQuestion::shuffle()
- 6.x question_types/quiz_multichoice/src/Plugin/quiz/QuizQuestion/MultichoiceQuestion.php \Drupal\quiz_multichoice\Plugin\quiz\QuizQuestion\MultichoiceQuestion::shuffle()
Custom shuffle function.
It keeps the array key - value relationship intact.
Parameters
array $array:
Return value
array
2 calls to MultichoiceQuestion::shuffle()
- MultichoiceQuestion::getAnsweringForm in question_types/
quiz_multichoice/ src/ Plugin/ quiz/ QuizQuestion/ MultichoiceQuestion.php - Get the form through which the user will answer the question.
- MultichoiceQuestion::getNodeView in question_types/
quiz_multichoice/ src/ Plugin/ quiz/ QuizQuestion/ MultichoiceQuestion.php - Implementation of getNodeView().
File
- question_types/
quiz_multichoice/ src/ Plugin/ quiz/ QuizQuestion/ MultichoiceQuestion.php, line 475
Class
- MultichoiceQuestion
- @QuizQuestion ( id = "multichoice", label = Plugin annotation @Translation("Multiple choice question"), handlers = { "response" = "\Drupal\quiz_multichoice\Plugin\quiz\QuizQuestion\MultichoiceResponse" } )
Namespace
Drupal\quiz_multichoice\Plugin\quiz\QuizQuestionCode
private function shuffle(array &$array) {
$newArray = array();
$toReturn = array_keys($array);
shuffle($toReturn);
foreach ($toReturn as $key) {
$newArray[$key] = $array[$key];
}
$array = $newArray;
return $toReturn;
}