mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 04:22:07 +02:00
MDL-57583 completion: fix bug with advcheckbox in course completion form
Added the appropriate checks to handle the advcheckbox post data.
This commit is contained in:
parent
1034421264
commit
5a24e2177e
@ -84,13 +84,17 @@ class completion_criteria_activity extends completion_criteria {
|
||||
|
||||
$this->course = $data->id;
|
||||
|
||||
foreach (array_keys($data->criteria_activity) as $activity) {
|
||||
|
||||
$module = $DB->get_record('course_modules', array('id' => $activity));
|
||||
$this->module = self::get_mod_name($module->module);
|
||||
$this->moduleinstance = $activity;
|
||||
$this->id = NULL;
|
||||
$this->insert();
|
||||
// Data comes from advcheckbox, so contains keys for all activities.
|
||||
// A value of 0 is 'not checked' whereas 1 is 'checked'.
|
||||
foreach ($data->criteria_activity as $activity => $val) {
|
||||
// Only update those which are checked.
|
||||
if (!empty($val)) {
|
||||
$module = $DB->get_record('course_modules', array('id' => $activity));
|
||||
$this->module = self::get_mod_name($module->module);
|
||||
$this->moduleinstance = $activity;
|
||||
$this->id = null;
|
||||
$this->insert();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user