コード例 #1
0
function certificate_prepare_issue($course, $user)
{
    global $certificate;
    if (record_exists("certificate_issues", "certificateid", $certificate->id, "userid", $user->id)) {
        return get_record("certificate_issues", "certificateid", $certificate->id, "userid", $user->id);
    } else {
        if (certificate_grade_condition()) {
            $timecreated = time();
            $certdate = certificate_generate_date($certificate, $course);
            if (!$certdate) {
                $certdate = $timecreated;
            }
            $code = certificate_generate_code();
            if ($certificate->printgrade == 1) {
                $coursegrade = get_course_grade($course->id);
            } else {
                if ($certificate->printgrade > 1) {
                    $coursegrade = certificate_mod_grade($course, $certificate->printgrade);
                }
            }
            if ($certificate->gradefmt == 1) {
                $gradeinput = $coursegrade->percentage . '%';
            } else {
                if ($certificate->gradefmt == 2) {
                    $gradeinput = $coursegrade->points . ' %%P%%';
                } else {
                    if ($certificate->gradefmt == 3) {
                        $gradeinput = certificate_get_gradeletter($coursegrade->percentage);
                    }
                }
            }
            $studentname = str_replace('\'', '\\\'', certificate_generate_studentname($course, $user));
            insert_record("certificate_issues", array("certificateid" => $certificate->id, "userid" => $user->id, "timecreated" => $timecreated, "studentname" => $studentname, "code" => $code, "classname" => str_replace('\'', '\\\'', $course->fullname), "certdate" => $certdate, "credits" => $certificate->credithours, "grade" => $gradeinput), false);
            certificate_email_teachers($certificate);
        }
    }
}
コード例 #2
0
ファイル: view.php プロジェクト: nadavkav/MoodleTAO
require_capability('mod/certificate:view', $context);
// log update
add_to_log($course->id, 'certificate', 'view', "view.php?id={$cm->id}", $certificate->id, $cm->id);
//check to see if requiredcertification and user has not completed.
if (!empty($certificate->requiredcertification)) {
    //check to make sure user is certified.
    if (!record_exists('tao_user_certification_status', 'userid', $USER->id, 'certtype', $certificate->requiredcertification, 'status', 'approved')) {
        view_header($course, $certificate, $cm);
        print_simple_box(notify(get_string('requiredcertificationdesc', 'local')));
        print_continue("{$CFG->wwwroot}/course/view.php?id={$course->id}");
        print_footer();
        die;
    }
}
/// Check locked grades
$restrict_errors = certificate_grade_condition();
/// Display errors and die
if (!empty($restrict_errors) && !has_capability('mod/certificate:manage', $context)) {
    $errortext = '';
    view_header($course, $certificate, $cm);
    foreach ($restrict_errors as $err) {
        $errortext .= '<p><center>' . $err . '</center></p>';
    }
    print_simple_box($errortext);
    print_continue("{$CFG->wwwroot}/course/view.php?id={$course->id}");
    print_footer();
    die;
}
/// Create certrecord
certificate_prepare_issue($course, $USER, $certificate);
/// Load custom type
コード例 #3
0
    view_header($course, $certificate, $cm);
    echo "<p align=\"center\">" . get_string('viewed', 'certificate') . "<br /> " . certificate_date_format('timecreated', $certrecord) . ", " . strftime('%X', $certrecord->timecreated) . "</p>";
    echo '<center>';
    echo '<form action="" method="get" name="form1" target="_blank">';
    echo '<input type="hidden" name="id" value=' . $cm->id . ' />';
    echo '<input type="hidden" name="certificate" value=' . $certificate->id . ' />';
    echo '<input type="button" name="Submit" value="' . get_string('backbutton', 'certificate') . '" onClick="JavaScript:history.back();" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" name="Submit" value="' . $strreviewcertificate . '" />';
    echo '</form>';
    echo '</center>';
    print_footer(NULL, $course);
} else {
    if ($certrecord and isset($_GET['certificate'])) {
        $generate = true;
    } else {
        //Record Certificate
        if (certificate_grade_condition()) {
            if (!isset($_GET['certificate'])) {
                view_header($course, $certificate, $cm);
                echo "<table width=\"100%\" border=\"0\" cellspacing=\"40\" cellpadding=\"0\"><tr><td colspan=\"2\"><div align=\"justify\"><p>" . get_string('alert1', 'certificate') . '</p></div></td></tr>';
                if ($certificate->unenrol > 0) {
                    echo "<tr><td><strong><font color=\"#FF0000\">" . get_string('attention', 'certificate') . ":</font></strong></td><td><div align=\"justify\"><p>" . get_string('alert2', 'certificate') . '</p></div></td></tr>';
                }
                echo '<tr><td colspan="2"><center>';
                echo '<form action="" method="post" name="form2">';
                echo '<input type="button" name="Submit" value="' . get_string('backbutton', 'certificate') . '" onClick="JavaScript:history.back();" />';
                echo '</form></center></td></tr>';
                echo '<tr><td colspan="2">';
                if ($certificate->delivery == 0) {
                    echo "<p align=\"center\">" . get_string('openwindow', 'certificate') . "<br /> </p>";
                } else {
                    if ($certificate->delivery == 1) {