예제 #1
0
// Retrieve the certificate settings record
$certsettingrec = new certificatesettings($csid);
$certsettingrec->load();
// Check if the record exists or if the certificate is disabled
if (empty($certsettingrec->id) and !empty($certsettingrec->disable)) {
    // Passing hard coded error code to disallow administrators from changing them to
    // custom strings
    echo get_string('errorfindingcertsetting', 'local_elisprogram', 'Error 11');
}
// Retrieve the certificate issued record
$certissuedrec = new certificateissued($ciid);
$certissuedrec->load();
// Check if the record exists or if the certificate is disabled
if (empty($certissuedrec->id) and !empty($certissuedrec->disable)) {
    // Passing hard coded error code to disallow administrators from changing them to
    // custom strings
    echo get_string('errorfindingcertissued', 'local_elisprogram', 'Error 22');
}
// Set the border, seal and template filenames and other info
$borderimage = $certsettingrec->cert_border;
$sealimage = $certsettingrec->cert_seal;
$template = $certsettingrec->cert_template;
$instructor = '';
$params = array();
// Retrieve additional metadata about the entity
$params = certificate_get_entity_metadata($certsettingrec, $certissuedrec, $student);
if (!empty($params)) {
    certificate_output_entity_completion($params, $borderimage, $sealimage, $template);
} else {
    echo get_string('errorfindingcertsetting', 'local_elisprogram', 'Error 33');
}
 /**
  * Test retrieving metadata passing correct entity type name
  */
 public function test_retireve_metadata_for_entity_correct_entity_type()
 {
     $this->load_csv_data();
     $student = new user(104);
     $certsetting = new certificatesettings(6);
     $certissued = new certificateissued(9);
     $certissued->load();
     $student->load();
     $certsetting->load();
     $result = certificate_get_entity_metadata($certsetting, $certissued, $student);
     $this->assertNotEquals(false, $result);
 }