GravityView  2.17
The best, easiest way to display Gravity Forms entries on your website.
field-gquiz_is_pass-html.php
Go to the documentation of this file.
1 <?php
2 /**
3  * The default quiz pass/fail 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 $form = $gravityview->view->form->form;
15 $display_value = $gravityview->display_value;
16 $entry = $gravityview->entry->as_entry();
17 
18 // If there's no grade, don't continue
19 if ( gv_empty( $display_value, false, false ) ) {
20  return;
21 }
22 
23 // Check if grading is enabled for the form. If not set, default to false.
24 $grading_type_enabled = ! empty( $form['gravityformsquiz']['grading'] ) ? $form['gravityformsquiz']['grading'] : 'none';
25 
26 if ( 'passfail' === $grading_type_enabled ) {
27 
28  // By default, the field value is "1" for Pass and "0" for Fail. We want the text.
29  echo GFCommon::replace_variables( '{quiz_passfail}', $form, $entry );
30 
31 } elseif ( GVCommon::has_cap( 'gravityforms_edit_forms' ) ) {
32  $grade_type = __( 'Pass/Fail', 'gk-gravityview' );
33  printf( esc_html_x( '%s grading is disabled for this form. %sChange the setting%s', '%s is the current Quiz field type ("Letter" or "Pass/Fail")', 'gk-gravityview' ), $grade_type, '<a href="'. admin_url('admin.php?page=gf_edit_forms&amp;view=settings&amp;subview=gravityformsquiz&amp;id='.$form['id'] ) . '">', '</a>' );
34 }
if(! isset( $gravityview)||empty( $gravityview->template)) $form
The default quiz pass/fail field output template.
if(gv_empty( $display_value, false, false)) $grading_type_enabled
gravityview()
The main GravityView wrapper function.
gv_empty( $value, $zero_is_empty=true, $allow_string_booleans=true)
Is the value empty?
static has_cap( $caps='', $object_id=null, $user_id=null)
Alias of GravityView_Roles_Capabilities::has_cap()