Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions classes/observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

8 changes: 8 additions & 0 deletions db/events.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
),
);

6 changes: 6 additions & 0 deletions lang/en/block_exaport.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
27 changes: 27 additions & 0 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;