Home › Forums › Legacy Support › Support queries › How-to & Troubleshooting › Units and Total duration
- This topic has 25 replies, 6 voices, and was last updated 3 years, 8 months ago by Diana.
-
AuthorPosts
-
May 30, 2016 at 6:27 am #50877H.K. LatiyanParticipantTry using this code. 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); $unit_text = translate(' Units','vibe-customtypes'); if(defined('ICL_LANGUAGE_CODE')){ switch(ICL_LANGUAGE_CODE){ case 'fr': $unit_text='conférences'; break; case 'en': $unit_text='lectures'; break; case 'ar': $unit_text='محاضرة'; break; } } $hours_text = ' Hours'; if(defined('ICL_LANGUAGE_CODE')){ switch(ICL_LANGUAGE_CODE){ case 'fr': $hours_text='Hours in french'; break; case 'en': $hours_text='Hours in english'; break; case 'ar': $hours_text='Hours in arabic'; break; } } $course_details['units'] = '<li><i class="icon-grid-alt"></i>'.count($units).' '.$unit_text.'</li>'; $duration = 0; foreach($units as $unit){ $unit_duration_parameter = 3600; $duration = $duration + ($unit_duration_parameter * get_post_meta($unit,'vibe_duration',true)); } $course_details['units_duration'] = '<li><i class="icon-clock-1"></i>'.$duration.' '.$hours_text.'</li>'; return $course_details; }July 1, 2016 at 3:19 pm #56055ateya3dSpectatorHello sorry for delay in replay i have a 60 hpur course after apply the last code i get it if i used the lecture time parameter in Minuts i get it 12960000 HOURS if i used the lecture time parameter in Hours i get it 216000 HOURSJuly 2, 2016 at 12:57 pm #56216MrVibeKeymasterIn above code pasted by latiyan. Change this : $unit_duration_parameter = 3600; $duration = $duration + ($unit_duration_parameter * get_post_meta($unit,'vibe_duration',true)); to this : $unit_duration_parameter = apply_filters('vibe_unit_duration_parameter',3600,$unit); $duration = $duration + ($unit_duration_parameter * get_post_meta($unit,'vibe_duration',true))/3600; Let me know if this does not help.July 2, 2016 at 7:01 pm #56249ateya3dSpectatorHello the code work good but the hours lo like this 13.5833333333 Hours i want the Hours to be if 13.5833333333 like this 14.0 or 14 also hide Units and Total duration of units if no any units defined or assigned to the course Thanks for your cooperationJuly 4, 2016 at 12:37 pm #56411Anshuman SahuKeymasterIn the above suggestion there is a little addition .Please add a line after above two lines t as :
$unit_duration_parameter = apply_filters('vibe_unit_duration_parameter',3600,$unit);
$duration = $duration + ($unit_duration_parameter * get_post_meta($unit,'vibe_duration',true))/3600; $duration = round($duration );
July 4, 2016 at 3:09 pm #56449ateya3dSpectatorafter last modification the total hours changed from 13.5833333333 Hours to 12 HoursJuly 5, 2016 at 2:07 pm #56641Anshuman SahuKeymasterWorking fine at my text setup . Please check : http://screencast-o-matic.com/watch/cDih21ivyiJuly 5, 2016 at 4:50 pm #56690ateya3dSpectatornot working fine for me what can i do ??July 6, 2016 at 2:34 pm #56849Anshuman SahuKeymasterWell it seems like the round function is not working well in your site but working fine at my site . so lets try the php ceil function . If gives upper value of the integer . Try changing this line : $duration = round($duration ); to this : $duration = ceil($duration );August 12, 2020 at 7:30 am #282216kalantorParticipantHello can you give this code like tip or trick with working conditions on 3.9xAugust 12, 2020 at 8:07 am #282227DianaParticipantplease create your own topic and do explain what the issue is Closing this topic -
AuthorPosts
- The topic ‘Units and Total duration’ is closed to new replies.