You are here

private function MatchingQuestion::customShuffle in Quiz 7.5

Same name and namespace in other branches
  1. 6.6 question_types/matching/matching.classes.inc \MatchingQuestion::customShuffle()
  2. 6.3 question_types/matching/matching.classes.inc \MatchingQuestion::customShuffle()
  3. 6.4 question_types/matching/matching.classes.inc \MatchingQuestion::customShuffle()
  4. 6.5 question_types/matching/matching.classes.inc \MatchingQuestion::customShuffle()
  5. 7.6 question_types/matching/matching.classes.inc \MatchingQuestion::customShuffle()
  6. 7 question_types/matching/matching.classes.inc \MatchingQuestion::customShuffle()
  7. 7.4 question_types/matching/matching.classes.inc \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/matching/matching.classes.inc
Implementation of getAnsweringForm().

File

question_types/matching/matching.classes.inc, line 257
Matching classes.

Class

MatchingQuestion
Extension of QuizQuestion.

Code

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