@@ -1466,6 +1466,9 @@ public static function get_topic_progress_by_course_id( $course_id, $student_id
14661466 foreach ( $ topics_query ->posts as $ topic_post ) {
14671467 $ topic_id = (int ) $ topic_post ->ID ;
14681468
1469+ $ total_topic_items = 0 ;
1470+ $ total_topic_items_completed = 0 ;
1471+
14691472 $ topic = array (
14701473 'topic_id ' => $ topic_id ,
14711474 'topic_summary ' => $ topic_post ->post_content ,
@@ -1493,8 +1496,6 @@ public static function get_topic_progress_by_course_id( $course_id, $student_id
14931496 'link ' => esc_url_raw ( get_permalink ( $ post_id ) ),
14941497 'title ' => $ content_post ->post_title ,
14951498 'is_completed ' => $ is_completed ,
1496- 'time_limit ' => tutor_utils ()->get_quiz_option ( $ post_id , 'time_limit.time_value ' ),
1497- 'time_type ' => tutor_utils ()->get_quiz_option ( $ post_id , 'time_limit.time_type ' ),
14981499 'label ' => __ ( 'Quiz ' , 'tutor ' ),
14991500 'icon ' => Icon::QUIZ_2 ,
15001501 );
@@ -1515,23 +1516,33 @@ public static function get_topic_progress_by_course_id( $course_id, $student_id
15151516 );
15161517
15171518 } elseif ( tutor ()->zoom_post_type === $ post_type ) {
1519+
1520+ $ zoom_start_date = get_post_meta ($ post_id , '_tutor_zm_start_datetime ' , true );
1521+ $ start_timestamp = $ zoom_start_date ? strtotime ( $ zoom_start_date ) : 0 ;
1522+ $ is_completed = $ start_timestamp && strtotime ('now ' ) > $ start_timestamp ;
15181523 $ topic ['items ' ][] = array (
15191524 'type ' => 'zoom_meeting ' ,
15201525 'id ' => $ post_id ,
15211526 'title ' => $ content_post ->post_title ,
15221527 'link ' => esc_url_raw ( get_permalink ( $ post_id ) ),
15231528 'label ' => __ ( 'Live Class ' , 'tutor ' ),
15241529 'icon ' => Icon::ZOOM ,
1530+ 'is_completed ' => $ is_completed ,
15251531 );
15261532
15271533 } elseif ( tutor ()->meet_post_type === $ post_type ) {
1534+ $ google_end_date = get_post_meta ($ post_id , 'tutor-google-meet-end-datetime ' , true );
1535+ $ end_timestamp = $ google_end_date ? strtotime ( $ google_end_date ) : 0 ;
1536+ $ is_completed = $ end_timestamp && strtotime ('now ' ) > $ end_timestamp ;
1537+
15281538 $ topic ['items ' ][] = array (
15291539 'type ' => 'google_meet ' ,
15301540 'id ' => $ post_id ,
15311541 'title ' => $ content_post ->post_title ,
15321542 'link ' => esc_url_raw ( get_permalink ( $ post_id ) ),
15331543 'label ' => __ ( 'Live Class ' , 'tutor ' ),
15341544 'icon ' => Icon::GOOGLE_MEET ,
1545+ 'is_completed ' => $ is_completed ,
15351546 );
15361547
15371548 } else {
@@ -1555,10 +1566,16 @@ public static function get_topic_progress_by_course_id( $course_id, $student_id
15551566 $ topic ['topic_completed ' ] = false ;
15561567 } else {
15571568 $ topic ['topic_started ' ] = true ;
1569+ $ total_topic_items_completed ++;
15581570 }
15591571 }
1572+
1573+ $ total_topic_items = count ($ contents_query ->posts );
15601574 }
15611575
1576+ $ topic ['topic_completion_percentage ' ] = $ total_topic_items > 0 && $ total_topic_items_completed > 0
1577+ ? (int ) round ( ( $ total_topic_items_completed / $ total_topic_items ) * 100 )
1578+ : 0 ;
15621579 $ topic_list [] = $ topic ;
15631580 }
15641581
0 commit comments