LLMS_Question::get_correct_choice()
Retrieve correct choices for a given question
Return Return
(array)
Source Source
File: includes/models/model.llms.question.php
public function get_correct_choice() { $correct = false; if ( $this->supports( 'choices' ) && $this->supports( 'grading', 'auto' ) ) { $multi = ( 'yes' === $this->get( 'multi_choices' ) ); $correct = array(); foreach ( $this->get_choices() as $choice ) { if ( $choice->is_correct() ) { $correct[] = $choice->get( 'id' ); if ( ! $multi ) { break; } } } // Always sort multi choices for easy auto comparison. if ( $multi && $this->supports( 'selectable' ) ) { sort( $correct ); } } return $correct; }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
3.16.0 | Introduced. |