Introduced automatic class loading for elements
This commit is contained in:
parent
14cc24e540
commit
2416e8a3e0
29 changed files with 144 additions and 148 deletions
|
@ -22,14 +22,16 @@
|
|||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
||||
namespace mod_customcert;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Class customcert_element_base
|
||||
* Class element
|
||||
*
|
||||
* All customercert element plugins are based on this class.
|
||||
*/
|
||||
abstract class customcert_element_base {
|
||||
abstract class element {
|
||||
|
||||
/**
|
||||
* The data for the element we are adding.
|
||||
|
@ -39,7 +41,7 @@ abstract class customcert_element_base {
|
|||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param stdClass $element the element data
|
||||
* @param \stdClass $element the element data
|
||||
*/
|
||||
public function __construct($element) {
|
||||
$this->element = clone($element);
|
||||
|
@ -49,7 +51,7 @@ abstract class customcert_element_base {
|
|||
* This function renders the form elements when adding a customcert element.
|
||||
* Can be overridden if more functionality is needed.
|
||||
*
|
||||
* @param mod_customcert_edit_element_form $mform the edit_form instance.
|
||||
* @param \mod_customcert_edit_element_form $mform the edit_form instance.
|
||||
*/
|
||||
public function render_form_elements($mform) {
|
||||
// Render the common elements.
|
||||
|
@ -62,8 +64,7 @@ abstract class customcert_element_base {
|
|||
* Sets the data on the form when editing an element.
|
||||
* Can be overridden if more functionality is needed.
|
||||
*
|
||||
* @param mod_customcert_edit_element_form $mform the edit_form instance
|
||||
* @param array the form elements to set
|
||||
* @param \mod_customcert_edit_element_form $mform the edit_form instance
|
||||
*/
|
||||
public function definition_after_data($mform) {
|
||||
// Loop through the properties of the element and set the values
|
||||
|
@ -99,13 +100,13 @@ abstract class customcert_element_base {
|
|||
* Handles saving the form elements created by this element.
|
||||
* Can be overridden if more functionality is needed.
|
||||
*
|
||||
* @param stdClass $data the form data
|
||||
* @param \stdClass $data the form data
|
||||
*/
|
||||
public function save_form_elements($data) {
|
||||
global $DB;
|
||||
|
||||
// Get the data from the form.
|
||||
$element = new stdClass();
|
||||
$element = new \stdClass();
|
||||
$element->name = $data->name;
|
||||
$element->data = $this->save_unique_data($data);
|
||||
$element->font = (isset($data->font)) ? $data->font : null;
|
||||
|
@ -135,7 +136,7 @@ abstract class customcert_element_base {
|
|||
* customcert column.
|
||||
* Can be overridden if more functionality is needed.
|
||||
*
|
||||
* @param stdClass $data the form data
|
||||
* @param \stdClass $data the form data
|
||||
* @return string the unique data to save
|
||||
*/
|
||||
public function save_unique_data($data) {
|
||||
|
@ -147,7 +148,7 @@ abstract class customcert_element_base {
|
|||
* to a template to be loaded later.
|
||||
* Can be overridden if more functionality is needed.
|
||||
*
|
||||
* @param stdClass $data the form data
|
||||
* @param \stdClass $data the form data
|
||||
* @return bool returns true if the data was saved to the template, false otherwise
|
||||
*/
|
||||
public function save_data_to_template($data) {
|
||||
|
@ -159,7 +160,7 @@ abstract class customcert_element_base {
|
|||
* from a template to an existing customcert.
|
||||
* Can be overridden if more functionality is needed.
|
||||
*
|
||||
* @param stdClass $data the form data
|
||||
* @param \stdClass $data the form data
|
||||
* @return bool returns true if the data was loaded from the template, false otherwise
|
||||
*/
|
||||
public function load_data_from_template($data) {
|
||||
|
@ -170,7 +171,7 @@ abstract class customcert_element_base {
|
|||
* Handles rendering the element on the pdf.
|
||||
* Must be overridden.
|
||||
*
|
||||
* @param pdf $pdf the pdf object
|
||||
* @param \pdf $pdf the pdf object
|
||||
* @param bool $preview true if it is a preview, false otherwise
|
||||
*/
|
||||
public abstract function render($pdf, $preview);
|
||||
|
@ -178,13 +179,13 @@ abstract class customcert_element_base {
|
|||
/**
|
||||
* Common behaviour for rendering specified content on the pdf.
|
||||
*
|
||||
* @param pdf $pdf the pdf object
|
||||
* @param \pdf $pdf the pdf object
|
||||
* @param string $content the content to render
|
||||
*/
|
||||
public function render_content($pdf, $content) {
|
||||
list($font, $attr) = $this->get_font();
|
||||
$pdf->setFont($font, $attr, $this->element->size);
|
||||
$fontcolour = TCPDF_COLORS::convertHTMLColorToDec($this->element->colour, $fontcolour);
|
||||
$fontcolour = \TCPDF_COLORS::convertHTMLColorToDec($this->element->colour, $fontcolour);
|
||||
$pdf->SetTextColor($fontcolour['R'], $fontcolour['G'], $fontcolour['B']);
|
||||
|
||||
$x = $this->element->posx;
|
||||
|
@ -251,7 +252,7 @@ abstract class customcert_element_base {
|
|||
$fontstyle .= ': font-style: italic';
|
||||
}
|
||||
$style = $fontstyle . '; color: ' . $this->element->colour . '; font-size: ' . $this->element->size . 'pt';
|
||||
return html_writer::tag('span', $content, array('style' => $style));
|
||||
return \html_writer::tag('span', $content, array('style' => $style));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -293,7 +294,7 @@ abstract class customcert_element_base {
|
|||
/**
|
||||
* Helper function to render the font elements.
|
||||
*
|
||||
* @param mod_customcert_edit_element_form $mform the edit_form instance.
|
||||
* @param \mod_customcert_edit_element_form $mform the edit_form instance.
|
||||
*/
|
||||
public function render_form_element_font($mform) {
|
||||
$mform->addElement('select', 'font', get_string('font', 'customcert'), customcert_get_fonts());
|
||||
|
@ -310,7 +311,7 @@ abstract class customcert_element_base {
|
|||
/**
|
||||
* Helper function to render the colour elements.
|
||||
*
|
||||
* @param mod_customcert_edit_element_form $mform the edit_form instance.
|
||||
* @param \mod_customcert_edit_element_form $mform the edit_form instance.
|
||||
*/
|
||||
public function render_form_element_colour($mform) {
|
||||
$mform->addElement('customcert_colourpicker', 'colour', get_string('fontcolour', 'customcert'));
|
||||
|
@ -322,7 +323,7 @@ abstract class customcert_element_base {
|
|||
/**
|
||||
* Helper function to render the position elements.
|
||||
*
|
||||
* @param mod_customcert_edit_element_form $mform the edit_form instance.
|
||||
* @param \mod_customcert_edit_element_form $mform the edit_form instance.
|
||||
*/
|
||||
public function render_form_element_position($mform) {
|
||||
$mform->addElement('text', 'posx', get_string('posx', 'customcert'), array('size' => 10));
|
||||
|
@ -435,7 +436,7 @@ abstract class customcert_element_base {
|
|||
* data will need to be updated if we are restoring the course as the course module id will
|
||||
* be different in the new course.
|
||||
*
|
||||
* @param restore_customcert_activity_task $restore
|
||||
* @param \restore_customcert_activity_task $restore
|
||||
*/
|
||||
public function after_restore($restore) {
|
||||
|
1
edit.php
1
edit.php
|
@ -27,7 +27,6 @@ require_once($CFG->dirroot . '/mod/customcert/locallib.php');
|
|||
require_once($CFG->dirroot . '/mod/customcert/edit_form.php');
|
||||
require_once($CFG->dirroot . '/mod/customcert/load_template_form.php');
|
||||
require_once($CFG->dirroot . '/mod/customcert/save_template_form.php');
|
||||
require_once($CFG->dirroot . '/mod/customcert/element/element.class.php');
|
||||
|
||||
$cmid = required_param('cmid', PARAM_INT);
|
||||
$moveup = optional_param('moveup', 0, PARAM_INT);
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
|
||||
require_once('../../config.php');
|
||||
require_once($CFG->dirroot . '/mod/customcert/edit_element_form.php');
|
||||
require_once($CFG->dirroot . '/mod/customcert/element/element.class.php');
|
||||
|
||||
$cmid = required_param('cmid', PARAM_INT);
|
||||
$action = required_param('action', PARAM_ALPHA);
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
||||
namespace customcertelement_border;
|
||||
|
||||
require_once($CFG->dirroot . '/mod/customcert/element/element.class.php');
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* The customcert element border's core interaction API.
|
||||
|
@ -25,12 +25,12 @@ require_once($CFG->dirroot . '/mod/customcert/element/element.class.php');
|
|||
* @copyright 2013 Mark Nelson <markn@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class customcert_element_border extends customcert_element_base {
|
||||
class element extends \mod_customcert\element {
|
||||
|
||||
/**
|
||||
* This function renders the form elements when adding a customcert element.
|
||||
*
|
||||
* @param mod_customcert_edit_element_form $mform the edit_form instance
|
||||
* @param \mod_customcert_edit_element_form $mform the edit_form instance
|
||||
*/
|
||||
public function render_form_elements($mform) {
|
||||
// We want to define the width of the border.
|
||||
|
@ -45,11 +45,11 @@ class customcert_element_border extends customcert_element_base {
|
|||
/**
|
||||
* Handles rendering the element on the pdf.
|
||||
*
|
||||
* @param pdf $pdf the pdf object
|
||||
* @param \pdf $pdf the pdf object
|
||||
* @param bool $preview true if it is a preview, false otherwise
|
||||
*/
|
||||
public function render($pdf, $preview) {
|
||||
$colour = TCPDF_COLORS::convertHTMLColorToDec($this->element->colour, $colour);
|
||||
$colour = \TCPDF_COLORS::convertHTMLColorToDec($this->element->colour, $colour);
|
||||
$pdf->SetLineStyle(array('width' => $this->element->data, 'color' => $colour));
|
||||
$pdf->Line(0, 0, $pdf->getPageWidth(), 0);
|
||||
$pdf->Line($pdf->getPageWidth(), 0, $pdf->getPageWidth(), $pdf->getPageHeight());
|
||||
|
@ -92,7 +92,7 @@ class customcert_element_border extends customcert_element_base {
|
|||
/**
|
||||
* Sets the data on the form when editing an element.
|
||||
*
|
||||
* @param mod_customcert_edit_element_form $mform the edit_form instance
|
||||
* @param \mod_customcert_edit_element_form $mform the edit_form instance
|
||||
*/
|
||||
public function definition_after_data($mform) {
|
||||
if (!empty($this->element->data)) {
|
||||
|
@ -105,7 +105,7 @@ class customcert_element_border extends customcert_element_base {
|
|||
* This will handle how form data will be saved into the data column in the
|
||||
* customcert_elements table.
|
||||
*
|
||||
* @param stdClass $data the form data
|
||||
* @param \stdClass $data the form data
|
||||
* @return string the json encoded array
|
||||
*/
|
||||
public function save_unique_data($data) {
|
|
@ -24,6 +24,6 @@
|
|||
|
||||
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
||||
|
||||
$plugin->version = 2015080500; // The current module version (Date: YYYYMMDDXX).
|
||||
$plugin->version = 2015121400; // The current module version (Date: YYYYMMDDXX).
|
||||
$plugin->requires = 2015051100; // Requires this Moodle version (2.9).
|
||||
$plugin->component = 'customcertelement_border';
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
||||
namespace customcertelement_categoryname;
|
||||
|
||||
require_once($CFG->dirroot . '/mod/customcert/element/element.class.php');
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* The customcert element categoryname's core interaction API.
|
||||
|
@ -25,12 +25,12 @@ require_once($CFG->dirroot . '/mod/customcert/element/element.class.php');
|
|||
* @copyright 2013 Mark Nelson <markn@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class customcert_element_categoryname extends customcert_element_base {
|
||||
class element extends \mod_customcert\element {
|
||||
|
||||
/**
|
||||
* Handles rendering the element on the pdf.
|
||||
*
|
||||
* @param pdf $pdf the pdf object
|
||||
* @param \pdf $pdf the pdf object
|
||||
* @param bool $preview true if it is a preview, false otherwise
|
||||
*/
|
||||
public function render($pdf, $preview) {
|
|
@ -24,6 +24,6 @@
|
|||
|
||||
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
||||
|
||||
$plugin->version = 2015080500; // The current module version (Date: YYYYMMDDXX).
|
||||
$plugin->version = 2015121400; // The current module version (Date: YYYYMMDDXX).
|
||||
$plugin->requires = 2015051100; // Requires this Moodle version (2.9).
|
||||
$plugin->component = 'customcertelement_categoryname';
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
||||
namespace customcertelement_code;
|
||||
|
||||
require_once($CFG->dirroot . '/mod/customcert/element/element.class.php');
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* The customcert element code's core interaction API.
|
||||
|
@ -25,12 +25,12 @@ require_once($CFG->dirroot . '/mod/customcert/element/element.class.php');
|
|||
* @copyright 2013 Mark Nelson <markn@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class customcert_element_code extends customcert_element_base {
|
||||
class element extends \mod_customcert\element {
|
||||
|
||||
/**
|
||||
* Handles rendering the element on the pdf.
|
||||
*
|
||||
* @param pdf $pdf the pdf object
|
||||
* @param \pdf $pdf the pdf object
|
||||
* @param bool $preview true if it is a preview, false otherwise
|
||||
*/
|
||||
public function render($pdf, $preview) {
|
|
@ -24,6 +24,6 @@
|
|||
|
||||
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
||||
|
||||
$plugin->version = 2015080500; // The current module version (Date: YYYYMMDDXX).
|
||||
$plugin->version = 2015121400; // The current module version (Date: YYYYMMDDXX).
|
||||
$plugin->requires = 2015051100; // Requires this Moodle version (2.9).
|
||||
$plugin->component = 'customcertelement_code';
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
||||
namespace customcertelement_coursename;
|
||||
|
||||
require_once($CFG->dirroot . '/mod/customcert/element/element.class.php');
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* The customcert element coursename's core interaction API.
|
||||
|
@ -25,12 +25,12 @@ require_once($CFG->dirroot . '/mod/customcert/element/element.class.php');
|
|||
* @copyright 2013 Mark Nelson <markn@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class customcert_element_coursename extends customcert_element_base {
|
||||
class element extends \mod_customcert\element {
|
||||
|
||||
/**
|
||||
* Handles rendering the element on the pdf.
|
||||
*
|
||||
* @param pdf $pdf the pdf object
|
||||
* @param \pdf $pdf the pdf object
|
||||
* @param bool $preview true if it is a preview, false otherwise
|
||||
*/
|
||||
public function render($pdf, $preview) {
|
|
@ -24,6 +24,6 @@
|
|||
|
||||
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
||||
|
||||
$plugin->version = 2015080500; // The current module version (Date: YYYYMMDDXX).
|
||||
$plugin->version = 2015121400; // The current module version (Date: YYYYMMDDXX).
|
||||
$plugin->requires = 2015051100; // Requires this Moodle version (2.9).
|
||||
$plugin->component = 'customcertelement_coursename';
|
||||
|
|
|
@ -14,10 +14,9 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
||||
namespace customcertelement_date;
|
||||
|
||||
require_once($CFG->dirroot . '/mod/customcert/element/element.class.php');
|
||||
require_once($CFG->dirroot . '/mod/customcert/element/grade/lib.php');
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Date - Issue
|
||||
|
@ -36,19 +35,19 @@ define('CUSTOMCERT_DATE_COMPLETION', '2');
|
|||
* @copyright 2013 Mark Nelson <markn@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class customcert_element_date extends customcert_element_base {
|
||||
class element extends \mod_customcert\element {
|
||||
|
||||
/**
|
||||
* This function renders the form elements when adding a customcert element.
|
||||
*
|
||||
* @param mod_customcert_edit_element_form $mform the edit_form instance
|
||||
* @param \mod_customcert_edit_element_form $mform the edit_form instance
|
||||
*/
|
||||
public function render_form_elements($mform) {
|
||||
// Get the possible date options.
|
||||
$dateoptions = array();
|
||||
$dateoptions[CUSTOMCERT_DATE_ISSUE] = get_string('issueddate', 'customcertelement_date');
|
||||
$dateoptions[CUSTOMCERT_DATE_COMPLETION] = get_string('completiondate', 'customcertelement_date');
|
||||
$dateoptions = $dateoptions + customcert_element_grade::get_grade_items();
|
||||
$dateoptions = $dateoptions + \customcertelement_grade\element::get_grade_items();;
|
||||
|
||||
$mform->addElement('select', 'dateitem', get_string('dateitem', 'customcertelement_date'), $dateoptions);
|
||||
$mform->addHelpButton('dateitem', 'dateitem', 'customcertelement_date');
|
||||
|
@ -63,7 +62,7 @@ class customcert_element_date extends customcert_element_base {
|
|||
* This will handle how form data will be saved into the data column in the
|
||||
* customcert_elements table.
|
||||
*
|
||||
* @param stdClass $data the form data
|
||||
* @param \stdClass $data the form data
|
||||
* @return string the json encoded array
|
||||
*/
|
||||
public function save_unique_data($data) {
|
||||
|
@ -80,7 +79,7 @@ class customcert_element_date extends customcert_element_base {
|
|||
/**
|
||||
* Handles rendering the element on the pdf.
|
||||
*
|
||||
* @param pdf $pdf the pdf object
|
||||
* @param \pdf $pdf the pdf object
|
||||
* @param bool $preview true if it is a preview, false otherwise
|
||||
*/
|
||||
public function render($pdf, $preview) {
|
||||
|
@ -119,10 +118,10 @@ class customcert_element_date extends customcert_element_base {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
$gradeitem = new stdClass();
|
||||
$gradeitem = new \stdClass();
|
||||
$gradeitem->gradeitem = $dateitem;
|
||||
$gradeitem->gradeformat = GRADE_DISPLAY_TYPE_PERCENTAGE;
|
||||
if ($modinfo = customcert_element_grade::get_grade($gradeitem, $issue->userid)) {
|
||||
if ($modinfo = \customcertelement_grade\element::get_grade($gradeitem, $issue->userid)) {
|
||||
$date = $modinfo->dategraded;
|
||||
}
|
||||
}
|
||||
|
@ -156,7 +155,7 @@ class customcert_element_date extends customcert_element_base {
|
|||
/**
|
||||
* Sets the data on the form when editing an element.
|
||||
*
|
||||
* @param mod_customcert_edit_element_form $mform the edit_form instance
|
||||
* @param \mod_customcert_edit_element_form $mform the edit_form instance
|
||||
*/
|
||||
public function definition_after_data($mform) {
|
||||
// Set the item and format for this element.
|
||||
|
@ -175,13 +174,13 @@ class customcert_element_date extends customcert_element_base {
|
|||
* We will want to update the course module the date element is pointing to as it will
|
||||
* have changed in the course restore.
|
||||
*
|
||||
* @param restore_customcert_activity_task $restore
|
||||
* @param \restore_customcert_activity_task $restore
|
||||
*/
|
||||
public function after_restore($restore) {
|
||||
global $DB;
|
||||
|
||||
$dateinfo = json_decode($this->element->data);
|
||||
if ($newitem = restore_dbops::get_backup_ids_record($restore->get_restoreid(), 'course_module', $dateinfo->dateitem)) {
|
||||
if ($newitem = \restore_dbops::get_backup_ids_record($restore->get_restoreid(), 'course_module', $dateinfo->dateitem)) {
|
||||
$dateinfo->dateitem = $newitem->newitemid;
|
||||
$DB->set_field('customcert_elements', 'data', self::save_unique_data($dateinfo), array('id' => $this->element->id));
|
||||
}
|
|
@ -24,6 +24,6 @@
|
|||
|
||||
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
||||
|
||||
$plugin->version = 2015080500; // The current module version (Date: YYYYMMDDXX).
|
||||
$plugin->version = 2015121400; // The current module version (Date: YYYYMMDDXX).
|
||||
$plugin->requires = 2015051100; // Requires this Moodle version (2.9).
|
||||
$plugin->component = 'customcertelement_date';
|
||||
|
|
|
@ -14,9 +14,10 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
||||
namespace customcertelement_grade;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once($CFG->dirroot . '/mod/customcert/element/element.class.php');
|
||||
require_once($CFG->libdir . '/grade/constants.php');
|
||||
require_once($CFG->dirroot . '/grade/lib.php');
|
||||
require_once($CFG->dirroot . '/grade/querylib.php');
|
||||
|
@ -33,12 +34,12 @@ define('CUSTOMCERT_GRADE_COURSE', '0');
|
|||
* @copyright 2013 Mark Nelson <markn@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class customcert_element_grade extends customcert_element_base {
|
||||
class element extends \mod_customcert\element {
|
||||
|
||||
/**
|
||||
* This function renders the form elements when adding a customcert element.
|
||||
*
|
||||
* @param mod_customcert_edit_element_form $mform the edit_form instance
|
||||
* @param \mod_customcert_edit_element_form $mform the edit_form instance
|
||||
*/
|
||||
public function render_form_elements($mform) {
|
||||
// Get the grade items we can display.
|
||||
|
@ -63,7 +64,7 @@ class customcert_element_grade extends customcert_element_base {
|
|||
* This will handle how form data will be saved into the data column in the
|
||||
* customcert_elements table.
|
||||
*
|
||||
* @param stdClass $data the form data.
|
||||
* @param \stdClass $data the form data.
|
||||
* @return string the json encoded array
|
||||
*/
|
||||
public function save_unique_data($data) {
|
||||
|
@ -80,7 +81,7 @@ class customcert_element_grade extends customcert_element_base {
|
|||
/**
|
||||
* Handles rendering the element on the pdf.
|
||||
*
|
||||
* @param pdf $pdf the pdf object
|
||||
* @param \pdf $pdf the pdf object
|
||||
* @param bool $preview true if it is a preview, false otherwise
|
||||
*/
|
||||
public function render($pdf, $preview) {
|
||||
|
@ -96,7 +97,7 @@ class customcert_element_grade extends customcert_element_base {
|
|||
|
||||
// If we are previewing this certificate then just show a demonstration grade.
|
||||
if ($preview) {
|
||||
$courseitem = grade_item::fetch_course_item($COURSE->id);
|
||||
$courseitem = \grade_item::fetch_course_item($COURSE->id);
|
||||
$grade = grade_format_gradevalue('100', $courseitem, true, $gradeinfo->gradeformat, 2);
|
||||
} else {
|
||||
// Get the grade for the grade item.
|
||||
|
@ -123,7 +124,7 @@ class customcert_element_grade extends customcert_element_base {
|
|||
// Decode the information stored in the database.
|
||||
$gradeinfo = json_decode($this->element->data);
|
||||
|
||||
$courseitem = grade_item::fetch_course_item($COURSE->id);
|
||||
$courseitem = \grade_item::fetch_course_item($COURSE->id);
|
||||
// Define how many decimals to display.
|
||||
$decimals = 2;
|
||||
if ($gradeinfo->gradeformat == GRADE_DISPLAY_TYPE_PERCENTAGE) {
|
||||
|
@ -137,7 +138,7 @@ class customcert_element_grade extends customcert_element_base {
|
|||
/**
|
||||
* Sets the data on the form when editing an element.
|
||||
*
|
||||
* @param mod_customcert_edit_element_form $mform the edit_form instance
|
||||
* @param \mod_customcert_edit_element_form $mform the edit_form instance
|
||||
*/
|
||||
public function definition_after_data($mform) {
|
||||
// Set the item and format for this element.
|
||||
|
@ -156,13 +157,13 @@ class customcert_element_grade extends customcert_element_base {
|
|||
* We will want to update the course module the grade element is pointing to as it will
|
||||
* have changed in the course restore.
|
||||
*
|
||||
* @param restore_customcert_activity_task $restore
|
||||
* @param \restore_customcert_activity_task $restore
|
||||
*/
|
||||
public function after_restore($restore) {
|
||||
global $DB;
|
||||
|
||||
$gradeinfo = json_decode($this->element->data);
|
||||
if ($newitem = restore_dbops::get_backup_ids_record($restore->get_restoreid(), 'course_module', $gradeinfo->gradeitem)) {
|
||||
if ($newitem = \restore_dbops::get_backup_ids_record($restore->get_restoreid(), 'course_module', $gradeinfo->gradeitem)) {
|
||||
$gradeinfo->gradeitem = $newitem->newitemid;
|
||||
$DB->set_field('customcert_elements', 'data', self::save_unique_data($gradeinfo), array('id' => $this->element->id));
|
||||
}
|
||||
|
@ -245,7 +246,7 @@ class customcert_element_grade extends customcert_element_base {
|
|||
/**
|
||||
* Helper function to return the grade to display.
|
||||
*
|
||||
* @param stdClass $gradeinfo
|
||||
* @param \stdClass $gradeinfo
|
||||
* @param int $userid
|
||||
* @return string the grade result
|
||||
*/
|
||||
|
@ -258,10 +259,10 @@ class customcert_element_grade extends customcert_element_base {
|
|||
|
||||
// Check if we are displaying the course grade.
|
||||
if ($gradeitem == CUSTOMCERT_GRADE_COURSE) {
|
||||
if ($courseitem = grade_item::fetch_course_item($COURSE->id)) {
|
||||
if ($courseitem = \grade_item::fetch_course_item($COURSE->id)) {
|
||||
// Set the grade type we want.
|
||||
$courseitem->gradetype = GRADE_TYPE_VALUE;
|
||||
$grade = new grade_grade(array('itemid' => $courseitem->id, 'userid' => $userid));
|
||||
$grade = new \grade_grade(array('itemid' => $courseitem->id, 'userid' => $userid));
|
||||
$coursegrade = grade_format_gradevalue($grade->finalgrade, $courseitem, true, $gradeformat, 2);
|
||||
return $coursegrade;
|
||||
}
|
||||
|
@ -281,7 +282,7 @@ class customcert_element_grade extends customcert_element_base {
|
|||
* @param int $moduleid
|
||||
* @param int $gradeformat
|
||||
* @param int $userid
|
||||
* @return stdClass the grade information
|
||||
* @return \stdClass the grade information
|
||||
*/
|
||||
public static function get_mod_grade($moduleid, $gradeformat, $userid) {
|
||||
global $DB;
|
||||
|
@ -291,7 +292,7 @@ class customcert_element_grade extends customcert_element_base {
|
|||
|
||||
$gradeitem = grade_get_grades($cm->course, 'mod', $module->name, $cm->instance, $userid);
|
||||
if (!empty($gradeitem)) {
|
||||
$item = new grade_item();
|
||||
$item = new \grade_item();
|
||||
$item->gradetype = GRADE_TYPE_VALUE;
|
||||
$item->courseid = $cm->course;
|
||||
$itemproperties = reset($gradeitem->items);
|
||||
|
@ -307,7 +308,7 @@ class customcert_element_grade extends customcert_element_base {
|
|||
}
|
||||
|
||||
// Create the object we will be returning.
|
||||
$modinfo = new stdClass;
|
||||
$modinfo = new \stdClass;
|
||||
$modinfo->name = $DB->get_field($module->name, 'name', array('id' => $cm->instance));
|
||||
$modinfo->gradetodisplay = grade_format_gradevalue($grade, $item, true, $gradeformat, $decimals);
|
||||
|
|
@ -24,6 +24,6 @@
|
|||
|
||||
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
||||
|
||||
$plugin->version = 2015080500; // The current module version (Date: YYYYMMDDXX).
|
||||
$plugin->version = 2015121400; // The current module version (Date: YYYYMMDDXX).
|
||||
$plugin->requires = 2015051100; // Requires this Moodle version (2.9).
|
||||
$plugin->component = 'customcertelement_grade';
|
||||
|
|
|
@ -14,10 +14,9 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
||||
namespace customcertelement_gradeitemname;
|
||||
|
||||
require_once($CFG->dirroot . '/mod/customcert/element/element.class.php');
|
||||
require_once($CFG->dirroot . '/mod/customcert/element/grade/lib.php');
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* The customcert element gradeitemname's core interaction API.
|
||||
|
@ -26,16 +25,16 @@ require_once($CFG->dirroot . '/mod/customcert/element/grade/lib.php');
|
|||
* @copyright 2013 Mark Nelson <markn@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class customcert_element_gradeitemname extends customcert_element_base {
|
||||
class element extends \mod_customcert\element {
|
||||
|
||||
/**
|
||||
* This function renders the form elements when adding a customcert element.
|
||||
*
|
||||
* @param mod_customcert_edit_element_form $mform the edit_form instance
|
||||
* @param \mod_customcert_edit_element_form $mform the edit_form instance
|
||||
*/
|
||||
public function render_form_elements($mform) {
|
||||
$mform->addElement('select', 'gradeitem', get_string('gradeitem', 'customcertelement_gradeitemname'),
|
||||
customcert_element_grade::get_grade_items());
|
||||
\customcertelement_grade\element::get_grade_items());
|
||||
$mform->addHelpButton('gradeitem', 'gradeitem', 'customcertelement_gradeitemname');
|
||||
|
||||
parent::render_form_elements($mform);
|
||||
|
@ -45,7 +44,7 @@ class customcert_element_gradeitemname extends customcert_element_base {
|
|||
* This will handle how form data will be saved into the data column in the
|
||||
* customcert_elements table.
|
||||
*
|
||||
* @param stdClass $data the form data
|
||||
* @param \stdClass $data the form data
|
||||
* @return string the text
|
||||
*/
|
||||
public function save_unique_data($data) {
|
||||
|
@ -59,7 +58,7 @@ class customcert_element_gradeitemname extends customcert_element_base {
|
|||
/**
|
||||
* Handles rendering the element on the pdf.
|
||||
*
|
||||
* @param pdf $pdf the pdf object
|
||||
* @param \pdf $pdf the pdf object
|
||||
* @param bool $preview true if it is a preview, false otherwise
|
||||
*/
|
||||
public function render($pdf, $preview) {
|
||||
|
@ -103,7 +102,7 @@ class customcert_element_gradeitemname extends customcert_element_base {
|
|||
/**
|
||||
* Sets the data on the form when editing an element.
|
||||
*
|
||||
* @param mod_customcert_edit_element_form $mform the edit_form instance
|
||||
* @param \mod_customcert_edit_element_form $mform the edit_form instance
|
||||
*/
|
||||
public function definition_after_data($mform) {
|
||||
if (!empty($this->element->data)) {
|
|
@ -24,6 +24,6 @@
|
|||
|
||||
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
||||
|
||||
$plugin->version = 2015080500; // The current module version (Date: YYYYMMDDXX).
|
||||
$plugin->version = 2015121400; // The current module version (Date: YYYYMMDDXX).
|
||||
$plugin->requires = 2015051100; // Requires this Moodle version (2.9).
|
||||
$plugin->component = 'customcertelement_gradeitemname';
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
||||
namespace customcertelement_image;
|
||||
|
||||
require_once($CFG->dirroot . '/mod/customcert/element/element.class.php');
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* The customcert element image's core interaction API.
|
||||
|
@ -25,14 +25,14 @@ require_once($CFG->dirroot . '/mod/customcert/element/element.class.php');
|
|||
* @copyright 2013 Mark Nelson <markn@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class customcert_element_image extends customcert_element_base {
|
||||
class element extends \mod_customcert\element {
|
||||
|
||||
private $filemanageroptions = array();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param stdClass $element the element data
|
||||
* @param \stdClass $element the element data
|
||||
*/
|
||||
public function __construct($element) {
|
||||
global $COURSE;
|
||||
|
@ -49,7 +49,7 @@ class customcert_element_image extends customcert_element_base {
|
|||
/**
|
||||
* This function renders the form elements when adding a customcert element.
|
||||
*
|
||||
* @param mod_customcert_edit_element_form $mform the edit_form instance
|
||||
* @param \mod_customcert_edit_element_form $mform the edit_form instance
|
||||
*/
|
||||
public function render_form_elements($mform) {
|
||||
$mform->addElement('select', 'image', get_string('image', 'customcertelement_image'), self::get_images());
|
||||
|
@ -108,13 +108,13 @@ class customcert_element_image extends customcert_element_base {
|
|||
* Handles saving the form elements created by this element.
|
||||
* Can be overridden if more functionality is needed.
|
||||
*
|
||||
* @param stdClass $data the form data
|
||||
* @param \stdClass $data the form data
|
||||
*/
|
||||
public function save_form_elements($data) {
|
||||
global $COURSE;
|
||||
|
||||
// Handle file uploads.
|
||||
customcert_upload_imagefiles($data->customcertimage, context_course::instance($COURSE->id)->id);
|
||||
customcert_upload_imagefiles($data->customcertimage, \context_course::instance($COURSE->id)->id);
|
||||
|
||||
parent::save_form_elements($data);
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ class customcert_element_image extends customcert_element_base {
|
|||
* This will handle how form data will be saved into the data column in the
|
||||
* customcert_elements table.
|
||||
*
|
||||
* @param stdClass $data the form data
|
||||
* @param \stdClass $data the form data
|
||||
* @return string the json encoded array
|
||||
*/
|
||||
public function save_unique_data($data) {
|
||||
|
@ -140,7 +140,7 @@ class customcert_element_image extends customcert_element_base {
|
|||
/**
|
||||
* Handles rendering the element on the pdf.
|
||||
*
|
||||
* @param pdf $pdf the pdf object
|
||||
* @param \pdf $pdf the pdf object
|
||||
* @param bool $preview true if it is a preview, false otherwise
|
||||
*/
|
||||
public function render($pdf, $preview) {
|
||||
|
@ -181,7 +181,7 @@ class customcert_element_image extends customcert_element_base {
|
|||
// Get the image.
|
||||
$fs = get_file_storage();
|
||||
if ($file = $fs->get_file_by_hash($imageinfo->pathnamehash)) {
|
||||
$url = moodle_url::make_pluginfile_url($file->get_contextid(), 'mod_customcert', 'image', $file->get_itemid(),
|
||||
$url = \moodle_url::make_pluginfile_url($file->get_contextid(), 'mod_customcert', 'image', $file->get_itemid(),
|
||||
$file->get_filepath(), $file->get_filename());
|
||||
$fileimageinfo = $file->get_imageinfo();
|
||||
$whratio = $fileimageinfo['width'] / $fileimageinfo['height'];
|
||||
|
@ -203,14 +203,14 @@ class customcert_element_image extends customcert_element_base {
|
|||
$style .= 'height: ' . $imageinfo->height . 'mm';
|
||||
}
|
||||
|
||||
return html_writer::tag('img', '', array('src' => $url, 'style' => $style));
|
||||
return \html_writer::tag('img', '', array('src' => $url, 'style' => $style));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the data on the form when editing an element.
|
||||
*
|
||||
* @param mod_customcert_edit_element_form $mform the edit_form instance
|
||||
* @param \mod_customcert_edit_element_form $mform the edit_form instance
|
||||
*/
|
||||
public function definition_after_data($mform) {
|
||||
global $COURSE;
|
||||
|
@ -225,7 +225,7 @@ class customcert_element_image extends customcert_element_base {
|
|||
|
||||
// Editing existing instance - copy existing files into draft area.
|
||||
$draftitemid = file_get_submitted_draft_itemid('customcertimage');
|
||||
file_prepare_draft_area($draftitemid, context_course::instance($COURSE->id)->id, 'mod_customcert', 'image', 0, $this->filemanageroptions);
|
||||
file_prepare_draft_area($draftitemid, \context_course::instance($COURSE->id)->id, 'mod_customcert', 'image', 0, $this->filemanageroptions);
|
||||
$element = $mform->getElement('customcertimage');
|
||||
$element->setValue($draftitemid);
|
||||
|
||||
|
@ -246,19 +246,19 @@ class customcert_element_image extends customcert_element_base {
|
|||
// The array used to store the images.
|
||||
$arrfiles = array();
|
||||
// Loop through the files uploaded in the system context.
|
||||
if ($files = $fs->get_area_files(context_system::instance()->id, 'mod_customcert', 'image', false, 'filename', false)) {
|
||||
if ($files = $fs->get_area_files(\context_system::instance()->id, 'mod_customcert', 'image', false, 'filename', false)) {
|
||||
foreach ($files as $hash => $file) {
|
||||
$arrfiles[$hash] = $file->get_filename();
|
||||
}
|
||||
}
|
||||
// Loop through the files uploaded in the course context.
|
||||
if ($files = $fs->get_area_files(context_course::instance($COURSE->id)->id, 'mod_customcert', 'image', false, 'filename', false)) {
|
||||
if ($files = $fs->get_area_files(\context_course::instance($COURSE->id)->id, 'mod_customcert', 'image', false, 'filename', false)) {
|
||||
foreach ($files as $hash => $file) {
|
||||
$arrfiles[$hash] = $file->get_filename();
|
||||
}
|
||||
}
|
||||
|
||||
core_collator::asort($arrfiles);
|
||||
\core_collator::asort($arrfiles);
|
||||
$arrfiles = array_merge(array('0' => get_string('noimage', 'customcert')), $arrfiles);
|
||||
|
||||
return $arrfiles;
|
|
@ -24,6 +24,6 @@
|
|||
|
||||
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
||||
|
||||
$plugin->version = 2015080500; // The current module version (Date: YYYYMMDDXX).
|
||||
$plugin->version = 2015121400; // The current module version (Date: YYYYMMDDXX).
|
||||
$plugin->requires = 2015051100; // Requires this Moodle version (2.9).
|
||||
$plugin->component = 'customcertelement_image';
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
||||
namespace customcertelement_studentname;
|
||||
|
||||
require_once($CFG->dirroot . '/mod/customcert/element/element.class.php');
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* The customcert element studentname's core interaction API.
|
||||
|
@ -25,12 +25,12 @@ require_once($CFG->dirroot . '/mod/customcert/element/element.class.php');
|
|||
* @copyright 2013 Mark Nelson <markn@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class customcert_element_studentname extends customcert_element_base {
|
||||
class element extends \mod_customcert\element {
|
||||
|
||||
/**
|
||||
* Handles rendering the element on the pdf.
|
||||
*
|
||||
* @param pdf $pdf the pdf object
|
||||
* @param \pdf $pdf the pdf object
|
||||
* @param bool $preview true if it is a preview, false otherwise
|
||||
*/
|
||||
public function render($pdf, $preview) {
|
|
@ -24,6 +24,6 @@
|
|||
|
||||
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
||||
|
||||
$plugin->version = 2015080500; // The current module version (Date: YYYYMMDDXX).
|
||||
$plugin->version = 2015121400; // The current module version (Date: YYYYMMDDXX).
|
||||
$plugin->requires = 2015051100; // Requires this Moodle version (2.9).
|
||||
$plugin->component = 'customcertelement_studentname';
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
||||
namespace customcertelement_teachername;
|
||||
|
||||
require_once($CFG->dirroot . '/mod/customcert/element/element.class.php');
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* The customcert element teachername's core interaction API.
|
||||
|
@ -25,12 +25,12 @@ require_once($CFG->dirroot . '/mod/customcert/element/element.class.php');
|
|||
* @copyright 2013 Mark Nelson <markn@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class customcert_element_teachername extends customcert_element_base {
|
||||
class element extends \mod_customcert\element {
|
||||
|
||||
/**
|
||||
* This function renders the form elements when adding a customcert element.
|
||||
*
|
||||
* @param mod_customcert_edit_element_form $mform the edit_form instance
|
||||
* @param \mod_customcert_edit_element_form $mform the edit_form instance
|
||||
*/
|
||||
public function render_form_elements($mform) {
|
||||
$mform->addElement('select', 'teacher', get_string('teacher', 'customcertelement_teachername'),
|
||||
|
@ -44,7 +44,7 @@ class customcert_element_teachername extends customcert_element_base {
|
|||
* This will handle how form data will be saved into the data column in the
|
||||
* customcert_elements table.
|
||||
*
|
||||
* @param stdClass $data the form data
|
||||
* @param \stdClass $data the form data
|
||||
* @return string the text
|
||||
*/
|
||||
public function save_unique_data($data) {
|
||||
|
@ -54,7 +54,7 @@ class customcert_element_teachername extends customcert_element_base {
|
|||
/**
|
||||
* Handles rendering the element on the pdf.
|
||||
*
|
||||
* @param pdf $pdf the pdf object
|
||||
* @param \pdf $pdf the pdf object
|
||||
* @param bool $preview true if it is a preview, false otherwise
|
||||
*/
|
||||
public function render($pdf, $preview) {
|
||||
|
@ -94,7 +94,7 @@ class customcert_element_teachername extends customcert_element_base {
|
|||
$teachers = array();
|
||||
|
||||
// Now return all users who can manage the customcert in this context.
|
||||
if ($users = get_users_by_capability(context_module::instance($cmid), 'mod/customcert:manage')) {
|
||||
if ($users = get_users_by_capability(\context_module::instance($cmid), 'mod/customcert:manage')) {
|
||||
foreach ($users as $user) {
|
||||
$teachers[$user->id] = fullname($user);
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ class customcert_element_teachername extends customcert_element_base {
|
|||
/**
|
||||
* Sets the data on the form when editing an element.
|
||||
*
|
||||
* @param mod_customcert_edit_element_form $mform the edit_form instance
|
||||
* @param \mod_customcert_edit_element_form $mform the edit_form instance
|
||||
*/
|
||||
public function definition_after_data($mform) {
|
||||
if (!empty($this->element->data)) {
|
|
@ -24,6 +24,6 @@
|
|||
|
||||
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
||||
|
||||
$plugin->version = 2015080500; // The current module version (Date: YYYYMMDDXX).
|
||||
$plugin->version = 2015121400; // The current module version (Date: YYYYMMDDXX).
|
||||
$plugin->requires = 2015051100; // Requires this Moodle version (2.9).
|
||||
$plugin->component = 'customcertelement_teachername';
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
||||
namespace customcertelement_text;
|
||||
|
||||
require_once($CFG->dirroot . '/mod/customcert/element/element.class.php');
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* The customcert element text's core interaction API.
|
||||
|
@ -25,12 +25,12 @@ require_once($CFG->dirroot . '/mod/customcert/element/element.class.php');
|
|||
* @copyright 2013 Mark Nelson <markn@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class customcert_element_text extends customcert_element_base {
|
||||
class element extends \mod_customcert\element {
|
||||
|
||||
/**
|
||||
* This function renders the form elements when adding a customcert element.
|
||||
*
|
||||
* @param mod_customcert_edit_element_form $mform the edit_form instance
|
||||
* @param \mod_customcert_edit_element_form $mform the edit_form instance
|
||||
*/
|
||||
public function render_form_elements($mform) {
|
||||
$mform->addElement('textarea', 'text', get_string('text', 'customcertelement_text'));
|
||||
|
@ -44,7 +44,7 @@ class customcert_element_text extends customcert_element_base {
|
|||
* This will handle how form data will be saved into the data column in the
|
||||
* customcert_elements table.
|
||||
*
|
||||
* @param stdClass $data the form data
|
||||
* @param \stdClass $data the form data
|
||||
* @return string the text
|
||||
*/
|
||||
public function save_unique_data($data) {
|
||||
|
@ -54,7 +54,7 @@ class customcert_element_text extends customcert_element_base {
|
|||
/**
|
||||
* Handles rendering the element on the pdf.
|
||||
*
|
||||
* @param pdf $pdf the pdf object
|
||||
* @param \pdf $pdf the pdf object
|
||||
* @param bool $preview true if it is a preview, false otherwise
|
||||
*/
|
||||
public function render($pdf, $preview) {
|
||||
|
@ -74,7 +74,7 @@ class customcert_element_text extends customcert_element_base {
|
|||
/**
|
||||
* Sets the data on the form when editing an element.
|
||||
*
|
||||
* @param mod_customcert_edit_element_form $mform the edit_form instance
|
||||
* @param \mod_customcert_edit_element_form $mform the edit_form instance
|
||||
*/
|
||||
public function definition_after_data($mform) {
|
||||
if (!empty($this->element->data)) {
|
|
@ -24,6 +24,6 @@
|
|||
|
||||
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
||||
|
||||
$plugin->version = 2015080500; // The current module version (Date: YYYYMMDDXX).
|
||||
$plugin->version = 2015121400; // The current module version (Date: YYYYMMDDXX).
|
||||
$plugin->requires = 2015051100; // Requires this Moodle version (2.9).
|
||||
$plugin->component = 'customcertelement_text';
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
||||
namespace customcertelement_userfield;
|
||||
|
||||
require_once($CFG->dirroot . '/mod/customcert/element/element.class.php');
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* The customcert element userfield's core interaction API.
|
||||
|
@ -25,12 +25,12 @@ require_once($CFG->dirroot . '/mod/customcert/element/element.class.php');
|
|||
* @copyright 2013 Mark Nelson <markn@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class customcert_element_userfield extends customcert_element_base {
|
||||
class element extends \mod_customcert\element {
|
||||
|
||||
/**
|
||||
* This function renders the form elements when adding a customcert element.
|
||||
*
|
||||
* @param mod_customcert_edit_element_form $mform the edit_form instance
|
||||
* @param \mod_customcert_edit_element_form $mform the edit_form instance
|
||||
*/
|
||||
public function render_form_elements($mform) {
|
||||
// Get the user profile fields.
|
||||
|
@ -61,7 +61,7 @@ class customcert_element_userfield extends customcert_element_base {
|
|||
}
|
||||
// Combine the two.
|
||||
$fields = $userfields + $customfields;
|
||||
core_collator::asort($fields);
|
||||
\core_collator::asort($fields);
|
||||
|
||||
// Create the select box where the user field is selected.
|
||||
$mform->addElement('select', 'userfield', get_string('userfield', 'customcertelement_userfield'), $fields);
|
||||
|
@ -75,7 +75,7 @@ class customcert_element_userfield extends customcert_element_base {
|
|||
* This will handle how form data will be saved into the data column in the
|
||||
* customcert_elements table.
|
||||
*
|
||||
* @param stdClass $data the form data
|
||||
* @param \stdClass $data the form data
|
||||
* @return string the text
|
||||
*/
|
||||
public function save_unique_data($data) {
|
||||
|
@ -85,7 +85,7 @@ class customcert_element_userfield extends customcert_element_base {
|
|||
/**
|
||||
* Handles rendering the element on the pdf.
|
||||
*
|
||||
* @param pdf $pdf the pdf object
|
||||
* @param \pdf $pdf the pdf object
|
||||
* @param bool $preview true if it is a preview, false otherwise
|
||||
*/
|
||||
public function render($pdf, $preview) {
|
||||
|
@ -133,7 +133,7 @@ class customcert_element_userfield extends customcert_element_base {
|
|||
/**
|
||||
* Sets the data on the form when editing an element.
|
||||
*
|
||||
* @param mod_customcert_edit_element_form $mform the edit_form instance
|
||||
* @param \mod_customcert_edit_element_form $mform the edit_form instance
|
||||
*/
|
||||
public function definition_after_data($mform) {
|
||||
if (!empty($this->element->data)) {
|
|
@ -24,6 +24,6 @@
|
|||
|
||||
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
||||
|
||||
$plugin->version = 2015080500; // The current module version (Date: YYYYMMDDXX).
|
||||
$plugin->version = 2015121400; // The current module version (Date: YYYYMMDDXX).
|
||||
$plugin->requires = 2015051100; // Requires this Moodle version (2.9).
|
||||
$plugin->component = 'customcertelement_userfield';
|
||||
|
|
20
locallib.php
20
locallib.php
|
@ -121,13 +121,13 @@ function customcert_get_elements() {
|
|||
if (!$elementfolder->isDir() || $elementfolder->isDot()) {
|
||||
continue;
|
||||
}
|
||||
// Check that the standard class file exists, if not we do
|
||||
// Check that the standard class exists, if not we do
|
||||
// not want to display it as an option as it will not work.
|
||||
$foldername = $elementfolder->getFilename();
|
||||
$classfile = "$elementdir/$foldername/lib.php";
|
||||
if (file_exists($classfile)) {
|
||||
// Need to require this file in case if we choose to add this element.
|
||||
require_once($classfile);
|
||||
// Get the class name.
|
||||
$classname = '\\customcertelement_' . $foldername . '\\element';
|
||||
// Ensure the necessary class exists.
|
||||
if (class_exists($classname)) {
|
||||
$component = "customcertelement_{$foldername}";
|
||||
$options[$foldername] = get_string('pluginname', $component);
|
||||
}
|
||||
|
@ -246,13 +246,11 @@ function customcert_save_page_data($data) {
|
|||
* class does not exists.
|
||||
*/
|
||||
function customcert_get_element_instance($element) {
|
||||
global $CFG;
|
||||
// Get the class name.
|
||||
$classname = '\\customcertelement_' . $element->element . '\\element';
|
||||
|
||||
$classfile = "$CFG->dirroot/mod/customcert/element/{$element->element}/lib.php";
|
||||
// Ensure this necessary file exists.
|
||||
if (file_exists($classfile)) {
|
||||
require_once($classfile);
|
||||
$classname = "customcert_element_{$element->element}";
|
||||
// Ensure the necessary class exists.
|
||||
if (class_exists($classname)) {
|
||||
return new $classname($element);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
||||
|
||||
$plugin->version = 2015120801; // The current module version (Date: YYYYMMDDXX).
|
||||
$plugin->version = 2015121400; // The current module version (Date: YYYYMMDDXX).
|
||||
$plugin->requires = 2015051100; // Requires this Moodle version (2.9).
|
||||
$plugin->cron = 0; // Period for cron to check this module (secs).
|
||||
$plugin->component = 'mod_customcert';
|
||||
|
|
Loading…
Reference in a new issue