llms_shuffle_choices( array $choices )

Shuffles choices until the choice order has changed from the original The smaller the list of choices the greater the chance of shuffling not changing the array


Description Description


Parameters Parameters

$choices

(array) (Required) choices from an LLMS_Question


Top ↑

Return Return

(array)


Top ↑

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;

}

Top ↑

Changelog Changelog

Changelog
Version Description
3.16.12 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.