private function MatchingQuestion::customShuffle in Quiz 7
Same name and namespace in other branches
- 6.6 question_types/matching/matching.classes.inc \MatchingQuestion::customShuffle()
- 6.3 question_types/matching/matching.classes.inc \MatchingQuestion::customShuffle()
- 6.4 question_types/matching/matching.classes.inc \MatchingQuestion::customShuffle()
- 6.5 question_types/matching/matching.classes.inc \MatchingQuestion::customShuffle()
- 7.6 question_types/matching/matching.classes.inc \MatchingQuestion::customShuffle()
- 7.4 question_types/matching/matching.classes.inc \MatchingQuestion::customShuffle()
- 7.5 question_types/matching/matching.classes.inc \MatchingQuestion::customShuffle()
Shuffles an array, but keeps the keys, and makes sure the first element is the default element
Parameters
$array: Array to be shuffled
Return value
A shuffled version of the array with $array['def'] = '' as the first element
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 235 - matching.classes
Class
- MatchingQuestion
- Extension of QuizQuestion.
Code
private function customShuffle(array $array = array()) {
$new_array = array();
$new_array['def'] = '';
while (count($array)) {
$element = array_rand($array);
$new_array[$element] = $array[$element];
unset($array[$element]);
}
return $new_array;
}