From 659719945d46387ca8823ae45c51df97298a593d Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Wed, 5 Jun 2013 16:23:11 +0800 Subject: [PATCH] Introduced the code element --- .../code/lang/en/customcertelement_code.php | 26 ++++++++++ elements/code/lib.php | 48 +++++++++++++++++++ elements/code/version.php | 30 ++++++++++++ 3 files changed, 104 insertions(+) create mode 100644 elements/code/lang/en/customcertelement_code.php create mode 100644 elements/code/lib.php create mode 100644 elements/code/version.php diff --git a/elements/code/lang/en/customcertelement_code.php b/elements/code/lang/en/customcertelement_code.php new file mode 100644 index 0000000..6d57fb7 --- /dev/null +++ b/elements/code/lang/en/customcertelement_code.php @@ -0,0 +1,26 @@ +. + +/** + * Strings for component 'customcertelement_code', language 'en'. + * + * @package customcertelement_code + * @copyright Mark Nelson + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +$string['pluginname'] = 'Code'; diff --git a/elements/code/lib.php b/elements/code/lib.php new file mode 100644 index 0000000..51f849b --- /dev/null +++ b/elements/code/lib.php @@ -0,0 +1,48 @@ +. + +/** + * The code elements core interaction API. + * + * @package customcertelement_code + * @copyright Mark Nelson + * @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_element_code extends customcert_element_base { + + /** + * Handles rendering the element on the pdf. + * + * @param stdClass $pdf the pdf object + * @param int $userid + */ + public function render($pdf, $userid) { + global $DB; + + // Get the page. + $page = $DB->get_record('customcert_pages', array('id' => $this->element->pageid), '*', MUST_EXIST); + // Now we can get the issue for this user. + $issue = $DB->get_record('customcert_issues', array('userid' => $userid, 'customcertid' => $page->customcertid), '*', MUST_EXIST); + + parent::render_content($pdf, $issue->code); + } +} diff --git a/elements/code/version.php b/elements/code/version.php new file mode 100644 index 0000000..9a3bb37 --- /dev/null +++ b/elements/code/version.php @@ -0,0 +1,30 @@ +. + +/** + * This file contains the version information for the code plugin. + * + * @package customcertelement_code + * @copyright Mark Nelson + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.'); + +$plugin->version = 2013060500; +$plugin->requires = 2013040500; // Requires this Moodle version. +$plugin->component = 'customcertelement_code';