LLMS_Question::supports( string $feature, mixed $option = null )
Determine if the question supports a question feature
Parameters Parameters
- $feature
-
(string) (Required) Name of the feature (eg "choices").
- $option
-
(mixed) (Optional) Allow matching feature options.
Default value: null
Return Return
(boolean)
Source Source
File: includes/models/model.llms.question.php
* @param string $feature Name of the feature (eg "choices").
* @param mixed $option Allow matching feature options.
* @return boolean
*/
public function supports( $feature, $option = null ) {
$ret = false;
$type = $this->get_question_type();
if ( $type ) {
if ( 'choices' === $feature ) {
$ret = ( ! empty( $type['choices'] ) );
} elseif ( 'grading' === $feature ) {
$ret = ( $type['grading'] && $option === $type['grading'] );
} elseif ( 'points' === $feature ) {
$ret = $type['points'];
} elseif ( 'random_lock' === $feature ) {
$ret = $type['random_lock'];
} elseif ( 'selectable' === $feature ) {
$ret = empty( $type['choices'] ) ? false : $type['choices']['selectable'];
}
}
/**
* Filter supported features of a given question type.
*
* The dynamic portion of this hook, `$this->get( 'question_type' )`, refers to the type of question
* being filtered.
*
* @since 3.16.0
*
* @param boolean $ret Return value.
* @param string $string Name of the feature being checked.
* @param string $option Name of the option being checked.
* @param LLMS_Question $question Instance of the LLMS_Question.
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 3.16.15 | Unknown. |
| 3.16.0 | Introduced. |