Skip to content

Commit 32f657c

Browse files
authored
Merge pull request #2692 from themeum/completion-percentage-icon-issue
Completion icon issue in student progress modal
2 parents 05333d7 + 8e417f8 commit 32f657c

1 file changed

Lines changed: 5 additions & 16 deletions

File tree

models/CourseModel.php

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,34 +1464,23 @@ public static function get_course_progress_details( $course_id, $student_id ) {
14641464
}
14651465

14661466
foreach ( $topics_query->posts as $topic_post ) {
1467-
$topic_id = (int) $topic_post->ID;
1468-
$total_topic_items = 0;
1469-
$total_topic_items_completed = 0;
1470-
$items = array();
1471-
1472-
$contents_query = tutor_utils()->get_course_contents_by_topic( $topic_id, -1 );
1467+
$topic_id = (int) $topic_post->ID;
1468+
$items = array();
1469+
$completion_percentage = tutor_utils()->count_completed_contents_by_topic( $topic_id, $student_id );
1470+
$contents_query = tutor_utils()->get_course_contents_by_topic( $topic_id, -1 );
14731471

14741472
if ( ! empty( $contents_query ) && $contents_query->have_posts() ) {
14751473
foreach ( $contents_query->posts as $content_post ) {
14761474
$items[] = ( new self() )->build_course_progress_item( $content_post, $student_id, $course_id );
14771475
}
1478-
$total_topic_items = count( $contents_query->posts );
14791476
}
14801477

1481-
$total_topic_items_completed = count(
1482-
array_filter( $items, fn( $item ) => $item['is_completed'] )
1483-
);
1484-
1485-
$percentage = $total_topic_items > 0 && $total_topic_items_completed > 0
1486-
? round( ( $total_topic_items_completed / $total_topic_items ) * 100, 2 )
1487-
: 0;
1488-
14891478
$topic_list[] = array(
14901479
'id' => $topic_id,
14911480
'summary' => $topic_post->post_content,
14921481
'title' => get_the_title( $topic_id ),
14931482
'items' => $items,
1494-
'completion_percentage' => $percentage,
1483+
'completion_percentage' => $completion_percentage['percentage'] ?? 0,
14951484
);
14961485
}
14971486

0 commit comments

Comments
 (0)