MDL-58138 completion: Fixes for a number of small issues.

This commit is contained in:
Jake Dallimore 2017-04-12 11:50:43 +08:00
parent 32b93ea7f8
commit 273d310601
25 changed files with 90 additions and 146 deletions

View file

@ -130,9 +130,9 @@ class mod_choice_mod_form extends moodleform_mod {
*
* Only available on moodleform_mod.
*
* @param stdClass $data passed by reference
* @param stdClass $data the form data to be modified.
*/
public function data_postprocessing(&$data) {
public function data_postprocessing($data) {
parent::data_postprocessing($data);
// Set up completion section even if checkbox is not ticked
if (!empty($data->completionunlocked)) {

View file

@ -164,9 +164,9 @@ class mod_data_mod_form extends moodleform_mod {
*
* Only available on moodleform_mod.
*
* @param stdClass $data passed by reference
* @param stdClass $data the form data to be modified.
*/
public function data_postprocessing(&$data) {
public function data_postprocessing($data) {
parent::data_postprocessing($data);
if (!empty($data->completionunlocked)) {
$autocompletion = !empty($data->completion) && $data->completion == COMPLETION_TRACKING_AUTOMATIC;

View file

@ -166,9 +166,9 @@ class mod_feedback_mod_form extends moodleform_mod {
*
* Only available on moodleform_mod.
*
* @param stdClass $data passed by reference
* @param stdClass $data the form data to be modified.
*/
public function data_postprocessing(&$data) {
public function data_postprocessing($data) {
parent::data_postprocessing($data);
if (isset($data->page_after_submit_editor)) {
$data->page_after_submitformat = $data->page_after_submit_editor['format'];

View file

@ -298,9 +298,9 @@ class mod_forum_mod_form extends moodleform_mod {
*
* Only available on moodleform_mod.
*
* @param stdClass $data passed by reference
* @param stdClass $data the form data to be modified.
*/
public function data_postprocessing(&$data) {
public function data_postprocessing($data) {
parent::data_postprocessing($data);
// Turn off completion settings if the checkboxes aren't ticked
if (!empty($data->completionunlocked)) {

View file

@ -208,9 +208,9 @@ class mod_glossary_mod_form extends moodleform_mod {
*
* Only available on moodleform_mod.
*
* @param stdClass $data passed by reference
* @param stdClass $data the form data to be modified.
*/
public function data_postprocessing(&$data) {
public function data_postprocessing($data) {
parent::data_postprocessing($data);
if (!empty($data->completionunlocked)) {
// Turn off completion settings if the checkboxes aren't ticked

View file

@ -438,9 +438,9 @@ class mod_lesson_mod_form extends moodleform_mod {
*
* Only available on moodleform_mod.
*
* @param stdClass $data passed by reference
* @param stdClass $data the form data to be modified.
*/
public function data_postprocessing(&$data) {
public function data_postprocessing($data) {
parent::data_postprocessing($data);
// Turn off completion setting if the checkbox is not ticked.
if (!empty($data->completionunlocked)) {

View file

@ -550,9 +550,9 @@ class mod_scorm_mod_form extends moodleform_mod {
*
* Only available on moodleform_mod.
*
* @param stdClass $data passed by reference
* @param stdClass $data the form data to be modified.
*/
public function data_postprocessing(&$data) {
public function data_postprocessing($data) {
parent::data_postprocessing($data);
// Convert completionstatusrequired to a proper integer, if any.
$total = 0;

View file

@ -52,9 +52,9 @@ class mod_survey_mod_form extends moodleform_mod {
*
* Only available on moodleform_mod.
*
* @param stdClass $data passed by reference
* @param stdClass $data the form data to be modified.
*/
public function data_postprocessing(&$data) {
public function data_postprocessing($data) {
parent::data_postprocessing($data);
if (!empty($data->completionunlocked)) {
// Turn off completion settings if the checkboxes aren't ticked.

View file

@ -15,7 +15,15 @@ information provided here is intended especially for developers.
- mod_<modname>_core_calendar_is_event_visible
- mod_<modname>_core_calendar_provide_event_action
- mod_<modname>_core_calendar_event_action_show_items_acount
* Changes to the moodleform_mod class and its usage (MDL-58138):
- the get_data() method has been overriden. The implementation calls parent::get_data() and a new data_postprocessing() method
- new data_postprocessing() method added. Mods can override this in their mod_form subclass to modify the submit data. Previously
mods could only modify submitted data by overriding get_data() in the mod_form subclass. data_postprocessing() is now the way to
do this correctly.
- completion: \core_completion\manager calls the overriden mod_x_mod_form->data_postprocessing() to allow mods to modify their
completion data before saving the bulk completion form. If you've overriden get_data() to modify submit data for completion in
the past, you should now override the data_postprocessing() method in your mod_form and move your code there, so bulk completion
editing will be properly supported for your plugin.
=== 3.2 ===
* Callback delete_course is deprecated and should be replaced with observer for event \core\event\course_content_deleted