From 05c1c00cc0b87bdef4db89984b6b450d8c3c181b Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Wed, 6 May 2020 14:57:27 +0200 Subject: [PATCH] Revert "Add new Outcome element (#329)" This reverts commit 3e26a6b7c1ae71389633c0fed10e14d96bc36bcc. This logic should be in the Grade element. --- element/outcome/classes/element.php | 158 ------------------ element/outcome/classes/privacy/provider.php | 46 ----- .../lang/en/customcertelement_outcome.php | 27 --- element/outcome/version.php | 29 ---- tests/behat/managing_elements.feature | 28 ---- 5 files changed, 288 deletions(-) delete mode 100644 element/outcome/classes/element.php delete mode 100644 element/outcome/classes/privacy/provider.php delete mode 100644 element/outcome/lang/en/customcertelement_outcome.php delete mode 100644 element/outcome/version.php diff --git a/element/outcome/classes/element.php b/element/outcome/classes/element.php deleted file mode 100644 index 1306aa8..0000000 --- a/element/outcome/classes/element.php +++ /dev/null @@ -1,158 +0,0 @@ -. - -/** - * This file contains the customcert element outcome's core interaction API. - * - * @package customcertelement_outcome - * @copyright 2020 Mark Nelson - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -namespace customcertelement_outcome; - -defined('MOODLE_INTERNAL') || die(); - -/** - * The customcert element outcome's core interaction API. - * - * @package customcertelement_outcome - * @copyright 2020 Mark Nelson - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class element extends \mod_customcert\element { - - /** - * This function renders the form elements when adding a customcert element. - * - * @param \MoodleQuickForm $mform the edit_form instance - */ - public function render_form_elements($mform) { - global $COURSE; - - // Get grade items with outcomes/scales attached to them. - $gradeitems = \grade_item::fetch_all( - [ - 'courseid' => $COURSE->id, - 'gradetype' => GRADE_TYPE_SCALE - ] - ); - - $selectoutcomes = []; - foreach ($gradeitems as $gradeitem) { - // Get the name of the activity. - $cm = get_coursemodule_from_instance($gradeitem->itemmodule, $gradeitem->iteminstance, $COURSE->id); - $modcontext = \context_module::instance($cm->id); - $modname = format_string($cm->name, true, array('context' => $modcontext)); - - $optionname = $modname . " - " . $gradeitem->get_name(); - $selectoutcomes[$gradeitem->id] = $optionname; - } - asort($selectoutcomes); - - $mform->addElement('select', 'gradeitem', get_string('outcome', 'customcertelement_outcome'), $selectoutcomes); - - parent::render_form_elements($mform); - } - - /** - * This will handle how form data will be saved into the data column in the - * customcert_elements table. - * - * @param \stdClass $data the form data - * @return string the json encoded array - */ - public function save_unique_data($data) { - if (!empty($data->gradeitem)) { - return $data->gradeitem; - } - - return ''; - } - - /** - * Handles rendering the element on the pdf. - * - * @param \pdf $pdf the pdf object - * @param bool $preview true if it is a preview, false otherwise - * @param \stdClass $user the user we are rendering this for - */ - public function render($pdf, $preview, $user) { - // If there is no element data, we have nothing to display. - if (empty($this->get_data())) { - return; - } - - $gradeitem = \grade_item::fetch(['id' => $this->get_data()]); - - if ($preview) { - // Get the outcome. - $outcome = \grade_outcome::fetch(['id' => $gradeitem->outcomeid]); - - $display = $outcome->get_name(); - } else { - // Get the grade. - $grade = new \grade_grade( - [ - 'itemid' => $gradeitem->id, - 'userid' => $user->id - ] - ); - - $display = grade_format_gradevalue($grade->finalgrade, $gradeitem); - } - - \mod_customcert\element_helper::render_content($pdf, $this, $display); - } - - /** - * Render the element in html. - * - * This function is used to render the element when we are using the - * drag and drop interface to position it. - * - * @return string the html - */ - public function render_html() { - // If there is no element data, we have nothing to display. - if (empty($this->get_data())) { - return ''; - } - - // Get the grade item. - $gradeitem = \grade_item::fetch(['id' => $this->get_data()]); - - // Get the outcome. - $outcome = \grade_outcome::fetch(['id' => $gradeitem->outcomeid]); - - return \mod_customcert\element_helper::render_html_content($this, $outcome->get_name()); - } - - /** - * Sets the data on the form when editing an element. - * - * @param \MoodleQuickForm $mform the edit_form instance - */ - public function definition_after_data($mform) { - // Set the item and format for this element. - if (!empty($this->get_data())) { - $element = $mform->getElement('gradeitem'); - $element->setValue($this->get_data()); - } - - parent::definition_after_data($mform); - } -} diff --git a/element/outcome/classes/privacy/provider.php b/element/outcome/classes/privacy/provider.php deleted file mode 100644 index 4077741..0000000 --- a/element/outcome/classes/privacy/provider.php +++ /dev/null @@ -1,46 +0,0 @@ -. - -/** - * Privacy Subsystem implementation for customcertelement_outcome. - * - * @package customcertelement_outcome - * @copyright 2020 Mark Nelson - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -namespace customcertelement_outcome\privacy; - -defined('MOODLE_INTERNAL') || die(); - -/** - * Privacy Subsystem for customcertelement_outcome implementing null_provider. - * - * @copyright 2020 Mark Nelson - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class provider implements \core_privacy\local\metadata\null_provider { - - /** - * Get the language string identifier with the component's language - * file to explain why this plugin stores no data. - * - * @return string - */ - public static function get_reason() : string { - return 'privacy:metadata'; - } -} diff --git a/element/outcome/lang/en/customcertelement_outcome.php b/element/outcome/lang/en/customcertelement_outcome.php deleted file mode 100644 index 7610174..0000000 --- a/element/outcome/lang/en/customcertelement_outcome.php +++ /dev/null @@ -1,27 +0,0 @@ -. - -/** - * Strings for component 'customcertelement_outcome', language 'en'. - * - * @package customcertelement_outcome - * @copyright 2020 Mark Nelson - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -$string['outcome'] = 'Outcome'; -$string['pluginname'] = 'Outcome'; -$string['privacy:metadata'] = 'The Outcome plugin does not store any personal data.'; \ No newline at end of file diff --git a/element/outcome/version.php b/element/outcome/version.php deleted file mode 100644 index 175d6c3..0000000 --- a/element/outcome/version.php +++ /dev/null @@ -1,29 +0,0 @@ -. - -/** - * This file contains the version information for the outcome plugin. - * - * @package customcertelement_outcome - * @copyright 2020 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 = 2019111800; // The current module version (Date: YYYYMMDDXX). -$plugin->requires = 2019111800; // Requires this Moodle version (3.8). -$plugin->component = 'customcertelement_outcome'; diff --git a/tests/behat/managing_elements.feature b/tests/behat/managing_elements.feature index cf53b75..43d1cce 100644 --- a/tests/behat/managing_elements.feature +++ b/tests/behat/managing_elements.feature @@ -21,14 +21,6 @@ Feature: Being able to manage elements in a certificate template | assign | Assignment 1 | Assignment 1 intro | C1 | assign1 | | assign | Assignment 2 | Assignment 2 intro | C1 | assign2 | | customcert | Custom certificate 1 | Custom certificate 1 intro | C1 | customcert1 | - And the following config values are set as admin: - | enableoutcomes | 1 | - And the following "scales" exist: - | name | scale | - | Test Scale | Disappointing, Good, Very good, Excellent | - And the following "grade outcomes" exist: - | fullname | shortname | course | scale | - | Outcome 1 | OT1 | C1 | Test Scale | And I log in as "teacher1" And I am on "Course 1" course homepage And I follow "Custom certificate 1" @@ -259,26 +251,6 @@ Feature: Being able to manage elements in a certificate template | Height | 15 | | Alpha channel | 0.7 | And I press "Save changes" - # Outcome. - And I add the element "Outcome" to page "1" of the "Custom certificate 1" certificate template - And I set the following fields to these values: - | Outcome | Outcome 1 | - | Font | Helvetica | - | Size | 20 | - | Colour | #045ECD | - | Width | 20 | - | Reference point location | Top left | - And I press "Save changes" - And I should see "Date" in the "elementstable" "table" - And I click on ".edit-icon" "css_element" in the "Outcome" "table_row" - And the following fields match these values: - | Outcome | Outcome 1 | - | Font | Helvetica | - | Size | 20 | - | Colour | #045ECD | - | Width | 20 | - | Reference point location | Top left | - And I press "Save changes" # Student name. And I add the element "Student name" to page "1" of the "Custom certificate 1" certificate template And I set the following fields to these values: