/**
  * Test retreiving a certificate setting by using in illegit entity type value
  */
 public function test_retrieve_certificate_settings_by_entity_type_fail()
 {
     $this->load_csv_data();
     // Test Retrieving illegit data.
     $entityid = 3;
     $entitytype = 'NOTHING';
     $certsettings = new certificatesettings();
     $certsettings->get_data_by_entity($entityid, $entitytype);
     $record = $certsettings->to_object();
     $this->assertObjectNotHasAttribute('id', $certsettings);
 }
Example #2
0
require_once elispm::lib('data/certificateissued.class.php');
require_once elispm::lib('data/student.class.php');
require_once elispm::lib('data/instructor.class.php');
$ciid = required_param('id', PARAM_INT);
// Issued certificate id
$csid = required_param('csid', PARAM_INT);
// certificate setting id
global $USER;
$cmuserid = cm_get_crlmuserid($USER->id);
$student = new user($cmuserid);
$student->load();
if (empty($student->id)) {
    return get_string('studentnotfound', 'local_elisprogram');
}
// 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');
 /**
  * Test retrieving course metadata
  */
 public function test_retrieve_metadata_for_course_entity()
 {
     $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_course_entity_metadata($certsetting, $certissued, $student);
     $expected = array('student_name' => 'User Test2', 'course_name' => 'Test Course', 'class_idnumber' => 'Test_Class_Instance_1', 'class_enrol_time' => 1358315400, 'class_startdate' => 0, 'class_enddate' => 0, 'class_grade' => '10.00000', 'cert_timeissued' => 1358363100, 'cert_code' => '339Fjap8j6oPKnw', 'class_instructor_name' => 'User Test1');
     $this->assertEquals($expected, $result);
 }