mirror of
https://github.com/moodle/moodle.git
synced 2025-04-15 05:25:08 +02:00
MDL-58460 mod_data: work with bulk completion API
Part of MDL-58138 epic
This commit is contained in:
parent
d233adbb77
commit
61167c16d0
@ -52,6 +52,10 @@ class core_completion_bulk_update_testcase extends advanced_testcase {
|
||||
'choice-2' => ['choice', ['completion' => COMPLETION_TRACKING_MANUAL]],
|
||||
'data-1' => ['data', ['completion' => COMPLETION_TRACKING_AUTOMATIC, 'completionview' => 1]],
|
||||
'data-2' => ['data', ['completion' => COMPLETION_TRACKING_MANUAL]],
|
||||
'data-3' => ['data',
|
||||
['completion' => COMPLETION_TRACKING_AUTOMATIC, 'completionview' => 1, 'completionentries' => 3,
|
||||
'completionentriesenabled' => 1],
|
||||
['completion' => COMPLETION_TRACKING_AUTOMATIC, 'completionview' => 1, 'completionentries' => 3]],
|
||||
'feedback-1' => ['feedback', ['completion' => COMPLETION_TRACKING_AUTOMATIC, 'completionview' => 0,
|
||||
'completionsubmit' => 1]],
|
||||
'feedback-2' => ['feedback', ['completion' => COMPLETION_TRACKING_MANUAL]],
|
||||
|
@ -159,24 +159,21 @@ class mod_data_mod_form extends moodleform_mod {
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn off this completion setting if the checkbox is not ticked
|
||||
* Allows modules to modify the data returned by form get_data().
|
||||
* This method is also called in the bulk activity completion form.
|
||||
*
|
||||
* @return boolean indicates if any data was submitted
|
||||
* Only available on moodleform_mod.
|
||||
*
|
||||
* @param stdClass $data passed by reference
|
||||
*/
|
||||
public function get_data() {
|
||||
$data = parent::get_data();
|
||||
if (!$data) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function data_postprocessing(&$data) {
|
||||
parent::data_postprocessing($data);
|
||||
if (!empty($data->completionunlocked)) {
|
||||
$autocompletion = !empty($data->completion) && $data->completion == COMPLETION_TRACKING_AUTOMATIC;
|
||||
if (empty($data->completionentriesenabled) || !$autocompletion) {
|
||||
$data->completionentries = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user