diff --git a/classes/observer.php b/classes/observer.php index e59d79af..61031091 100644 --- a/classes/observer.php +++ b/classes/observer.php @@ -44,15 +44,44 @@ public static function user_enrolment_updated(\core\event\user_enrolment_updated private static function queue_distribution_task($courseid, $userid) { // Create ad-hoc task. $task = new \block_exaport\task\distribute_to_user_task(); - + // Set custom data. $task->set_custom_data([ 'courseid' => $courseid, 'userid' => $userid, ]); - + // Queue the task. \core\task\manager::queue_adhoc_task($task); } + + /** + * Handles course module created event. + * Placeholder for saving block_exaport_assignment_option data when an assignment is created. + * + * @param \core\event\course_module_created $event + * @return void + */ + public static function course_module_created(\core\event\course_module_created $event): void { + if (($event->other['modulename'] ?? null) !== 'assign') { + return; + } + // TODO: Save block_exaport_assignment_option value for the newly created assignment. + } + + /** + * Handles course module updated event. + * Placeholder for saving block_exaport_assignment_option data when an assignment is updated. + * + * @param \core\event\course_module_updated $event + * @return void + */ + public static function course_module_updated(\core\event\course_module_updated $event): void { + if (($event->other['modulename'] ?? null) !== 'assign') { + return; + } + // TODO: Save block_exaport_assignment_option value for the updated assignment. + // TODO: e.g. with this? optional_param('block_exaport_assignment_option', 0, PARAM_TEXT); + } } diff --git a/db/events.php b/db/events.php index 5a3ea7d8..f0409bc5 100644 --- a/db/events.php +++ b/db/events.php @@ -17,5 +17,13 @@ 'eventname' => '\core\event\user_enrolment_updated', 'callback' => '\block_exaport\observer::user_enrolment_updated', ), + array( + 'eventname' => '\core\event\course_module_created', + 'callback' => '\block_exaport\observer::course_module_created', + ), + array( + 'eventname' => '\core\event\course_module_updated', + 'callback' => '\block_exaport\observer::course_module_updated', + ), ); diff --git a/lang/en/block_exaport.php b/lang/en/block_exaport.php index eba03941..1c66cd36 100644 --- a/lang/en/block_exaport.php +++ b/lang/en/block_exaport.php @@ -977,3 +977,9 @@ $string['no_views_to_distribute'] = 'No view template defined to distribute'; $string['views_created'] = 'Views created: {$a}'; $string['views_skipped'] = 'Views skipped (already exist): {$a}'; + +// === Assignment settings === +$string['assignment_option'] = 'Exaport Assignment Option'; +$string['testvalue1'] = 'Test Value 1'; +$string['testvalue2'] = 'Test Value 2'; +$string['testvalue3'] = 'Test Value 3'; diff --git a/lib.php b/lib.php index 045f5ea2..ad961bab 100644 --- a/lib.php +++ b/lib.php @@ -316,3 +316,30 @@ function block_exaport_output_fragment_blockedit($args) { return $formdata->html; } + +/** + * Inject custom elements into the course module settings form for assignment activities. + * + * @param \moodleform_mod $formwrapper The moodle quickforms wrapper object. + * @param \MoodleQuickForm $mform The actual form object (required to modify the form). + * @return void + */ +function block_exaport_coursemodule_standard_elements(\moodleform_mod $formwrapper, \MoodleQuickForm $mform): void { + if (($formwrapper->get_current()->modulename ?? null) !== 'assign') { + return; + } + + $options = [ + 'testvalue1' => get_string('testvalue1', 'block_exaport'), + 'testvalue2' => get_string('testvalue2', 'block_exaport'), + 'testvalue3' => get_string('testvalue3', 'block_exaport'), + ]; + + // TODO: currently puts in in the last area (tags).. put it somewhere else + $mform->addElement( + 'select', + 'block_exaport_assignment_option', + get_string('assignment_option', 'block_exaport'), + $options + ); +} diff --git a/version.php b/version.php index 96923040..52679f6c 100644 --- a/version.php +++ b/version.php @@ -19,6 +19,6 @@ $plugin->component = 'block_exaport'; $plugin->release = '5.1'; -$plugin->version = 2026030403; +$plugin->version = 2026030600; $plugin->requires = 2021051700; // moodle 3.11 $plugin->maturity = MATURITY_STABLE;