llms_shuffle_choices( array $choices )
Shuffles choices until the choice order has changed from the original.
Description Description
The smaller the list of choices the greater the chance of shuffling not changing the array.
Parameters Parameters
- $choices
-
(array) (Required) Choices from an LLMS_Question
Return Return
(array)
Source Source
File: includes/functions/llms.functions.quiz.php
function llms_shuffle_choices( $choices ) { $count = count( $choices ); // If we only have one choice there's not much to shuffle with. if ( $count <= 1 ) { return $choices; // Reverse the array when we only have two. } elseif ( 2 === $count ) { $shuffled = array_reverse( $choices ); // Shuffle until the order has changed. } else { $shuffled = $choices; while ( $shuffled === $choices ) { shuffle( $shuffled ); } } return $shuffled; }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
3.16.12 | Introduced. |