GravityView  2.17
The best, easiest way to display Gravity Forms entries on your website.
gquiz_is_pass.php
Go to the documentation of this file.
1 <?php
2 /**
3  * Display Gravity Forms Quiz value Pass/Fail
4  *
5  * @package GravityView
6  * @subpackage GravityView/templates/fields
7  */
8 
10 
11 $field = $gravityview_view->getCurrentField();
12 
13 // If there's no grade, don't continue
14 if( gv_empty( $field['value'], false, false ) ) {
15  return;
16 }
17 
18 // Check if grading is enabled for the form. If not set, default to false.
19 $grading_type_enabled = !empty( $field['form']['gravityformsquiz']['grading'] ) ? $field['form']['gravityformsquiz']['grading'] : 'none';
20 
21 if( 'passfail' === $grading_type_enabled ) {
22 
23  // By default, the field value is "1" for Pass and "0" for Fail. We want the text.
24  echo GFCommon::replace_variables( '{quiz_passfail}', $gravityview_view->getForm(), $gravityview_view->getCurrentEntry() );
25 
26 } elseif( GVCommon::has_cap( 'gravityforms_edit_forms' ) ) {
27  $grade_type = __( 'Pass/Fail', 'gk-gravityview' );
28  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='.$gravityview_view->getFormId() ) . '">', '</a>' );
29 }
static getInstance( $passed_post=NULL)
$gravityview_view
if(gv_empty( $field['value'], false, false)) $grading_type_enabled
$field
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()