diff --git a/controllers/reviews.php b/controllers/reviews.php index 431eac6..26480ff 100644 --- a/controllers/reviews.php +++ b/controllers/reviews.php @@ -20,26 +20,29 @@ public static function manage() { } // list reviews - $course_filter = $status_filter = ''; + $course_filter = $status_filter = $other_filter_sql = ''; + $other_filter_sql = apply_filters('namaste-filter-reviews', $other_filter_sql); if(!empty($_GET['course_id'])) $course_filter = $wpdb->prepare(" AND course_id=%d ", intval($_GET['course_id'])); if(isset($_GET['status']) and $_GET['status'] !== '') $status_filter = $wpdb->prepare(" AND is_approved=%d ", intval($_GET['status'])); $offset = empty($_GET['offset']) ? 0 : intval($_GET['offset']); - $limit = 20; + $page_limit = 20; - $reviews = $wpdb->get_results($wpdb->prepare("SELECT tR.*, tP.post_title as course_name, tU.display_name as user_name + $reviews = $wpdb->get_results($wpdb->prepare("SELECT SQL_CALC_FOUND_ROWS tR.*, tP.post_title as course_name, tU.display_name as user_name FROM ".NAMASTE_COURSE_REVIEWS." tR JOIN {$wpdb->posts} tP ON tP.ID = tR.course_id AND tP.post_type = 'namaste_course' JOIN {$wpdb->users} tU ON tU.ID = tR.student_id - WHERE 1 $course_filter $status_filter ORDER BY tR.id DESC LIMIT %d, %d", $offset, $limit)); - - // add filter to allow Pro to reduce by class - $reviews = apply_filters('namaste-filter-reviews', $reviews); + WHERE 1 $course_filter $status_filter $other_filter_sql ORDER BY tR.id DESC LIMIT %d, %d", $offset, $page_limit)); + + $count = $wpdb->get_var("SELECT FOUND_ROWS()"); // select courses for the drop-down $_course = new NamasteLMSCourseModel(); $courses = $_course->select(); + $date_format = get_option('date_format'); + $time_format = get_option('date_format'); + if(@file_exists(get_stylesheet_directory().'/namaste/reviews.html.php')) include get_stylesheet_directory().'/namaste/reviews.html.php'; else include(NAMASTE_PATH."/views/reviews.html.php"); } // end manage @@ -64,13 +67,7 @@ public static function submit($vars) { public static function display_form($course_id) { $course_id = intval($course_id); - $rating_options = [ - 1 => __('Poor', 'namaste'), - 2 => __('Accedptable', 'namaste'), - 3 => __('Average', 'namaste'), - 4 => __('Good', 'namaste'), - 5 => __('Great', 'namaste'), - ]; + $rating_options = self :: get_rating_options(); $content = ''; $editor_id = 'namaste_review_course_'.$course_id; @@ -93,13 +90,51 @@ public static function display_form($course_id) { } // end display_form // shows the reviews on a course - public static function list_reviews() { + public static function list_reviews($course_id, $number = 0, $show = 'user_login') { + global $wpdb; + + $limit_sql = $number ? " LIMIT ".intval($number) : ''; + + $reviews = $wpdb->get_results($wpdb->prepare("SELECT SQL_CALC_FOUND_ROWS tR.*, tP.post_title as course_name, tU.$show as user_name + FROM ".NAMASTE_COURSE_REVIEWS." tR JOIN {$wpdb->posts} tP ON tP.ID = tR.course_id AND tP.post_type = 'namaste_course' + JOIN {$wpdb->users} tU ON tU.ID = tR.student_id + WHERE tR.course_id=%d AND is_approved=1 ORDER BY tR.id DESC $limit_sql", intval($course_id))); + + $date_format = get_option('date_format'); + $time_format = get_option('date_format'); + + if(@file_exists(get_stylesheet_directory().'/namaste/list-reviews.html.php')) include get_stylesheet_directory().'/namaste/list-reviews.html.php'; + else include(NAMASTE_PATH."/views/list-reviews.html.php"); } // end list_reviews + // a helper to display the stars for a review + public static function stars($rating) { + $rating_options = self :: get_rating_options(); + + $output = ''; + + foreach($rating_options as $r => $option) { + $class = $r <= $rating ? 'filled' : 'empty'; + $output .= ''; + } + + return $output; + } // end stars() + // safety private static function prepare_vars(&$vars) { $vars['course_id'] = intval($vars['course_id']); $vars['rating'] = intval($vars['namaste_rating']); $vars['review'] = wp_kses_post($vars['review']); } + + private static function get_rating_options() { + return [ + 1 => __('Poor', 'namaste'), + 2 => __('Accedptable', 'namaste'), + 3 => __('Average', 'namaste'), + 4 => __('Good', 'namaste'), + 5 => __('Great', 'namaste'), + ]; + } } \ No newline at end of file diff --git a/controllers/shortcodes.php b/controllers/shortcodes.php index 14b8742..149a59d 100644 --- a/controllers/shortcodes.php +++ b/controllers/shortcodes.php @@ -888,8 +888,19 @@ public static function review_course($atts, $contents = '') { return $content; } // end review_course - // list reviews + // list reviews - for now just list them all without navigation. + // $atts[number] - show last number of reviews public static function course_reviews($atts) { - return "NYI"; + $course_id = empty($atts['course_id']) ? 0 : intval($atts['course_id']); + if(empty($course_id)) return ""; + + $number = empty($atts['number']) ? 0 : intval($atts['number']); + $show = empty($atts['show']) ? 'user_login' : sanitize_text_field($atts['show']); + if(!in_array($show, ['user_login', 'display_name'])) $show = 'user_login'; + + ob_start(); + NamasteLMSReviews :: list_reviews($course_id, $number, $show); + $content = ob_get_clean(); + return $content; } } \ No newline at end of file diff --git a/css/main.css b/css/main.css index 1f6c1da..40f78a1 100755 --- a/css/main.css +++ b/css/main.css @@ -123,6 +123,14 @@ cursor: pointer; } +div.namaste-review { + border: 1pt solid #888888; + padding: 1em; + margin: 0.5em; + margin-bottom: 0.7em; + box-shadow: 0.5em 0.5em 0.5em #888888; +} + [role="region"][aria-labelledby][tabindex] { width: 100%; height: 100%; diff --git a/namaste.php b/namaste.php index 0701dd8..bbe1cc6 100755 --- a/namaste.php +++ b/namaste.php @@ -4,7 +4,7 @@ Plugin URI: http://namaste-lms.org Description: Learning Management System for WordPress. Courses, modules, lessons, gradebook, and everything you need. Author: Kiboko Labs -Version: 2.5.4.2 +Version: 2.5.5 Author URI: http://calendarscripts.info/ License: GPLv2 or later Text Domain: namaste diff --git a/namaste.pot b/namaste.pot index ed894bf..bae24e9 100644 --- a/namaste.pot +++ b/namaste.pot @@ -129,6 +129,26 @@ msgstr "" msgid "You can download only your own solutions." msgstr "" +#: controllers/reviews.php:133 +msgid "Poor" +msgstr "" + +#: controllers/reviews.php:134 +msgid "Accedptable" +msgstr "" + +#: controllers/reviews.php:135 +msgid "Average" +msgstr "" + +#: controllers/reviews.php:136 +msgid "Good" +msgstr "" + +#: controllers/reviews.php:137 +msgid "Great" +msgstr "" + #: controllers/shortcodes.php:42 msgid "Completed" msgstr "" @@ -229,6 +249,14 @@ msgstr "" msgid "Frozen" msgstr "" +#: controllers/shortcodes.php:873 +msgid "Your review has been accepted." +msgstr "" + +#: controllers/shortcodes.php:874 +msgid "Your review has been received and is awaiting moderation." +msgstr "" + #: controllers/shortcodes.php:23 msgid "This lesson has been completed." msgstr "" @@ -261,51 +289,51 @@ msgstr "" msgid "Advanced Reports" msgstr "" -#: models/course-model.php:162 +#: models/course-model.php:166 msgid "For advanced reports on this course, click here." msgstr "" -#: models/course-model.php:164 +#: models/course-model.php:168 msgid "You can get advanced reports on this course if you install the Namaste! Reports plugin." msgstr "" -#: models/course-model.php:265 +#: models/course-model.php:274 msgid "You are enrolled in this course. Check \"My courses\" link in your dashboard to see the lessons and to-do list" msgstr "" -#: models/course-model.php:315 +#: models/course-model.php:324 msgid "Received %d points for completing course \"%s\"." msgstr "" -#: models/course-model.php:329 +#: models/course-model.php:338 msgid "Completed course \"%s\"" msgstr "" -#: models/course-model.php:393 +#: models/course-model.php:402 msgid "You cannot enroll this course - other courses have to be completed first." msgstr "" -#: models/course-model.php:410 +#: models/course-model.php:419 msgid "Enrolled in course %s. Status: %s" msgstr "" -#: models/course-model.php:476 +#: models/course-model.php:485 msgid "Enroll for %1$s %2$s" msgstr "" -#: models/course-model.php:477 +#: models/course-model.php:486 msgid "Click to Enroll" msgstr "" -#: models/course-model.php:494 +#: models/course-model.php:503 msgid "Payment for course" msgstr "" -#: models/course-model.php:513 +#: models/course-model.php:522 msgid "Buy Enrollment" msgstr "" -#: models/course-model.php:563 +#: models/course-model.php:572 msgid "These courses should be completed before you can enroll:" msgstr "" @@ -453,123 +481,127 @@ msgstr "" msgid "Before accessing this module you must complete the following modules:" msgstr "" -#: models/namaste-model.php:297 +#: models/namaste-model.php:314 msgid "Namaste! LMS" msgstr "" -#: models/namaste-model.php:298 +#: models/namaste-model.php:315 msgid "To Do" msgstr "" -#: models/namaste-model.php:305 +#: models/namaste-model.php:322 msgid "Assignments" msgstr "" -#: models/namaste-model.php:306 +#: models/namaste-model.php:323 msgid "Students" msgstr "" -#: models/namaste-model.php:308 +#: models/namaste-model.php:325 msgid "Certificates" msgstr "" -#: models/namaste-model.php:309 +#: models/namaste-model.php:326 msgid "Students Earned Certificate" msgstr "" -#: models/namaste-model.php:311 +#: models/namaste-model.php:332 +msgid "Student Reviews" +msgstr "" + +#: models/namaste-model.php:336 msgid "Gradebook" msgstr "" -#: models/namaste-model.php:312 +#: models/namaste-model.php:337 msgid "Settings" msgstr "" -#: models/namaste-model.php:315 +#: models/namaste-model.php:341 msgid "xAPI / Tin Can" msgstr "" -#: models/namaste-model.php:318 +#: models/namaste-model.php:344 msgid "Help" msgstr "" -#: models/namaste-model.php:319 +#: models/namaste-model.php:345 msgid "Namaste! Plugins & API" msgstr "" -#: models/namaste-model.php:319 +#: models/namaste-model.php:345 msgid "Plugins & API" msgstr "" -#: models/namaste-model.php:322 +#: models/namaste-model.php:348 msgid "Student Lessons" msgstr "" -#: models/namaste-model.php:324 +#: models/namaste-model.php:350 msgid "Send note" msgstr "" -#: models/namaste-model.php:325 +#: models/namaste-model.php:351 msgid "Submit solution" msgstr "" -#: models/namaste-model.php:326 +#: models/namaste-model.php:352 msgid "View solutions" msgstr "" -#: models/namaste-model.php:327 +#: models/namaste-model.php:353 msgid "View all solutions" msgstr "" -#: models/namaste-model.php:328 +#: models/namaste-model.php:354 msgid "View Certificate" msgstr "" -#: models/namaste-model.php:329 +#: models/namaste-model.php:355 msgid "Download solution" msgstr "" -#: models/namaste-model.php:330 +#: models/namaste-model.php:356 msgid "Multi user configuration" msgstr "" -#: models/namaste-model.php:331 +#: models/namaste-model.php:357 msgid "Mass enroll students" msgstr "" -#: models/namaste-model.php:332 +#: models/namaste-model.php:358 msgid "Shortcode generator" msgstr "" -#: models/namaste-model.php:347 +#: models/namaste-model.php:373 msgid "My Courses" msgstr "" -#: models/namaste-model.php:348 +#: models/namaste-model.php:374 msgid "My Certificates" msgstr "" -#: models/namaste-model.php:349 +#: models/namaste-model.php:375 msgid "My Gradebook" msgstr "" -#: models/namaste-model.php:493 +#: models/namaste-model.php:522 msgid "You need to be logged in to access this lesson." msgstr "" -#: models/namaste-model.php:497 +#: models/namaste-model.php:526 msgid "You can enroll in this course from your student dashboard. You need to be logged in." msgstr "" -#: models/namaste-model.php:501 +#: models/namaste-model.php:530 msgid "You need to be logged in to access this module." msgstr "" -#: models/namaste-model.php:694 +#: models/namaste-model.php:723 msgid "You can also buy access to this {{{item}}} with {{{credits}}} virtual credits from your balance. You currently have [moolamojo-balance] credits total." msgstr "" -#: models/namaste-model.php:724 +#: models/namaste-model.php:753 msgid "

Course: {{{course-link}}}

" msgstr "" @@ -825,35 +857,43 @@ msgstr "" msgid "Automatically grade this course based on its lesson grades (learn how this works)" msgstr "" -#: views/course-meta-box.php:120 +#: views/course-meta-box.php:128 +msgid "Use the shortcode %s to show the submitted reviews on the course:" +msgstr "" + +#: views/course-meta-box.php:128 +msgid "Pass the attribute %1$s to show only the latest X reviews on this course. The attribute %2$s can contain values %3$s or %4$s to define whether you will display the username of the reviewer or their full name. " +msgstr "" + +#: views/course-meta-box.php:137 msgid "The same shortcode to use outside of the course page is %s" msgstr "" -#: views/course-meta-box.php:122 +#: views/course-meta-box.php:139 msgid "The shortcode %s on the other hand will display just the number of lessons in the course." msgstr "" -#: views/course-meta-box.php:125 +#: views/course-meta-box.php:142 msgid "Similar to the above, the shortcode %1$s will display the modules in this course and the shortcode %2$s will display the number of modules in it." msgstr "" -#: views/course-meta-box.php:131 +#: views/course-meta-box.php:148 msgid "The shortcode %s can be used to display conditional content to logged in or non-logged in users like this: %s. To use it outside of the course page pass also the attribute %s" msgstr "" -#: views/course-meta-box.php:131 +#: views/course-meta-box.php:148 msgid "Content enrolled users" msgstr "" -#: views/course-meta-box.php:131 +#: views/course-meta-box.php:148 msgid "Content for not enrolled users" msgstr "" -#: views/course-meta-box.php:136 +#: views/course-meta-box.php:153 msgid "You can limit the access to this course also by class / group." msgstr "" -#: views/course-meta-box.php:138 +#: views/course-meta-box.php:155 msgid "If you upgrade to PRO you will be able to assign courses to classes and restrict access based on class, have different managers for different classes, and a lot more." msgstr "" @@ -965,31 +1005,59 @@ msgstr "" msgid "When someone completes this course join them in the following BuddyPress group:" msgstr "" -#: views/course-meta-box.php:117 +#: views/course-meta-box.php:114 +msgid "Student Feedback" +msgstr "" + +#: views/course-meta-box.php:116 +msgid "Accept reviews from students after completing the course." +msgstr "" + +#: views/course-meta-box.php:118 +msgid "Hold reviews for moderation" +msgstr "" + +#: views/course-meta-box.php:122 +msgid "Use the following shortcode to include the review feature on the course page:" +msgstr "" + +#: views/course-meta-box.php:124 +msgid "The feature will be shown only when appropriate - i.e. after completing the course and only when the student has not already rated it." +msgstr "" + +#: views/course-meta-box.php:125 +msgid "You can enclose content / text in the shortcode. In that case the text will be shown conditionally when the whole rating form is displayed. Example:" +msgstr "" + +#: views/course-meta-box.php:126 +msgid "Thank you for competing this course! Please rate it now!" +msgstr "" + +#: views/course-meta-box.php:134 msgid "Shortcodes" msgstr "" -#: views/course-meta-box.php:119 +#: views/course-meta-box.php:136 msgid "inside the course content to display what the student needs to do to complete the course." msgstr "" -#: views/course-meta-box.php:121 +#: views/course-meta-box.php:138 msgid "will display the lessons in the course." msgstr "" -#: views/course-meta-box.php:121 +#: views/course-meta-box.php:138 msgid "It allows more advanced configurations explained on the " msgstr "" -#: views/course-meta-box.php:121 +#: views/course-meta-box.php:138 msgid "help page." msgstr "" -#: views/course-meta-box.php:128 +#: views/course-meta-box.php:145 msgid "inside the course content to display its current status for the logged in user." msgstr "" -#: views/course-meta-box.php:133 +#: views/course-meta-box.php:150 msgid "Did you know?" msgstr "" @@ -1605,6 +1673,10 @@ msgstr "" msgid "To-do Test/Exam:" msgstr "" +#: views/list-reviews.html.php:3 +msgid "%1$s on %2$s" +msgstr "" + #: views/manage-students.php:128 msgid "None" msgstr "" @@ -1889,7 +1961,7 @@ msgstr "" msgid "To edit this page you need to enable some roles to manage LMS on the Namaste Settings page." msgstr "" -#: views/multiuser.html.php:70 +#: views/multiuser.html.php:75 msgid "If you have Namaste! PRO all the above settings will also comply with any class (user group) limitations." msgstr "" @@ -1982,46 +2054,58 @@ msgid "No access to gradebook" msgstr "" #: views/multiuser.html.php:51 -msgid "Settings page access:" +msgid "Reviews access:" msgstr "" #: views/multiuser.html.php:52 -msgid "Manage settings" +msgid "Access reviews" msgstr "" #: views/multiuser.html.php:53 -msgid "No access to manage settings" +msgid "No access to reviews" msgstr "" #: views/multiuser.html.php:56 -msgid "Help page access:" +msgid "Settings page access:" msgstr "" #: views/multiuser.html.php:57 -msgid "View Help page" +msgid "Manage settings" msgstr "" #: views/multiuser.html.php:58 -msgid "No access to Help page" +msgid "No access to manage settings" msgstr "" #: views/multiuser.html.php:61 -msgid "Plugins page access:" +msgid "Help page access:" msgstr "" #: views/multiuser.html.php:62 -msgid "Access Plugins page" +msgid "View Help page" msgstr "" #: views/multiuser.html.php:63 -msgid "No access to Plugins page" +msgid "No access to Help page" +msgstr "" + +#: views/multiuser.html.php:66 +msgid "Plugins page access:" +msgstr "" + +#: views/multiuser.html.php:67 +msgid "Access Plugins page" msgstr "" #: views/multiuser.html.php:68 +msgid "No access to Plugins page" +msgstr "" + +#: views/multiuser.html.php:73 msgid "Don't display 'My Courses' link in the dashboard." msgstr "" -#: views/multiuser.html.php:72 +#: views/multiuser.html.php:77 msgid "Save configuration for this role" msgstr "" @@ -2565,6 +2649,62 @@ msgstr "" msgid "Save Exam Options" msgstr "" +#: views/review-course.html.php:3 +msgid "Rate this course:" +msgstr "" + +#: views/review-course.html.php:14 +msgid "Your review" +msgstr "" + +#: views/review-course.html.php:20 +msgid "Send Review" +msgstr "" + +#: views/reviews.html.php:1 +msgid "Student Reviews on Courses" +msgstr "" + +#: views/reviews.html.php:6 +msgid "Filter by course" +msgstr "" + +#: views/reviews.html.php:7 +msgid "All courses" +msgstr "" + +#: views/reviews.html.php:13 +msgid "Filter by status" +msgstr "" + +#: views/reviews.html.php:15 +msgid "Approved" +msgstr "" + +#: views/reviews.html.php:16 +msgid "Pending approval" +msgstr "" + +#: views/reviews.html.php:19 +msgid "Filter courses" +msgstr "" + +#: views/reviews.html.php:31 +msgid "Rating and Review" +msgstr "" + +#: views/reviews.html.php:33 +msgid "Action" +msgstr "" + +#: views/reviews.html.php:48 +msgid "Approve" +msgstr "" + +#: views/reviews.html.php:77 +msgid "No reviews found." +msgstr "" + #: views/search-form.html.php:3 msgid "Search in Courses and Lessons" msgstr "" @@ -2577,10 +2717,6 @@ msgstr "" msgid "in" msgstr "" -#: views/search-form.html.php:7 -msgid "All courses" -msgstr "" - #: views/search-form.html.php:15 msgid "All lessons" msgstr "" @@ -2925,10 +3061,6 @@ msgstr "" msgid "Attachments:" msgstr "" -#: views/view-solutions.php:56 -msgid "Approved" -msgstr "" - #: views/xapi-options.html.php:4 msgid "xAPI / Tin Can integration requires installing the free WP Experience API plugin. Your learning record store options should be saved there. On this page you only set up which activities from your LMS will go into the record store." msgstr "" diff --git a/readme.txt b/readme.txt index f7e3d14..b49db7b 100755 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Contributors: prasunsen, wakeop Tags: LMS, learning, courses, lessons, ILE, wpmu, multisite, buddypress Requires at least: 4.2 Tested up to: 5.8 -Stable tag: trunk +Stable tag: 2.5.5 License: GPL2 Namaste! LMS is a learning management system for WordPress. Supports unlimited number of courses, lessons, assignments, students etc. You can create various rules for course and lesson access and completeness based on assignment completion, test results, or manual admin approval. @@ -117,11 +117,12 @@ If you want to add the breadcrumb navigation to the theme see how to do it [here == Changelog == -= Version 2.5.4 = += Version 2.5.5 = - Adjusted access control to module pages: their contents should not be visible if you are not enrolled in the course or if there are unsatisfied module pre-requisites. - Added shortcode [namaste-breadcrumb] to display a breadcrumb style hierarchical navigation on lesson and module pages. - Added order by Namaste! points in your main Users page (when using points system is enabled). - Homework assignments now allow being "self approving". For these assignments you will not accept and review solutions from students. Instead, they will mark the homework completed themselves. +- Added option to accept reviews from students on completed course. The reviews with ratings can be shown on the front-end. = Version 2.5 = - Added filters by lesson status for each lesson in Manage Students page. diff --git a/views/course-meta-box.php b/views/course-meta-box.php index 0fde524..52c9c82 100644 --- a/views/course-meta-box.php +++ b/views/course-meta-box.php @@ -111,7 +111,7 @@

-

+

onclick="this.checked ? jQuery('.namaste-review-features').show() : jQuery('.namaste-review-features').hide();"> '> @@ -125,7 +125,7 @@


[namaste-review course_id="ID;?>"][/namaste-review]

-

ID.']" readonly onclick="this.select();">');?>

+

ID.']" readonly onclick="this.select();">');?> %1$s to show only the latest X reviews on this course. The attribute %2$s can contain values %3$s or %4$s to define whether you will display the username of the reviewer or their full name. ', 'namaste'), 'number=X', 'show', 'user_login', 'display_name');?>

 

diff --git a/views/list-reviews.html.php b/views/list-reviews.html.php new file mode 100644 index 0000000..cd10732 --- /dev/null +++ b/views/list-reviews.html.php @@ -0,0 +1,8 @@ + +
+

user_name, date_i18n($date_format.' '.$time_format, strtotime($review->datetime)));?>

+ +

rating);?>rating;?>

+ review));?> +
+ \ No newline at end of file diff --git a/views/reviews.html.php b/views/reviews.html.php index fc1aab4..ca1ac4e 100644 --- a/views/reviews.html.php +++ b/views/reviews.html.php @@ -29,14 +29,49 @@ + - NYI + + + course_name);?> + user_name;?> +

rating);?>rating;?>

+ review));?> + datetime));?> +
+ is_approved):?>" class="button button-primary"> + + + + +
+ + + +

0):?> + + + ($page_limit + $offset)):?> + + +

+ +