Example #1
0
 static function report($attr)
 {
     global $user_ID;
     $content = '';
     watupro_vc_scripts();
     // reports for who?
     $user_id = @$attr[1];
     if (empty($user_id)) {
         $user_id = $user_ID;
     }
     if (empty($user_id)) {
         return __('This content is only for logged in users', 'watupro');
     }
     $type = @$attr[0];
     $type = strtolower($type);
     if (!in_array($type, array("overview", "tests", "skills", "history"))) {
         $type = 'overview';
     }
     ob_start();
     switch ($type) {
         case 'overview':
             WTPReports::overview($user_id, false);
             break;
         case 'tests':
             WTPReports::tests($user_id, false);
             break;
         case 'skills':
             WTPReports::skills($user_id, false);
             break;
         case 'history':
             WTPReports::history($user_id, false);
             break;
     }
     $content = ob_get_contents();
     ob_end_clean();
     return $content;
 }
Example #2
0
function watupro_leaderboard($attr)
{
    global $wpdb;
    watupro_vc_scripts();
    $num = $attr[0];
    // number of users to show
    if (empty($num) or !is_numeric($num)) {
        $num = 10;
    }
    // now select them ordered by total points
    $users = $wpdb->get_results("SELECT SUM(tT.points) as points, tU.user_login as user_login \n\t\tFROM {$wpdb->users} tU JOIN " . WATUPRO_TAKEN_EXAMS . " tT ON tT.user_id = tU.ID\n\t\tWHERE tT.in_progress = 0 GROUP BY tU.ID ORDER BY points DESC LIMIT {$num}");
    $table = "<table class='watupro-leaderboard'><tr><th>" . __('User', 'watupro') . "</th><th>" . __("Points", 'watupro') . "</th></tr>";
    foreach ($users as $user) {
        $table .= "<tr><td>" . $user->user_login . "</td><td>" . $user->points . "</td></tr>";
    }
    $table .= "</table>";
    return $table;
}