Tidied up the PHPDocs and set the base element to an abstract class

This commit is contained in:
Mark Nelson 2013-06-12 18:35:27 +08:00
parent 7500bfda26
commit a26f0c2c66
11 changed files with 73 additions and 74 deletions

View file

@ -45,7 +45,7 @@ class mod_customcert_edit_element_form extends moodleform {
$element = $this->_customdata['element']; $element = $this->_customdata['element'];
// Add the field for the name of the variable, this is required for all elements. // Add the field for the name of the element, this is required for all elements.
$mform->addElement('text', 'name', get_string('elementname', 'customcert')); $mform->addElement('text', 'name', get_string('elementname', 'customcert'));
$mform->setType('name', PARAM_TEXT); $mform->setType('name', PARAM_TEXT);
$mform->setDefault('name', get_string('pluginname', 'customcertelements_' . $element->element)); $mform->setDefault('name', get_string('pluginname', 'customcertelements_' . $element->element));
@ -68,8 +68,8 @@ class mod_customcert_edit_element_form extends moodleform {
/** /**
* Validation. * Validation.
* *
* @param $data * @param array $data
* @param $files * @param array $files
* @return array the errors that were found * @return array the errors that were found
*/ */
public function validation($data, $files) { public function validation($data, $files) {

View file

@ -15,24 +15,23 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
require_once($CFG->dirroot . '/mod/customcert/elements/element.class.php');
/** /**
* The code elements core interaction API. * The customcert element code's core interaction API.
* *
* @package customcertelements_code * @package customcertelements_code
* @copyright Mark Nelson <markn@moodle.com> * @copyright Mark Nelson <markn@moodle.com>
* @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
*/ */
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
require_once($CFG->dirroot . '/mod/customcert/elements/element.class.php');
class customcert_elements_code extends customcert_elements_base { class customcert_elements_code extends customcert_elements_base {
/** /**
* Handles rendering the element on the pdf. * Handles rendering the element on the pdf.
* *
* @param stdClass $pdf the pdf object * @param pdf $pdf the pdf object
*/ */
public function render($pdf) { public function render($pdf) {
global $DB, $USER; global $DB, $USER;

View file

@ -15,19 +15,18 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The date elements core interaction API.
*
* @package customcertelements_date
* @copyright Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.'); defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
require_once($CFG->dirroot . '/mod/customcert/elements/element.class.php'); require_once($CFG->dirroot . '/mod/customcert/elements/element.class.php');
require_once($CFG->dirroot . '/mod/customcert/elements/grade/lib.php'); require_once($CFG->dirroot . '/mod/customcert/elements/grade/lib.php');
/**
* The customcert element date's core interaction API.
*
* @package customcertelements_date
* @copyright Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class customcert_elements_date extends customcert_elements_base { class customcert_elements_date extends customcert_elements_base {
/** /**
@ -55,7 +54,7 @@ class customcert_elements_date extends customcert_elements_base {
/** /**
* This function renders the form elements when adding a customcert element. * This function renders the form elements when adding a customcert element.
* *
* @param stdClass $mform the edit_form instance. * @param mod_customcert_edit_element_form $mform the edit_form instance
*/ */
public function render_form_elements($mform) { public function render_form_elements($mform) {
// Get the possible date options. // Get the possible date options.
@ -77,7 +76,7 @@ class customcert_elements_date extends customcert_elements_base {
* This will handle how form data will be saved into the data column in the * This will handle how form data will be saved into the data column in the
* customcert_elements table. * customcert_elements table.
* *
* @param stdClass $data the form data. * @param stdClass $data the form data
* @return string the json encoded array * @return string the json encoded array
*/ */
public function save_unique_data($data) { public function save_unique_data($data) {
@ -94,7 +93,7 @@ class customcert_elements_date extends customcert_elements_base {
/** /**
* Handles rendering the element on the pdf. * Handles rendering the element on the pdf.
* *
* @param stdClass $pdf the pdf object * @param pdf $pdf the pdf object
*/ */
public function render($pdf) { public function render($pdf) {
// TO DO. // TO DO.

View file

@ -27,7 +27,12 @@ require_once($CFG->dirroot . '/mod/customcert/includes/tcpdf_colors.php');
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.'); defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
class customcert_elements_base { /**
* Class customcert_elements_base
*
* All customercert element plugins are based on this class.
*/
abstract class customcert_elements_base {
/** /**
* The data for the element we are adding. * The data for the element we are adding.
@ -47,7 +52,7 @@ class customcert_elements_base {
* This function renders the form elements when adding a customcert element. * This function renders the form elements when adding a customcert element.
* Can be overridden if more functionality is needed. * Can be overridden if more functionality is needed.
* *
* @param stdClass $mform the edit_form instance. * @param mod_customcert_edit_element_form $mform the edit_form instance.
*/ */
public function render_form_elements($mform) { public function render_form_elements($mform) {
// Render the common elements. // Render the common elements.
@ -60,7 +65,7 @@ class customcert_elements_base {
* Sets the data on the form when editing an element. * Sets the data on the form when editing an element.
* Can be overridden if more functionality is needed. * Can be overridden if more functionality is needed.
* *
* @param stdClass $mform the edit_form instance * @param mod_customcert_edit_element_form $mform the edit_form instance
* @param array the form elements to set * @param array the form elements to set
*/ */
public function definition_after_data($mform) { public function definition_after_data($mform) {
@ -166,7 +171,7 @@ class customcert_elements_base {
* Handles rendering the element on the pdf. * Handles rendering the element on the pdf.
* Must be overridden. * Must be overridden.
* *
* @param stdClass $pdf the pdf object * @param pdf $pdf the pdf object
*/ */
public function render($pdf) { public function render($pdf) {
// Must be overridden. // Must be overridden.
@ -175,7 +180,7 @@ class customcert_elements_base {
/** /**
* Common behaviour for rendering specified content on the pdf. * Common behaviour for rendering specified content on the pdf.
* *
* @param stdClass $pdf the pdf object * @param pdf $pdf the pdf object
* @param string $content the content to render * @param string $content the content to render
*/ */
public function render_content($pdf, $content) { public function render_content($pdf, $content) {
@ -224,7 +229,7 @@ class customcert_elements_base {
/** /**
* Helper function to render the font elements. * Helper function to render the font elements.
* *
* @param stdClass $mform the edit_form instance. * @param mod_customcert_edit_element_form $mform the edit_form instance.
*/ */
public function render_form_elements_font($mform) { public function render_form_elements_font($mform) {
$mform->addElement('select', 'font', get_string('font', 'customcert'), customcert_get_fonts()); $mform->addElement('select', 'font', get_string('font', 'customcert'), customcert_get_fonts());
@ -241,7 +246,7 @@ class customcert_elements_base {
/** /**
* Helper function to render the colour elements. * Helper function to render the colour elements.
* *
* @param stdClass $mform the edit_form instance. * @param mod_customcert_edit_element_form $mform the edit_form instance.
*/ */
public function render_form_elements_colour($mform) { public function render_form_elements_colour($mform) {
$mform->addElement('customcert_colourpicker', 'colour', get_string('fontcolour', 'customcert')); $mform->addElement('customcert_colourpicker', 'colour', get_string('fontcolour', 'customcert'));
@ -253,7 +258,7 @@ class customcert_elements_base {
/** /**
* Helper function to render the position elements. * Helper function to render the position elements.
* *
* @param stdClass $mform the edit_form instance. * @param mod_customcert_edit_element_form $mform the edit_form instance.
*/ */
public function render_form_elements_position($mform) { public function render_form_elements_position($mform) {
$mform->addElement('text', 'posx', get_string('posx', 'customcert'), array('size' => 10)); $mform->addElement('text', 'posx', get_string('posx', 'customcert'), array('size' => 10));
@ -309,7 +314,7 @@ class customcert_elements_base {
/** /**
* Sets the font for the element. * Sets the font for the element.
* *
* @param stdClass $pdf the pdf object * @param pdf $pdf the pdf object
*/ */
public function set_font($pdf) { public function set_font($pdf) {
// Variable for the font. // Variable for the font.

View file

@ -15,14 +15,6 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The grade elements core interaction API.
*
* @package customcertelements_grade
* @copyright Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.'); defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
require_once($CFG->dirroot . '/mod/customcert/elements/element.class.php'); require_once($CFG->dirroot . '/mod/customcert/elements/element.class.php');
@ -35,6 +27,13 @@ require_once($CFG->dirroot . '/grade/querylib.php');
*/ */
define('CUSTOMCERT_GRADE_COURSE', '0'); define('CUSTOMCERT_GRADE_COURSE', '0');
/**
* The customcert element grade's core interaction API.
*
* @package customcertelements_grade
* @copyright Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class customcert_elements_grade extends customcert_elements_base { class customcert_elements_grade extends customcert_elements_base {
/** /**
@ -62,7 +61,7 @@ class customcert_elements_grade extends customcert_elements_base {
/** /**
* This function renders the form elements when adding a customcert element. * This function renders the form elements when adding a customcert element.
* *
* @param stdClass $mform the edit_form instance. * @param mod_customcert_edit_element_form $mform the edit_form instance
*/ */
public function render_form_elements($mform) { public function render_form_elements($mform) {
// Get the grade items we can display. // Get the grade items we can display.
@ -105,7 +104,7 @@ class customcert_elements_grade extends customcert_elements_base {
/** /**
* Handles rendering the element on the pdf. * Handles rendering the element on the pdf.
* *
* @param stdClass $pdf the pdf object * @param pdf $pdf the pdf object
*/ */
public function render($pdf) { public function render($pdf) {
global $USER; global $USER;

View file

@ -15,18 +15,17 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
require_once($CFG->dirroot . '/mod/customcert/elements/element.class.php');
/** /**
* The image elements core interaction API. * The customcert element image's core interaction API.
* *
* @package customcertelements_image * @package customcertelements_image
* @copyright Mark Nelson <markn@moodle.com> * @copyright Mark Nelson <markn@moodle.com>
* @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
*/ */
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
require_once($CFG->dirroot . '/mod/customcert/elements/element.class.php');
class customcert_elements_image extends customcert_elements_base { class customcert_elements_image extends customcert_elements_base {
/** /**
@ -58,7 +57,7 @@ class customcert_elements_image extends customcert_elements_base {
/** /**
* This function renders the form elements when adding a customcert element. * This function renders the form elements when adding a customcert element.
* *
* @param stdClass $mform the edit_form instance. * @param mod_customcert_edit_element_form $mform the edit_form instance
*/ */
public function render_form_elements($mform) { public function render_form_elements($mform) {
$mform->addElement('select', 'image', get_string('image', 'customcertelements_image'), self::get_images()); $mform->addElement('select', 'image', get_string('image', 'customcertelements_image'), self::get_images());
@ -105,7 +104,7 @@ class customcert_elements_image extends customcert_elements_base {
* This will handle how form data will be saved into the data column in the * This will handle how form data will be saved into the data column in the
* customcert_elements table. * customcert_elements table.
* *
* @param stdClass $data the form data. * @param stdClass $data the form data
* @return string the json encoded array * @return string the json encoded array
*/ */
public function save_unique_data($data) { public function save_unique_data($data) {
@ -122,7 +121,7 @@ class customcert_elements_image extends customcert_elements_base {
/** /**
* Handles rendering the element on the pdf. * Handles rendering the element on the pdf.
* *
* @param stdClass $pdf the pdf object * @param pdf $pdf the pdf object
*/ */
public function render($pdf) { public function render($pdf) {
global $CFG; global $CFG;
@ -148,7 +147,7 @@ class customcert_elements_image extends customcert_elements_base {
/** /**
* Return the list of possible images to use. * Return the list of possible images to use.
* *
* @return array the list of images that can be used. * @return array the list of images that can be used
*/ */
public static function get_images() { public static function get_images() {
// Create file storage object. // Create file storage object.

View file

@ -15,24 +15,23 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
require_once($CFG->dirroot . '/mod/customcert/elements/element.class.php');
/** /**
* The studentname elements core interaction API. * The customcert element studentname's core interaction API.
* *
* @package customcertelements_studentname * @package customcertelements_studentname
* @copyright Mark Nelson <markn@moodle.com> * @copyright Mark Nelson <markn@moodle.com>
* @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
*/ */
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
require_once($CFG->dirroot . '/mod/customcert/elements/element.class.php');
class customcert_elements_studentname extends customcert_elements_base { class customcert_elements_studentname extends customcert_elements_base {
/** /**
* Handles rendering the element on the pdf. * Handles rendering the element on the pdf.
* *
* @param stdClass $pdf the pdf object * @param pdf $pdf the pdf object
*/ */
public function render($pdf) { public function render($pdf) {
global $USER; global $USER;

View file

@ -15,18 +15,17 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
require_once($CFG->dirroot . '/mod/customcert/elements/element.class.php');
/** /**
* The text elements core interaction API. * The customcert element text's core interaction API.
* *
* @package customcertelements_text * @package customcertelements_text
* @copyright Mark Nelson <markn@moodle.com> * @copyright Mark Nelson <markn@moodle.com>
* @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
*/ */
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
require_once($CFG->dirroot . '/mod/customcert/elements/element.class.php');
class customcert_elements_text extends customcert_elements_base { class customcert_elements_text extends customcert_elements_base {
/** /**
@ -43,7 +42,7 @@ class customcert_elements_text extends customcert_elements_base {
/** /**
* This function renders the form elements when adding a customcert element. * This function renders the form elements when adding a customcert element.
* *
* @param stdClass $mform the edit_form instance. * @param mod_customcert_edit_element_form $mform the edit_form instance
*/ */
public function render_form_elements($mform) { public function render_form_elements($mform) {
$mform->addElement('textarea', 'text', get_string('text', 'customcertelements_text')); $mform->addElement('textarea', 'text', get_string('text', 'customcertelements_text'));
@ -57,7 +56,7 @@ class customcert_elements_text extends customcert_elements_base {
* This will handle how form data will be saved into the data column in the * This will handle how form data will be saved into the data column in the
* customcert_elements table. * customcert_elements table.
* *
* @param stdClass $data the form data. * @param stdClass $data the form data
* @return string the text * @return string the text
*/ */
public function save_unique_data($data) { public function save_unique_data($data) {
@ -67,7 +66,7 @@ class customcert_elements_text extends customcert_elements_base {
/** /**
* Handles rendering the element on the pdf. * Handles rendering the element on the pdf.
* *
* @param stdClass $pdf the pdf object * @param pdf $pdf the pdf object
*/ */
public function render($pdf) { public function render($pdf) {
parent::render_content($pdf, $this->element->data); parent::render_content($pdf, $this->element->data);

View file

@ -55,7 +55,7 @@ define('CUSTOMCERT_MAX_PER_PAGE', 300);
* Add customcert instance. * Add customcert instance.
* *
* @param stdClass $data * @param stdClass $data
* @param stdClass $mform * @param mod_customcert_mod_form $mform
* @return int new customcert instance id * @return int new customcert instance id
*/ */
function customcert_add_instance($data, $mform) { function customcert_add_instance($data, $mform) {
@ -76,7 +76,7 @@ function customcert_add_instance($data, $mform) {
* Update customcert instance. * Update customcert instance.
* *
* @param stdClass $data * @param stdClass $data
* @param stdClass $mform * @param mod_customcert_mod_form $mform
* @return bool true * @return bool true
*/ */
function customcert_update_instance($data, $mform) { function customcert_update_instance($data, $mform) {
@ -206,7 +206,7 @@ function customcert_reset_userdata($data) {
* Implementation of the function for printing the form elements that control * Implementation of the function for printing the form elements that control
* whether the course reset functionality affects the customcert. * whether the course reset functionality affects the customcert.
* *
* @param $mform form passed by reference * @param mod_customcert_mod_form $mform form passed by reference
*/ */
function customcert_reset_course_form_definition(&$mform) { function customcert_reset_course_form_definition(&$mform) {
$mform->addElement('header', 'customcertheader', get_string('modulenameplural', 'customcert')); $mform->addElement('header', 'customcertheader', get_string('modulenameplural', 'customcert'));

View file

@ -33,7 +33,7 @@ class mod_customcert_mod_form extends moodleform_mod {
* Form definition. * Form definition.
*/ */
function definition() { function definition() {
global $CFG, $DB, $OUTPUT; global $CFG;
$mform =& $this->_form; $mform =& $this->_form;
@ -91,8 +91,8 @@ class mod_customcert_mod_form extends moodleform_mod {
/** /**
* Some basic validation. * Some basic validation.
* *
* @param $data * @param array $data
* @param $files * @param array $files
* @return array the errors that were found * @return array the errors that were found
*/ */
public function validation($data, $files) { public function validation($data, $files) {

View file

@ -58,8 +58,8 @@ class mod_customcert_save_template_form extends moodleform {
/** /**
* Some basic validation. * Some basic validation.
* *
* @param $data * @param array $data
* @param $files * @param array $files
* @return array the errors that were found * @return array the errors that were found
*/ */
public function validation($data, $files) { public function validation($data, $files) {