lifterlms_template_student_dashboard_my_grades()
Description Description
Source Source
File: includes/functions/llms.functions.templates.dashboard.php
function lifterlms_template_student_dashboard_my_grades() { $student = llms_get_student(); if ( ! $student ) { return; } global $wp_query, $wp_rewrite; $slug = $wp_query->query['my-grades']; // list courses if ( empty( $slug ) || false !== strpos( $slug, $wp_rewrite->pagination_base . '/' ) ) { $per_page = apply_filters( 'llms_sd_grades_courses_per_page', 10 ); $page = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1; $sort = filter_input( INPUT_GET, 'sort', FILTER_SANITIZE_STRING ); if ( ! $sort ) { $sort = 'date_desc'; } $parts = explode( '_', $sort ); $courses = $student->get_courses( array( 'limit' => $per_page, 'skip' => $per_page * ( $page - 1 ), 'orderby' => $parts[0], 'order' => strtoupper( $parts[1] ), ) ); add_filter( 'paginate_links', 'llms_modify_dashboard_pagination_links' ); llms_get_template( 'myaccount/my-grades.php', array( 'courses' => array_map( 'llms_get_post', $courses['results'] ), 'student' => $student, 'sort' => $sort, 'pagination' => array( 'current' => absint( $page ), 'max' => absint( ceil( $courses['found'] / $per_page ) ), ), ) ); remove_filter( 'paginate_links', 'llms_modify_dashboard_pagination_links' ); // show single } else { $course = get_posts( array( 'name' => $slug, 'post_type' => 'course', ) ); $course = array_shift( $course ); if ( $course ) { $course = llms_get_post( $course ); } // get the latest achievement for the course $achievements = LLMS()->achievements()->get_achievements_by_post( $course->get( 'id' ) ); $latest_achievement = false; foreach ( $student->get_achievements( 'updated_date', 'DESC', 'achievements' ) as $achievement ) { if ( in_array( $achievement->get( 'achievement_template' ), $achievements ) ) { $latest_achievement = $achievement; break; } } $last_activity = $student->get_events( array( 'per_page' => 1, 'post_id' => $course->get( 'id' ), ) ); llms_get_template( 'myaccount/my-grades-single.php', array( 'course' => $course, 'student' => $student, 'latest_achievement' => $latest_achievement, 'last_activity' => $last_activity ? strtotime( $last_activity[0]->get( 'updated_date' ) ) : false, ) ); }// End if(). }
Expand full source code Collapse full source code View on GitHub
User Contributed Notes User Contributed Notes
Permalink: