private function DragDropQuestion::customShuffle in Quiz Drag Drop 7
Shuffles an array and makes sure the first element is the default element.
Parameters
array $array: Array to be shuffled
Return value
array A shuffled version of the array with $array['def'] = '' as the first element.
1 call to DragDropQuestion::customShuffle()
- DragDropQuestion::getAnsweringForm in ./
quiz_drag_drop.classes.inc - Generates the question form.
File
- ./
quiz_drag_drop.classes.inc, line 232 - Question type, enabling the creation of drag drop type of questions.
Class
- DragDropQuestion
- 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;
}