Hi There,
How is it possible to integrate the total Course + Quiz duration into a certificate as a shortcode?
Thanks for your advice.
Best regards,
Michael
@baldamus
This shortcode is already there
Refer:
http://prntscr.com/l567kh
Hi Diana,
Thanks for your answer. Unfortunately that's not the right shortcode. I would like to print the total length of the films, the number of lessons and sessions in the certificate.
They are displayed in the course overview. Is that possible?
Kind regards,
Michael
@baldamus
Yes, it is possible and for that, I have to write a custom shortcode which will fetch all these values.
Will share the code in few hours
Hi Diana,
That's very good news. Thank you very much. Please let me know when and where the new shortcodes will be available.
Kind regards,
Michael
This reply has been marked as private.
This reply has been marked as private.
Hi Diana,
Thank you for the code. Unfortunately, the length is not displayed in the certificate. What am I doing wrong? Please for short support.
Screenshot
Kind regards,
Michael
@baldamus
I guess, I have got the issue. Will update in few hours
Hi Diana,
I´m still waiting for an update. Do you have a bugfix for me?
Kind regards,
Michael
@Bladamus,
Apologies for the delayed response here...
add_shortcode('total_course_duration', 'total_course_duration');
function total_course_duration( $atts, $content = null ) {
extract(shortcode_atts(array(
'field' => '',
'course_id' =>'',
), $atts));
if(!isset($course) || !is_numeric($course)){
$course_id=$_GET['c'];
}
$course_curriculum = bp_course_get_curriculum($course_id);
if(!empty($course_curriculum)){
$duration = 0;
foreach($course_curriculum as $key => $item){
if(is_numeric($item)){
$post_type = get_post_type($item);
if( $post_type == 'unit' && function_exists('bp_course_get_unit_duration')){
$duration += bp_course_get_unit_duration($item);
}else if($post_type == 'quiz' && function_exists('bp_course_get_quiz_duration')){
$duration += bp_course_get_quiz_duration($item);
}
}
}
if(function_exists('tofriendlytime')){
$duration = tofriendlytime($duration);
}
return '<strong>'.$duration.'</strong>';
}
}