public function test_certificate_print_user_files()
 {
     global $CFG, $USER;
     $this->setAdminUser();
     $certificate = $this->generator->create_instance(array('course' => $this->course->id));
     $coursemodule = get_coursemodule_from_instance('certificate', $certificate->id);
     $certificateissues = certificate_get_issue($this->course, $USER, $certificate, $coursemodule);
     $context = context_module::instance($coursemodule->id);
     require_once "{$CFG->dirroot}/mod/certificate/certificate_pdf_renderer.php";
     $cpr = new certificate_pdf_renderer($certificate, $this->course, $coursemodule);
     $pdf = $cpr->get_pdf();
     $pdfstring = $pdf->Output('', 'S');
     $filename = "dummyfile.pdf";
     certificate_save_pdf($pdfstring, $certificateissues->id, $filename, $context->id);
     $this->assertTrue(!!preg_match("/{$filename}/i", certificate_print_user_files($certificate, $USER->id, $context->id)));
 }
Example #2
0
/**
 * Returns information about received certificate.
 * Used for user activity reports.
 *
 * @param stdClass $course
 * @param stdClass $user
 * @param stdClass $mod
 * @param stdClass $certificate
 * @return string the user complete information
 */
function certificate_user_complete($course, $user, $mod, $certificate)
{
    global $DB, $OUTPUT, $CFG;
    require_once $CFG->dirroot . '/mod/certificate/locallib.php';
    if ($issue = $DB->get_record('certificate_issues', array('certificateid' => $certificate->id, 'userid' => $user->id))) {
        echo $OUTPUT->box_start();
        echo get_string('issued', 'certificate') . ": ";
        echo userdate($issue->timecreated);
        $cm = get_coursemodule_from_instance('certificate', $certificate->id, $course->id);
        certificate_print_user_files($certificate, $user->id, context_module::instance($cm->id)->id);
        echo '<br />';
        echo $OUTPUT->box_end();
    } else {
        print_string('notissuedyet', 'certificate');
    }
}
Example #3
0
/**
 * Returns information about received certificate.
 * Used for user activity reports.
 *
 * @param stdClass $course
 * @param stdClass $user
 * @param stdClass $mod
 * @param stdClass $page
 * @return object|null
 */
function certificate_user_complete($course, $user, $mod, $certificate)
{
    global $DB, $OUTPUT;
    if ($issue = $DB->get_record('certificate_issues', array('certificateid' => $certificate->id, 'userid' => $user->id))) {
        echo $OUTPUT->box_start();
        echo get_string('issued', 'certificate') . ": ";
        echo userdate($issue->certdate);
        certificate_print_user_files($certificate->id, $user->id);
        echo '<br />';
        echo $OUTPUT->box_end();
    } else {
        print_string('notissuedyet', 'certificate');
    }
}
Example #4
0
$usercount = count(certificate_get_issues($certificate->id, $DB->sql_fullname(), $groupmode, $cm));
// Create the table for the users
$table = new html_table();
$table->width = "95%";
$table->tablealign = "center";
$table->head = array($strto);
$table->align = array('left');
foreach ($extrafields as $field) {
    $table->head[] = get_user_field_name($field);
    $table->align[] = 'left';
}
$table->head = array_merge($table->head, array($strdate, $strgrade, $strcode));
$table->align = array_merge($table->align, array('left', 'center', 'center'));
foreach ($users as $user) {
    $name = $OUTPUT->user_picture($user) . fullname($user);
    $date = userdate($user->timecreated) . certificate_print_user_files($certificate, $user->id, $context->id);
    $code = $user->code;
    $data = array();
    $data[] = $name;
    foreach ($extrafields as $field) {
        $data[] = $user->{$field};
    }
    $data = array_merge($data, array($date, certificate_get_grade($certificate, $course, $user->id), $code));
    $table->data[] = $data;
}
// Create table to store buttons
$tablebutton = new html_table();
$tablebutton->attributes['class'] = 'downloadreport';
$btndownloadods = $OUTPUT->single_button(new moodle_url("report.php", array('id' => $cm->id, 'download' => 'ods')), get_string("downloadods"));
$btndownloadxls = $OUTPUT->single_button(new moodle_url("report.php", array('id' => $cm->id, 'download' => 'xls')), get_string("downloadexcel"));
$btndownloadtxt = $OUTPUT->single_button(new moodle_url("report.php", array('id' => $cm->id, 'download' => 'txt')), get_string("downloadtext"));
function certificate_user_complete($course, $user, $mod, $certificate)
{
    if ($issue = get_record('certificate_issues', 'certificateid', $certificate->id, 'userid', $user->id)) {
        print_simple_box_start();
        echo get_string('issued', 'certificate') . ": ";
        echo userdate($issue->timecreated);
        certificate_print_user_files($user->id);
        echo '<br />';
    } else {
        print_string('notissuedyet', 'certificate');
    }
    print_simple_box_end();
}
        if ($groupmode = groupmode($course, $cm)) {   // Groups are being used
            $currentgroup = setup_and_print_groups($course, $groupmode, 'report.php?id='.$cm->id);
        } else {
            $currentgroup = 0;
        }

    /// Get all teachers and students
        if ($currentgroup) {
            $users = get_group_users($currentgroup);
        } else {
            $users = get_course_users($course->id);
        }
*/
$sqlsort = "s.studentname ASC";
//or sort by date:
// $sqlsort = "s.certdate ASC";
if (!($users = certificate_get_issues($certificate->id, $USER, $sqlsort))) {
    notice("There are no issued certificates", "../../course/view.php?id={$course->id}");
    die;
}
$table->head = array($strto, $strdate, $strcode);
$table->align = array("LEFT", "LEFT", "LEFT");
foreach ($users as $user) {
    $name = print_user_picture($user->id, $course->id, $user->picture, false, true) . $user->studentname;
    $date = certificate_date_report($user) . certificate_print_user_files($user->id);
    $code = $user->code;
    $table->data[] = array($name, $date, $code);
}
echo "<BR>";
print_table($table);
print_footer($course);
            echo $grade . "\t";
            echo $user->code . "\n";
            $row++;
        }
    }
    exit;
}
// Create the table for the users
$table = new html_table();
$table->width = "95%";
$table->tablealign = "center";
$table->head = array($strto, $strdate, $strgrade, $strcode);
$table->align = array("left", "left", "center", "center");
foreach ($users as $user) {
    $name = $OUTPUT->user_picture($user) . $user->studentname;
    $date = userdate($user->certdate) . certificate_print_user_files($certificate, $user->id, $context->id);
    if ($user->reportgrade != null) {
        $grade = $user->reportgrade;
    } else {
        $grade = get_string('notapplicable', 'certificate');
    }
    $code = $user->code;
    $table->data[] = array($name, $date, $grade, $code);
}
// Create table to store buttons
$tablebutton = new html_table();
$tablebutton->attributes['class'] = 'downloadreport';
$btndownloadods = $OUTPUT->single_button(new moodle_url("report.php", array('id' => $cm->id, 'download' => 'ods')), get_string("downloadods"));
$btndownloadxls = $OUTPUT->single_button(new moodle_url("report.php", array('id' => $cm->id, 'download' => 'xls')), get_string("downloadexcel"));
$btndownloadtxt = $OUTPUT->single_button(new moodle_url("report.php", array('id' => $cm->id, 'download' => 'txt')), get_string("downloadtext"));
$tablebutton->data[] = array($btndownloadods, $btndownloadxls, $btndownloadtxt);
Example #8
0
                $grade = get_string('notapplicable', 'certificate');
            }
            echo $grade . "\t";
            echo $user->code . "\n";
            $row++;
        }
    }
    exit;
}
echo '<br />';
print_heading(get_string('modulenameplural', 'certificate'));
$table->head = array($strto, $strdate, $strgrade, $strcode);
$table->align = array("LEFT", "LEFT", "CENTER", "CENTER");
foreach ($users as $user) {
    $name = print_user_picture($user->id, $course->id, $user->picture, false, true) . $user->studentname;
    $date = userdate($user->certdate) . certificate_print_user_files($user->id);
    if ($user->reportgrade != null) {
        $grade = $user->reportgrade;
    } else {
        $grade = get_string('notapplicable', 'certificate');
    }
    $code = $user->code;
    $table->data[] = array($name, $date, $grade, $code);
}
echo '<br />';
print_table($table);
//now give links for downloading spreadsheets.
echo "<br />\n";
echo "<table class=\"downloadreport\"><tr>\n";
echo "<td>";
$options = array();