コード例 #1
0
ファイル: submit_exam.php プロジェクト: alvarpoon/anbig
}
// 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%%')) {