Verify custom certificate with date

Verify custom certificate with date

by Terri Roshell -
Number of replies: 3

Is there a way to add the Awarded Date of the certificate to the Verify link?

Average of ratings: -
In reply to Terri Roshell

Re: Verify custom certificate with date

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
I don't think there is - I am guessing that you don't actually want it in the link though? You are wanting to show the date on the verify page - I would suggest putting in a request on the developer's github page as that seems like something that should be there..
In reply to Emma Richardson

Re: Verify custom certificate with date

by Terri Roshell -
I figured it out.

LOCATION: /home//public_html/lms/mod/customcert/verify_certificate.php
$sql = "SELECT ci.id, u.id as userid, $userfields, co.id as courseid,
co.fullname as coursefullname, c.id as certificateid,
c.name as certificatename, FROM_UNIXTIME(ci.timecreated,'%m-%d-%Y') as timecreated, c.verifyany
FROM {customcert} c
JOIN {customcert_issues} ci
ON c.id = ci.customcertid
JOIN {customcert_issues} ct
ON ci.timecreated = ct.timecreated
JOIN {course} co
ON c.course = co.id
JOIN {user} u
ON ci.userid = u.id
WHERE ci.code = :code";

LOCATION: /home//public_html/lms/mod/customcert/classes/output/verify_certificate_result.php

/**
* @var string Awarded on date.
* /
public $timecreated;

/**
* Constructor.
*
* @param \stdClass $result
*/
public function __construct($result) {
$cm = get_coursemodule_from_instance('customcert', $result->certificateid);
$context = \context_module::instance($cm->id);

$this->userprofileurl = new \moodle_url('/user/view.php', array('id' => $result->userid,
'course' => $result->courseid));
$this->userfullname = fullname($result);
$this->courseurl = new \moodle_url('/course/view.php', array('id' => $result->courseid));
$this->coursefullname = format_string($result->coursefullname, true, ['context' => $context]);
$this->certificatename = format_string($result->certificatename, true, ['context' => $context]);
$this->timecreated = format_string($result->timecreated, true, ['context => $context']);
}

/**
* Function to export the renderer data in a format that is suitable for a mustache template.
*
* @param \renderer_base $output Used to do a final render of any components that need to be rendered for export.
* @return \stdClass|array
*/
public function export_for_template(\renderer_base $output) {
$result = new \stdClass();
$result->userprofileurl = $this->userprofileurl;
$result->userfullname = $this->userfullname;
$result->coursefullname = $this->coursefullname;
$result->courseurl = $this->courseurl;
$result->certificatename = $this->certificatename;
$result->timecreated = $this->timecreated;

return $result;
}

LOCATION: /home//public_html/lms/mod/customcert/templates/verify_certificate_result.mustache