Units and Total duration

Home Forums Legacy Support Support queries How-to & Troubleshooting Units and Total duration

Viewing 11 posts - 16 through 26 (of 26 total)
  • Author
    Posts
  • #50877
    H.K. Latiyan
    Participant
    Try 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; }
    #56055
    ateya3d
    Spectator
    Hello 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 HOURS  
    #56216
    MrVibe
    Keymaster
    In 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.
    #56249
    ateya3d
    Spectator
    Hello 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 cooperation
    #56411
    Anshuman Sahu
    Keymaster
    In 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 );

    #56449
    ateya3d
    Spectator
    after last modification the total hours changed from 13.5833333333 Hours to 12 Hours
    #56641
    Anshuman Sahu
    Keymaster
    Working fine at my text setup . Please check : http://screencast-o-matic.com/watch/cDih21ivyi
    #56690
    ateya3d
    Spectator
    not working fine for me what can i do ??
    #56849
    Anshuman Sahu
    Keymaster
    Well 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 );
    #282216
    kalantor
    Participant
    Hello can you give this code like tip or trick with working conditions on 3.9x
    #282227
    Diana
    Participant
    please create your own topic and do explain what the issue is Closing this topic
Viewing 11 posts - 16 through 26 (of 26 total)
  • The topic ‘Units and Total duration’ is closed to new replies.