GravityView  2.17
The best, easiest way to display Gravity Forms entries on your website.
field-quiz-html.php
Go to the documentation of this file.
1 <?php
2 /**
3  * The default quiz field output template.
4  *
5  * @global \GV\Template_Context $gravityview
6  * @since 2.0
7  */
8 
9 if ( ! isset( $gravityview ) || empty( $gravityview->template ) ) {
10  gravityview()->log->error( '{file} template loaded without context', array( 'file' => __FILE__ ) );
11  return;
12 }
13 
14 $field = $gravityview->field->field;
15 $value = $gravityview->value;
16 $form = $gravityview->view->form->form;
17 $entry = $gravityview->entry->as_entry();
18 $field_settings = $gravityview->field->as_configuration();
19 
20 // If there's no grade, don't continue
21 if ( gv_empty( $value ) ) {
22  return;
23 }
24 
25 if ( ! class_exists( 'GFQuiz' ) ) {
26  do_action( 'gravityview_log_error', __FILE__ . ': GFQuiz class does not exist.' );
27  return;
28 }
29 
30 // Get the setting for show/hide explanation
31 $show_answer = \GV\Utils::get( $field_settings, 'quiz_show_explanation' );
32 
33 // Update the quiz field so GF generates the output properly
34 $field->gquizShowAnswerExplanation = ! empty( $show_answer );
35 
36 // Generate the output
37 echo GFQuiz::get_instance()->display_quiz_on_entry_detail( $value, $field, $entry, $form );
if(! isset( $gravityview)||empty( $gravityview->template)) $field
The default quiz field output template.
$field_settings
if(gv_empty( $value)) if(! class_exists( 'GFQuiz')) $show_answer
static get( $array, $key, $default=null)
Grab a value from an array or an object or default.
gravityview()
The main GravityView wrapper function.
gv_empty( $value, $zero_is_empty=true, $allow_string_booleans=true)
Is the value empty?