diff --git a/backup/moodle2/backup_checklist_stepslib.php b/backup/moodle2/backup_checklist_stepslib.php index 5bc7c2f..9494ae0 100644 --- a/backup/moodle2/backup_checklist_stepslib.php +++ b/backup/moodle2/backup_checklist_stepslib.php @@ -45,7 +45,7 @@ protected function define_structure() { $checklist = new backup_nested_element('checklist', ['id'], [ 'name', 'intro', 'introformat', 'timecreated', 'timemodified', 'useritemsallowed', 'studentcomments', 'teacheredit', 'theme', 'duedatesoncalendar', 'teachercomments', 'maxgrade', - 'autopopulate', 'autoupdate', 'completionpercent', 'completionpercenttype', 'emailoncomplete', 'lockteachermarks', + 'autopopulate', 'supportlabel', 'autoupdate', 'completionpercent', 'completionpercenttype', 'emailoncomplete', 'lockteachermarks', ]); $items = new backup_nested_element('items'); diff --git a/classes/local/output_status.php b/classes/local/output_status.php index 61c8ffd..d699014 100644 --- a/classes/local/output_status.php +++ b/classes/local/output_status.php @@ -78,6 +78,8 @@ class output_status { protected $itemid = null; /** @var bool */ protected $autopopulate = false; + /** @var bool */ + protected $supportlabel = false; /** @var string|null */ protected $autoupdatewarning = null; /** @var bool */ @@ -405,6 +407,22 @@ public function set_autopopulate($autopopulate) { $this->autopopulate = $autopopulate; } + /** + * Is label support enabled for this instance? + * @return boolean + */ + public function is_supportlabel() { + return $this->supportlabel; + } + + /** + * Set as label support enabled + * @param boolean $supportlabel + */ + public function set_supportlabel($supportlabel) { + $this->supportlabel = $supportlabel; + } + /** * Should the autoupdate warning be shown and, if so, what type? * @return int|null diff --git a/db/install.xml b/db/install.xml index 54f1bd9..2ece0c1 100644 --- a/db/install.xml +++ b/db/install.xml @@ -21,6 +21,7 @@ + diff --git a/db/upgrade.php b/db/upgrade.php index 9f20c07..a866711 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -441,5 +441,17 @@ function xmldb_checklist_upgrade($oldversion = 0) { upgrade_mod_savepoint(true, 2022052801, 'checklist'); } + if ($oldversion < 2026010100) { + $table = new xmldb_table('checklist'); + $field = new xmldb_field('supportlabel', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '0'); + if (!$dbman->field_exists($table, $field)) { + $dbman->add_field($table, $field); + } + + // Checklist savepoint reached. + upgrade_mod_savepoint(true, 2026010100, 'checklist'); + + } + return $result; } diff --git a/lang/en/checklist.php b/lang/en/checklist.php index 47a6621..c86585f 100644 --- a/lang/en/checklist.php +++ b/lang/en/checklist.php @@ -193,6 +193,9 @@ $string['student_comment_updated'] = 'Student comment updated'; $string['student_comment_updated_desc'] = 'The user with id {$a->userid} has updated a comment in the checklist with course module id {$a->cmid} to have text \'{$a->commenttext}\''; $string['studentcomments'] = 'User can add their own comments to checklist items'; +$string['supportlabel'] = 'Support label'; +$string['supportlabel_help'] = 'By default label are not supported because in many cases the checklist would be very large.
+If you whant also to use label in checklist, then you can activate it with this setting.'; $string['teacheralongsidecheck'] = 'Student and teacher'; $string['teachercomments'] = 'Teachers can add comments'; $string['teacherdate'] = 'Date a teacher last updated this item'; diff --git a/locallib.php b/locallib.php index edb1a08..fbddbbe 100644 --- a/locallib.php +++ b/locallib.php @@ -482,12 +482,13 @@ protected function update_items_from_course() { $nextpos = $this->items[$sectionheading]->position + 1; } + $supportlabel = $this->checklist->supportlabel; foreach ($sections[$section] as $cmid) { if ($this->cm->id == $cmid) { continue; // Do not include this checklist in the list of modules. } - if ($mods->get_cm($cmid)->modname === 'label') { - continue; // Ignore any labels. + if ($mods->get_cm($cmid)->modname === 'label' && !$supportlabel) { + continue; // Ignore any labels. } if (isset($mods->get_cm($cmid)->deletioninprogress) && $mods->get_cm($cmid)->deletioninprogress) { continue; // M3.2 onwards - if cm is in the recycle bin, being deleted, then skip it. diff --git a/mod_form.php b/mod_form.php index 54d5d6e..f91ea09 100644 --- a/mod_form.php +++ b/mod_form.php @@ -94,6 +94,10 @@ public function definition() { $mform->setDefault('autopopulate', 0); $mform->addHelpButton('autopopulate', 'autopopulate', 'checklist'); + $mform->addElement('select', 'supportlabel', get_string('supportlabel', 'checklist'), $ynoptions); + $mform->setDefault('supportlabel', 0); + $mform->addHelpButton('supportlabel', 'supportlabel', 'checklist'); + $checkdisable = true; $str = 'autoupdate'; if (get_config('mod_checklist', 'linkcourses')) { diff --git a/tests/generator/lib.php b/tests/generator/lib.php index cff60bc..21af0ea 100644 --- a/tests/generator/lib.php +++ b/tests/generator/lib.php @@ -49,6 +49,7 @@ public function create_instance($record = null, ?array $options = null) { 'teachercomments' => 1, 'maxgrade' => 100, 'autopopulate' => CHECKLIST_AUTOPOPULATE_NO, + 'supportlabel' => 0, 'autoupdate' => CHECKLIST_AUTOUPDATE_YES, 'completionpercent' => 0, 'emailoncomplete' => 0, diff --git a/version.php b/version.php index 589cccf..7f4b227 100644 --- a/version.php +++ b/version.php @@ -24,9 +24,9 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2025101800; // The current module version (Date: YYYYMMDDXX). +$plugin->version = 2026010100; // The current module version (Date: YYYYMMDDXX). $plugin->maturity = MATURITY_STABLE; -$plugin->release = '4.1.0.7'; +$plugin->release = '4.1.0.8'; $plugin->requires = 2022112800; // Moodle 4.1.0. $plugin->component = 'mod_checklist'; $plugin->supported = [401, 501];