|
@@ 993-1006 (lines=14) @@
|
| 990 |
|
* @since 1.9.0 |
| 991 |
|
* @return int $number_of_graded_lessons |
| 992 |
|
*/ |
| 993 |
|
public static function get_graded_lessons_count(){ |
| 994 |
|
|
| 995 |
|
global $wpdb; |
| 996 |
|
|
| 997 |
|
$comment_query_piece[ 'select'] = "SELECT COUNT(*) AS total"; |
| 998 |
|
$comment_query_piece[ 'from'] = " FROM {$wpdb->comments} INNER JOIN {$wpdb->commentmeta} ON ( {$wpdb->comments}.comment_ID = {$wpdb->commentmeta}.comment_id ) "; |
| 999 |
|
$comment_query_piece[ 'where'] = " WHERE {$wpdb->comments}.comment_type IN ('sensei_lesson_status') AND ( wp_commentmeta.meta_key = 'grade')"; |
| 1000 |
|
$comment_query_piece[ 'orderby'] = " ORDER BY {$wpdb->comments}.comment_date_gmt DESC "; |
| 1001 |
|
|
| 1002 |
|
$comment_query = $comment_query_piece['select'] . $comment_query_piece['from'] . $comment_query_piece['where'] . $comment_query_piece['orderby']; |
| 1003 |
|
$number_of_graded_lessons = intval( $wpdb->get_var( $comment_query, 0, 0 ) ); |
| 1004 |
|
|
| 1005 |
|
return $number_of_graded_lessons; |
| 1006 |
|
} |
| 1007 |
|
|
| 1008 |
|
/** |
| 1009 |
|
* Add together all the graded lesson grades |
|
@@ 1014-1028 (lines=15) @@
|
| 1011 |
|
* @since 1.9.0 |
| 1012 |
|
* @return double $sum_of_all_grades |
| 1013 |
|
*/ |
| 1014 |
|
public static function get_graded_lessons_sum(){ |
| 1015 |
|
|
| 1016 |
|
global $wpdb; |
| 1017 |
|
|
| 1018 |
|
$comment_query_piece[ 'select'] = "SELECT SUM({$wpdb->commentmeta}.meta_value) AS meta_sum"; |
| 1019 |
|
$comment_query_piece[ 'from'] = " FROM {$wpdb->comments} INNER JOIN {$wpdb->commentmeta} ON ( {$wpdb->comments}.comment_ID = {$wpdb->commentmeta}.comment_id ) "; |
| 1020 |
|
$comment_query_piece[ 'where'] = " WHERE {$wpdb->comments}.comment_type IN ('sensei_lesson_status') AND ( wp_commentmeta.meta_key = 'grade')"; |
| 1021 |
|
$comment_query_piece[ 'orderby'] = " ORDER BY {$wpdb->comments}.comment_date_gmt DESC "; |
| 1022 |
|
|
| 1023 |
|
$comment_query = $comment_query_piece['select'] . $comment_query_piece['from'] . $comment_query_piece['where'] . $comment_query_piece['orderby']; |
| 1024 |
|
$sum_of_all_grades = intval( $wpdb->get_var( $comment_query, 0, 0 ) ); |
| 1025 |
|
|
| 1026 |
|
return $sum_of_all_grades; |
| 1027 |
|
|
| 1028 |
|
} |
| 1029 |
|
|
| 1030 |
|
/** |
| 1031 |
|
* Get the sum of all grades for the given user. |