function watupro_user_certificates() { global $wpdb, $user_ID; $certificate = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . WATUPRO_CERTIFICATES . " WHERE ID=%d", $_GET['id'])); // check access $multiuser_access = 'all'; if (watupro_intel()) { $multiuser_access = WatuPROIMultiUser::check_access('certificates_access'); } if ($multiuser_access == 'own') { if ($certificate->editor_id != $user_ID) { wp_die(__('You can manage only your own certificates', 'watupro')); } } if (!empty($_GET['approve'])) { $wpdb->query($wpdb->prepare("UPDATE " . WATUPRO_USER_CERTIFICATES . " SET pending_approval = 0 WHERE ID=%d", $_GET['user_certificate_id'])); // send email to user? if ($certificate->approval_notify_user) { WatuPROCertificate::approval_notify($certificate, $_GET['user_certificate_id']); } watupro_redirect("admin.php?page=watupro_user_certificates&id=" . $_GET['id']); } if (!empty($_GET['delete'])) { $wpdb->query($wpdb->prepare("DELETE FROM " . WATUPRO_USER_CERTIFICATES . " WHERE ID=%d", $_GET['user_certificate_id'])); } // select users $users = $wpdb->get_results($wpdb->prepare("SELECT tUC.ID as user_certificate_id, tU.user_nicename as user_nicename, tU.user_email as user_email, \n\ttE.name as exam_name, tUC.pending_approval as pending_approval, tT.ID as taking_id, tT.date as taking_date, tT.result as taking_result,\n\ttE.ID as exam_id\n\tFROM " . WATUPRO_USER_CERTIFICATES . " tUC \n\tJOIN {$wpdb->users} tU ON tUC.user_id = tU.ID \n\tJOIN " . WATUPRO_TAKEN_EXAMS . " tT ON tT.user_id = tU.ID AND tT.ID = tUC.taking_id\n\tJOIN " . WATUPRO_EXAMS . " tE ON tE.ID = tT.exam_id AND tE.ID = tUC.exam_id\n\tWHERE tUC.certificate_id=%d\n\tORDER BY tT.ID DESC", $certificate->ID)); $dateformat = get_option('date_format'); $is_admin = true; wp_enqueue_script('thickbox', null, array('jquery')); wp_enqueue_style('thickbox.css', '/' . WPINC . '/js/thickbox/thickbox.css', null, '1.0'); if (@file_exists(get_stylesheet_directory() . '/watupro/users-earned-certificate.html.php')) { require get_stylesheet_directory() . '/watupro/users-earned-certificate.html.php'; } else { require WATUPRO_PATH . "/views/users-earned-certificate.html.php"; } }
} // calculate percentage if ($total == 0) { $percent = 0; } else { $percent = number_format($score / $total * 100, 2); } $percent = round($percent); // generic rating $rating = $_watu->calculate_rating($total, $score, $percent); // assign grade list($grade, $certificate_id, $do_redirect, $grade_obj) = WTPGrade::calculate($exam_id, $achieved, $percent, 0, $user_grade_ids); // assign certificate if any $certificate = ""; if (!empty($certificate_id) and is_user_logged_in()) { $certificate = WatuPROCertificate::assign($exam, $taking_id, $certificate_id, $user_ID); } // category grades if any $catgrades = WTPGrade::replace_category_grades($exam->final_screen, $taking_id, $exam->ID); // replace some old confusingly named vars $exam->final_screen = str_replace("%%SCORE%%", "%%CORRECT%%", $exam->final_screen); // url to share the final screen and maybe redirect to it? $post_url = empty($post) ? get_permalink($_POST['post_id']) : get_permalink($post->ID); $post_url .= strstr($post_url, "?") ? "&" : "?"; $share_url = $post_url . "waturl=" . base64_encode($exam->ID . "|" . $taking_id); if (!empty($exam->shareable_final_screen) and !empty($exam->redirect_final_screen)) { $do_redirect = $share_url; } // time spent on this quiz $time_spent = ''; if (strstr($exam->final_screen, '%%TIME-SPENT%%') or strstr($exam->email_output, '%%TIME-SPENT%%')) {