gquiz_answer_indicator

Description

This filter allows the HTML markup for the answer indicator to be changed.

Usage

add_filter( 'gquiz_answer_indicator', 'gquiz_answer_indicator', 10, 7 );

Parameters

  • $indicator_markup string

    The indicator HTML/text for an answer.

  • $form Form Object

    The form object.

  • $field Field Object

    The field object.

  • $choice

    The Choice object for the quiz.

  • $lead Lead Object

    The Lead object.

  • $is_response_correct bool

    True or false if the response is correct; can be used to change indicators.

  • $is_response_wrong bool

    True or false if the response is incorrect; can be used to change indicators.

Examples

add_filter( 'gquiz_answer_indicator', 'gquiz_answer_indicator', 10, 7);
function gquiz_answer_indicator( $indicator_markup, $form, $field, $choice, $lead, $is_response_correct, $is_response_wrong ) {
if ( $is_response_correct ) {
$indicator_markup = ' (you got this one right!)';
} elseif ( $is_response_wrong ) {
if  ( $field['inputType'] == 'checkbox' && rgar( $choice, 'gquizIsCorrect' ) ) {
$indicator_markup = ' (you missed this one!)';
} else {
$indicator_markup = ' (you got this one wrong!)';
}
} elseif ( rgar( $choice, 'gquizIsCorrect' ) ) {
$indicator_markup = ' (this was the correct answer!)';
}
return $indicator_markup;
}

Placement

This code should be placed in the functions.php file of your active theme.

Source Code

This filter is located in GFQuiz::get_quiz_results() in gravityformsquiz/class-gf-quiz.php.