Home › Forums › Legacy Support › 4.0 Bugs & Issues › leaderboard
- This topic has 35 replies, 3 voices, and was last updated 3 years, 8 months ago by
MrVibe.
-
AuthorPosts
-
May 25, 2021 at 5:42 am #358903
Ernesto Lee
ParticipantIs it possible to show course leaderboard based on all quiz taken and present on similar UI like this? Instead of individual quiz. https://share.getcloudapp.com/lluNjXKE @alex, please i need your attentionMay 26, 2021 at 3:17 pm #359174Anshuman Sahu
KeymasterCurrently exact is not available . But this can be seen in course -> statistics tab . You can choose student name and marks and then can generate stats . After this you can click on marks column to sort it.May 28, 2021 at 4:23 pm #359464Ernesto Lee
Participantplease refer this: https://wplms.io/support/forums/topic/course-leaderboard/ i think we can achieve this too: https://share.getcloudapp.com/lluNjXKE code is already there. just little modification i thinkMay 29, 2021 at 2:45 pm #359565Anshuman Sahu
KeymasterWell that data is already present in the stats data and we used the same query in that shortcode . You can as well use this code : https://wplms.io/support/forums/topic/course-leaderboard/#post-203406 then this shortcode [course_leaderboard course=course-id] replace your course-id with your course id .May 29, 2021 at 5:11 pm #359577Ernesto Lee
Participanti know all of this. i tested this code it is not working. can you test this code in your machine and then revert back with output???May 31, 2021 at 2:47 pm #359722Anshuman Sahu
KeymasterOk there is one more parameter there in the shortcode. [course-leaderboard count="20" course="50"] where 50 is course id and count = 20 is number of items to show.May 31, 2021 at 6:35 pm #359758Ernesto Lee
Participantif i want to show all courses top 10 leaderboard data then?June 1, 2021 at 2:16 pm #359861Anshuman Sahu
KeymasterIt already shows list students sorted by score (course marks ) just change the count param : count="10"[course-leaderboard count="10' course="50"]
June 1, 2021 at 6:36 pm #359903Ernesto Lee
Participantno you do not understand [course-leaderboard count="10' course="50"] course id = 50 number of people in the course to be appear for ranking: 10 ---- the issue is it shows only 1 course data. suppose we pass course-id-50 then it shows top 10 people rank in course id 50. ---- 1- i want to show the all course 200 course top 10 guys??? how is that possible. 2- i want to show this shortcode i all courses >> course description. this code limitation is i have to pass course id. i want if i place this code in course description. it should fetch the current course id. i dont want to pass the id manually in every shortcode. [course-leaderboard count="10' course=" current course id taken automatically"] please revise the shortcode.June 2, 2021 at 12:22 am #359923MrVibe
Keymasterwhen you say : 1. i want to show the all course 200 course top 10 guy <-- do you mean we have to sum all the scores of courses completed by all the students and then rank them ? Or we just show the top 10 from the maximum marks achieved by students in any course. 2. this is possible, but we need to know if you are using WPLMS V4 layout or v3 layouts becuase the asnwer will differ according to thatJune 2, 2021 at 6:14 am #359939Ernesto Lee
ParticipantFor 2 question. i am using wplms 4. workflow: i will put the shortcode in the single course page area using elementor for course layout design. it should show the current opened single course related course leaderboard. or here in tab: https://share.getcloudapp.com/OAuQzkoxJune 2, 2021 at 9:54 pm #360081MrVibe
Keymasterok, this is possible , sharing code in next reply.June 2, 2021 at 10:04 pm #360083MrVibe
Keymasteradd_filter('wplms_get_course_tabs',function($tabs){ $tabs['leaderboard'] = 'Leaderboard'; return $tabs; }); add_filter('wplms_course_tab_data',function($data,$body,$course_id){ if($body['tab'] == 'leaderboard'){ ob_start(); do_shortcode('YOUR SHORTCODE'); $data = ob_get_clean(); } return $data; },10,3); --- This filter is missing in orignal code, added in update : wplms_plugin/includes/vibe-course-module/includes/api/class-student-controller.php line 990 add this link : return new WP_REST_Response( array('status'=>1,'data'=>apply_filters('wplms_course_tab_data','',$body,$course_id)), 200 );June 3, 2021 at 5:08 pm #360222Ernesto Lee
Participantthis is the shortcode [course-leaderboard count=”10′ course=” current course id taken automatically”] in your current code https://share.getcloudapp.com/ApuzNL4v or [course-leaderboard count="10'] i should write this without course id???? i am using this shortcode add_shortcode(‘course_leaderboard’,function ($atts,$content=null){ ob_start(); global $wpdb; if(!isset($atts[‘count’])){ $atts[‘count’] =10; } $students = $wpdb->get_results($wpdb->prepare(” SELECT pm.meta_key,pm.meta_value FROM {$wpdb->postmeta} AS pm LEFT JOIN {$wpdb->posts} as p ON pm.post_id = p.ID WHERE p.post_status = %s AND p.post_type = %s AND p.ID = %d AND pm.meta_key REGEXP ‘^[0-9]+$’ ORDER BY pm.meta_value DESC LIMIT 0,{$atts[‘count’]} “,’publish’,’course’,$atts[‘course’])); if(!empty($students)){ echo ‘- ’;
foreach ($students as $key => $stu) {
$student = get_user_by(‘id’,$stu->meta_key);
if(!empty($student) && !is_wp_error($student)){
echo ‘
- <span style=”width: 50% !important;display: inline-block; font-size: 18px;”>’.bp_core_get_user_displayname($student->ID).'</span><span style=”width: 50% !important;display: inline-block; font-size: 18px;”>’.$stu->meta_value.'</span> ’; } } echo ‘
June 4, 2021 at 2:56 pm
#360363

Keymaster
Well you have to add the course id to it , its necessary .
Author
Posts
- The topic ‘leaderboard’ is closed to new replies.