You are here

private function MultichoiceQuestion::shuffle in Quiz 7.5

Same name and namespace in other branches
  1. 6.4 question_types/multichoice/multichoice.classes.inc \MultichoiceQuestion::shuffle()
  2. 7.6 question_types/multichoice/multichoice.classes.inc \MultichoiceQuestion::shuffle()
  3. 7 question_types/multichoice/multichoice.classes.inc \MultichoiceQuestion::shuffle()
  4. 7.4 question_types/multichoice/multichoice.classes.inc \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/multichoice/multichoice.classes.inc
Implementation of getAnsweringForm().
MultichoiceQuestion::getNodeView in question_types/multichoice/multichoice.classes.inc
Implementation of getNodeView().

File

question_types/multichoice/multichoice.classes.inc, line 462
Multichoice classes.

Class

MultichoiceQuestion
Extension of QuizQuestion.

Code

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;
}