Minor code changes (#415)
This commit is contained in:
parent
a1f0e6dec7
commit
8b8a358790
3 changed files with 35 additions and 25 deletions
|
@ -35,17 +35,26 @@ defined('MOODLE_INTERNAL') || die();
|
||||||
*/
|
*/
|
||||||
class element extends \mod_customcert\element {
|
class element extends \mod_customcert\element {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The course short name.
|
||||||
|
*/
|
||||||
|
const COURSE_SHORT_NAME = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The course fullname.
|
||||||
|
*/
|
||||||
|
const COURSE_FULL_NAME = 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function renders the form elements when adding a customcert element.
|
* This function renders the form elements when adding a customcert element.
|
||||||
*
|
*
|
||||||
* @param \MoodleQuickForm $mform the edit_form instance
|
* @param \MoodleQuickForm $mform the edit_form instance
|
||||||
*/
|
*/
|
||||||
public function render_form_elements($mform) {
|
public function render_form_elements($mform) {
|
||||||
|
|
||||||
// The course name display options.
|
// The course name display options.
|
||||||
$mform->addElement('select', 'coursenamedisplay', get_string('coursenamedisplay', 'customcertelement_coursename'),
|
$mform->addElement('select', 'coursenamedisplay', get_string('coursenamedisplay', 'customcertelement_coursename'),
|
||||||
self::get_course_name_display_options());
|
self::get_course_name_display_options());
|
||||||
$mform->setType('coursenamedisplay', PARAM_ALPHA);
|
$mform->setType('coursenamedisplay', PARAM_INT);
|
||||||
$mform->addHelpButton('coursenamedisplay', 'coursenamedisplay', 'customcertelement_coursename');
|
$mform->addHelpButton('coursenamedisplay', 'coursenamedisplay', 'customcertelement_coursename');
|
||||||
|
|
||||||
parent::render_form_elements($mform);
|
parent::render_form_elements($mform);
|
||||||
|
@ -103,7 +112,7 @@ class element extends \mod_customcert\element {
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function get_course_name_detail() : string {
|
protected function get_course_name_detail(): string {
|
||||||
$courseid = \mod_customcert\element_helper::get_courseid($this->get_id());
|
$courseid = \mod_customcert\element_helper::get_courseid($this->get_id());
|
||||||
$course = get_course($courseid);
|
$course = get_course($courseid);
|
||||||
$context = \mod_customcert\element_helper::get_context($this->get_id());
|
$context = \mod_customcert\element_helper::get_context($this->get_id());
|
||||||
|
@ -112,7 +121,7 @@ class element extends \mod_customcert\element {
|
||||||
$field = $this->get_data();
|
$field = $this->get_data();
|
||||||
// The name value to display.
|
// The name value to display.
|
||||||
$value = $course->fullname;
|
$value = $course->fullname;
|
||||||
if ($field == 'courseshortdescription') {
|
if ($field == self::COURSE_SHORT_NAME) {
|
||||||
$value = $course->shortname;
|
$value = $course->shortname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,12 +133,10 @@ class element extends \mod_customcert\element {
|
||||||
*
|
*
|
||||||
* @return array returns an array of name options
|
* @return array returns an array of name options
|
||||||
*/
|
*/
|
||||||
public static function get_course_name_display_options() {
|
public static function get_course_name_display_options(): array {
|
||||||
$coursenamedisplayoptions = array(
|
return [
|
||||||
'coursename' => get_string('coursename', 'customcertelement_coursename'),
|
self::COURSE_FULL_NAME => get_string('coursefullname', 'customcertelement_coursename'),
|
||||||
'courseshortdescription' => get_string('courseshortdescription', 'customcertelement_coursename')
|
self::COURSE_SHORT_NAME => get_string('courseshortname', 'customcertelement_coursename')
|
||||||
);
|
];
|
||||||
|
|
||||||
return $coursenamedisplayoptions;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,9 +22,10 @@
|
||||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$string['coursenamedisplay'] = 'Type';
|
||||||
|
$string['coursenamedisplay_help'] = 'Display the course full name or short name?';
|
||||||
|
$string['coursefullname'] = 'Full name';
|
||||||
|
$string['courseshortname'] = 'Short name';
|
||||||
$string['pluginname'] = 'Course name';
|
$string['pluginname'] = 'Course name';
|
||||||
$string['privacy:metadata'] = 'The Course name plugin does not store any personal data.';
|
$string['privacy:metadata'] = 'The Course name plugin does not store any personal data.';
|
||||||
$string['coursenamedisplay'] = 'Course name / short description';
|
|
||||||
$string['coursenamedisplay_help'] = 'Course name or short description you wish to display on certificate.';
|
|
||||||
$string['coursename'] = 'Course name';
|
|
||||||
$string['courseshortdescription'] = 'Course short description';
|
|
||||||
|
|
|
@ -101,6 +101,7 @@ Feature: Being able to manage elements in a certificate template
|
||||||
And I add the element "Course name" to page "1" of the "Custom certificate 1" certificate template
|
And I add the element "Course name" to page "1" of the "Custom certificate 1" certificate template
|
||||||
And I set the following fields to these values:
|
And I set the following fields to these values:
|
||||||
| Font | Helvetica |
|
| Font | Helvetica |
|
||||||
|
| Type | Short name |
|
||||||
| Size | 20 |
|
| Size | 20 |
|
||||||
| Colour | #045ECD |
|
| Colour | #045ECD |
|
||||||
| Width | 20 |
|
| Width | 20 |
|
||||||
|
@ -110,6 +111,7 @@ Feature: Being able to manage elements in a certificate template
|
||||||
And I click on ".edit-icon" "css_element" in the "Course name" "table_row"
|
And I click on ".edit-icon" "css_element" in the "Course name" "table_row"
|
||||||
And the following fields match these values:
|
And the following fields match these values:
|
||||||
| Font | Helvetica |
|
| Font | Helvetica |
|
||||||
|
| Type | Short name |
|
||||||
| Size | 20 |
|
| Size | 20 |
|
||||||
| Colour | #045ECD |
|
| Colour | #045ECD |
|
||||||
| Width | 20 |
|
| Width | 20 |
|
||||||
|
|
Loading…
Reference in a new issue