/** * List the certificates available to be printed. * TODO: Figure out a better way of displaying all of the cert entity types */ public function display_default() { global $CFG, $USER, $OUTPUT; // This is for a Moodle user, so get the Curriculum user id. $cuserid = cm_get_crlmuserid($USER->id); $link = ''; $attributes = array(); $text = ''; if (empty($cuserid)) { print_error('notelisuser', 'local_elisprogram'); } if (empty(elis::$config->local_elisprogram->disablecertificates)) { $curasses = curriculumstudent::get_completed_for_user($cuserid); if (count($curasses) == 0) { print_string('certificates_none_earned', 'local_elisprogram'); } else { print_string('certificates_earned', 'local_elisprogram'); echo html_writer::start_tag('ul'); foreach ($curasses as $curass) { $attributes['href'] = 'certificate.php?id=' . $curass->id; $attributes['target'] = '_blank'; $text = $curass->curriculum->name; $link = html_writer::tag('a', $text, $attributes); echo html_writer::tag('li', $link); } echo html_writer::end_tag('ul'); } } if (isset(elis::$config->local_elisprogram->disablecoursecertificates) && empty(elis::$config->local_elisprogram->disablecoursecertificates)) { $records = get_user_certificates($cuserid); $this->display_entity_certificates($records); $records->close(); } }
/** * Test retreiving a user who has been issued 2 certificate referencing only 1 certificate setting record * (example. A student, enrolled in 2 different classes belonging to the same course description) */ public function test_retrieve_user_cert_for_two_class_one_settings() { $this->load_csv_data(); $record = array(); $cmuserid = 5; $recordset = get_user_certificates($cmuserid); $expected = array(); $expected['id'] = 6; $expected['cm_userid'] = '5'; $expected['cert_code'] = '779Fjap8j6oPKnw'; $expected['timeissued'] = '1358316000'; $expected['entity_id'] = '5'; $expected['entity_type'] = 'COURSE'; $expected['csid'] = '5'; $expected['cert_border'] = 'Fancy1-black.jpg'; $expected['cert_seal'] = 'Amazing.png'; $expected['cert_template'] = 'default5.php'; $expected2 = array(); $expected2['id'] = 7; $expected2['cm_userid'] = '5'; $expected2['cert_code'] = '879Fjap8j6oPKnw'; $expected2['timeissued'] = '1358317000'; $expected2['entity_id'] = '5'; $expected2['entity_type'] = 'COURSE'; $expected2['csid'] = '5'; $expected2['cert_border'] = 'Fancy1-black.jpg'; $expected2['cert_seal'] = 'Amazing.png'; $expected2['cert_template'] = 'default5.php'; foreach ($recordset as $data) { $record[] = $data; } $recordset->close(); $this->assertEquals(2, count($record)); foreach ($expected as $key => $val) { $this->assertObjectHasAttribute($key, $record[0]); $this->assertEquals($val, $record[0]->{$key}); } foreach ($expected2 as $key => $val) { $this->assertObjectHasAttribute($key, $record[1]); $this->assertEquals($val, $record[1]->{$key}); } }