GravityView  2.17
The best, easiest way to display Gravity Forms entries on your website.
field-gquiz_grade-html.php
Go to the documentation of this file.
1 <?php
2 /**
3  * The default quiz grade 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 $value = $gravityview->value;
15 $form = $gravityview->view->form->form;
16 
17 // If there's no grade, don't continue
18 if ( gv_empty( $value, false, false ) ) {
19  return;
20 }
21 
22 // Check if grading is enabled for the form. If not set, default to false.
23 $grading_type_enabled = ! empty( $form['gravityformsquiz']['grading'] ) ? $form['gravityformsquiz']['grading'] : 'none';
24 
25 if ( 'letter' === $grading_type_enabled ) {
26  echo $value;
27 } elseif ( GVCommon::has_cap( 'gravityforms_edit_forms' ) ) {
28  $grade_type = __( 'Letter', 'gk-gravityview' );
29  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>' );
30 }
if(! isset( $gravityview)||empty( $gravityview->template)) $value
The default quiz grade field output template.
if(gv_empty( $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()