Exclude unlimited time quiz from duration

Home Forums Legacy Support Support queries How-to & Troubleshooting Exclude unlimited time quiz from duration

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #130920
    dantwah
    Spectator
    Hi! I am using this tip: https://vibethemes.com/documentation/wplms/knowledge-base/show-number-of-units-and-total-duration-of-units-in-course-details/ to show the total unit + quiz time in the course details section. Now some instructors want to have quizes with unlimited time, if they set this at 9999 each quiz adds at least 9999 seconds to the total duration. This is not representative. So, I would like to exclude quizes that have a duration of 9999 from the duration of the course. How can this be fixed? Kind regards
    #131035
    H.K. Latiyan
    Participant
    Hi, You can simply edit the code and add a condition for 9999 duration. Bellow is the updated code for this case: add_filter('wplms_course_details_widget','wplms_show_unit_count_and_time'); function wplms_show_unit_count_and_time($course_details){     $course_id = get_the_ID();     $units=bp_course_get_curriculum_units($course_id);     $course_details['units'] = '<li><i class="icon-grid-alt"></i>'.count($units).' Units</li>';     $duration = $total_duration = 0;     foreach($units as $unit){         $duration = get_post_meta($unit,'vibe_duration',true);         if(get_post_type($unit)=='unit'){            $unit_duration_parameter = apply_filters('vibe_unit_duration_parameter',60,$unit);         }elseif(get_post_type($unit)=='quiz'){            $unit_duration_parameter = apply_filters('vibe_quiz_duration_parameter',60,$unit);         }                  if($duration < 9999){           $total_duration =  $total_duration + $duration*$unit_duration_parameter;         }      }                   $course_details['units_duration'] = '<li><i class="icon-clock-1"></i>'.tofriendlytime(( $total_duration)).'</li>';      return $course_details; }
    #131137
    dantwah
    Spectator
    Thanks works like charm!
Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Exclude unlimited time quiz from duration’ is closed to new replies.