Moved the rendering of the header form element for each customcert element to edit_form.php

The render_common_form_elements function was removed in the base class and it's contents put into the render_form_element function. These changes mean that some elements may not be required to override the render_form_element function, such as the studentname element, where this function was removed.
This commit is contained in:
Mark Nelson 2013-02-26 17:22:52 +08:00
parent 52fbc108a7
commit 2b4bbbe820
6 changed files with 7 additions and 37 deletions

View file

@ -244,6 +244,9 @@ class mod_customcert_edit_form extends moodleform {
// It's possible this element was added to the database then the folder was deleted, if
// this is the case we do not want to render these elements as an error will occur.
if (file_exists($classfile)) {
// Add element header.
$mform->addElement('header', 'headerelement_' . $element->id, get_string('page', 'customcert', $pagenum) . " - " .
get_string('pluginname', 'customcertelement_' . $element->element));
// Add the page number to the element so we can use within the element.
$element->pagenum = $pagenum;
// Get the classname.

View file

@ -69,23 +69,11 @@ class customcert_element_base {
/**
* This function renders the form elements when adding a customcert element.
* Must be overriden.
* Can be overridden if more functionality is needed.
*
* @param stdClass $mform the edit_form instance.
* @return array the form elements
*/
public function render_form_elements($mform) {
// Must be overriden.
return false;
}
/**
* This function renders the common form elements when adding a customcert element.
*
* @param stdClass $mform the edit_form instance.
* @return array the form elements
*/
public function render_common_form_elements($mform) {
// The identifier.
$id = $this->element->id;

View file

@ -60,15 +60,11 @@ class customcert_element_grade extends customcert_element_base {
$gradeformat = $gradeinfo->gradeformat;
}
// Add element header.
$mform->addElement('header', 'headerelement_' . $id, get_string('page', 'customcert', $this->element->pagenum) . " - " .
get_string('pluginname', 'customcertelement_grade'));
// The elements unique to this field.
$mform->addElement('select', 'gradeitem_' . $id, get_string('gradeitem', 'customcertelement_grade'), $this->get_grade_items());
$mform->addElement('select', 'gradeformat_' . $id, get_string('gradeformat', 'customcertelement_grade'), $this->get_grade_format_options());
parent::render_common_form_elements($mform);
parent::render_form_elements($mform);
$mform->setDefault('gradeitem_' . $id, $gradeitem);
$mform->setDefault('gradeformat_' . $id, $gradeformat);

View file

@ -1,6 +1,6 @@
<?php
// This file is part of Moodle - http://moodle.org/
// This file is part of the customcert module for Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by

View file

@ -38,23 +38,6 @@ class customcert_element_studentname extends customcert_element_base {
parent::__construct($element);
}
/**
* This function renders the form elements when adding a customcert element.
*
* @param stdClass $mform the edit_form instance.
* @return array the form elements
*/
public function render_form_elements($mform) {
// The identifier.
$id = $this->element->id;
// Add element header.
$mform->addElement('header', 'headerelement_' . $id, get_string('page', 'customcert', $this->element->pagenum) . " - "
. get_string('pluginname', 'customcertelement_studentname'));
parent::render_common_form_elements($mform);
}
/**
* Handles displaying the element on the pdf.
*

View file

@ -1,6 +1,6 @@
<?php
// This file is part of Moodle - http://moodle.org/
// This file is part of the customcert module for Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by