Quiz correct answers in pdf

Hello,

I have developed an assessment, using the quiz add on. Though I have to select a ‘right’ answer so there are no unexpected calculations in the quiz result, there are no right or wrong answers in an assessment, so I don’t want right and/or wrong answers to appear on the pdf of each respondent’s assessment results.

How do I delete or hide the ticks and crosses in the pdf?

Thanks!

Tim

Hi Tim,

To clarify, are you using Gravity PDF to generate the PDF?

Sorry Jake, I should have said that. Yes, I am.

1 Like

Thanks for confirming, Tim.

If you add this code to your active theme’s functions.php file, Gravity PDF will begin outputting Quiz fields with just the user’s answer:

add_filter( 'gfpdf_pdf_field_content', function( $value, $field, $entry, $form ) {
	if ( $field->type !== 'quiz' ) {
		return $value;
	}

	return \GFCommon::replace_variables( '{:' . $field->id . '}', $form, $entry );
}, 10, 4 );

Let me know if you run into any problems.

1 Like

Excellent – thank you Jake! I will try it first thing tomorrow morning – I am on Pacific Time!

1 Like

Hi Jake,

My assessment doesn’t have right or wrong answers; some answers are just better than others. I would therefore like to get rid of the ticks and crosses altogether, if possible.

Is there a way to do that?

Thank you!

Tim

Hey Tim,

Similar process as above, but this time you would strip out the images used:

    add_filter( 'gfpdf_pdf_field_content', function( $value, $field, $entry, $form ) {
    	if ( $field->type !== 'quiz' ) {
    		return $value;
    	}

    	return wp_kses( $value, [ 'ul' => [], 'li' => [] ] );
    }, 10, 4 );
1 Like