Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Adhoc Task for Each Course Module #164

Merged
merged 4 commits into from
Sep 24, 2024
Merged
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
12 changes: 6 additions & 6 deletions backup/moodle2/backup_reengagement_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,29 +43,29 @@ protected function define_structure() {
$userinfo = $this->get_setting_value('userinfo');

// Define each element separated.
$reengagement = new backup_nested_element('reengagement', array('id'), array(
$reengagement = new backup_nested_element('reengagement', ['id'], [
'name', 'timecreated', 'timemodified',
'emailuser', 'emailsubject', 'emailcontent', 'emailcontentformat',
'duration', 'suppresstarget', 'emaildelay', 'emailrecipient',
'emailsubjectmanager', 'emailcontentmanager', 'emailcontentmanagerformat',
'remindercount', 'thirdpartyemails', 'emailsubjectthirdparty',
'emailcontentthirdparty', 'emailcontentthirdpartyformat'));
'emailcontentthirdparty', 'emailcontentthirdpartyformat']);

$inprogresses = new backup_nested_element('inprogresses');

$inprogress = new backup_nested_element('inprogress', array('id'), array(
'reengagement', 'userid', 'completiontime', 'emailtime', 'emailsent', 'completed'));
$inprogress = new backup_nested_element('inprogress', ['id'], [
'reengagement', 'userid', 'completiontime', 'emailtime', 'emailsent', 'completed']);

// Build the tree.
$reengagement->add_child($inprogresses);
$inprogresses->add_child($inprogress);

// Define sources.
$reengagement->set_source_table('reengagement', array('id' => backup::VAR_ACTIVITYID));
$reengagement->set_source_table('reengagement', ['id' => backup::VAR_ACTIVITYID]);

// All the rest of elements only happen if we are including user info.
if ($userinfo) {
$inprogress->set_source_table('reengagement_inprogress', array('reengagement' => '../../id'));
$inprogress->set_source_table('reengagement_inprogress', ['reengagement' => '../../id']);
}

// Define id annotations.
Expand Down
10 changes: 5 additions & 5 deletions backup/moodle2/restore_reengagement_activity_task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ protected function define_my_steps() {
* processed by the link decoder
*/
public static function define_decode_contents() {
$contents = array();
$contents = [];

$contents[] = new restore_decode_content('reengagement', 'emailcontent');
$contents[] = new restore_decode_content('reengagement', 'emailcontentmanager');
Expand All @@ -71,7 +71,7 @@ public static function define_decode_contents() {
* to the activity to be executed by the link decoder
*/
public static function define_decode_rules() {
$rules = array();
$rules = [];

$rules[] = new restore_decode_rule('STANDDOWNVIEWBYID', '/mod/reengagement/view.php?id=$1', 'course_module');
$rules[] = new restore_decode_rule('STANDDOWNINDEX', '/mod/reengagement/index.php?id=$1', 'course');
Expand All @@ -87,7 +87,7 @@ public static function define_decode_rules() {
* of {@see restore_log_rule} objects
*/
public static function define_restore_log_rules() {
$rules = array();
$rules = [];

return $rules;
}
Expand All @@ -103,7 +103,7 @@ public static function define_restore_log_rules() {
* activity level. All them are rules not linked to any module instance (cmid = 0)
*/
public static function define_restore_log_rules_for_course() {
$rules = array();
$rules = [];

// Fix old wrong uses (missing extension).
$rules[] = new restore_log_rule('reengagement', 'view all', 'index?id={course}', null,
Expand All @@ -122,7 +122,7 @@ public function after_restore() {
global $DB;
$id = $this->get_activityid();
$course = $this->get_courseid();
$reengagement = $DB->get_record('reengagement', array('id' => $id));
$reengagement = $DB->get_record('reengagement', ['id' => $id]);
if (empty($reengagement)) {
// Unexpected, but nothing needs doing.
return;
Expand Down
2 changes: 1 addition & 1 deletion backup/moodle2/restore_reengagement_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class restore_reengagement_activity_structure_step extends restore_activity_stru
*/
protected function define_structure() {

$paths = array();
$paths = [];
$userinfo = $this->get_setting_value('userinfo');

$paths[] = new restore_path_element('reengagement', '/activity/reengagement');
Expand Down
12 changes: 6 additions & 6 deletions bulkchange.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@

$id = required_param('id', PARAM_INT); // Course_module ID.
$formaction = required_param('formaction', PARAM_LOCALURL);
$userids = optional_param('userids', array(), PARAM_TEXT);
$userids = optional_param('userids', [], PARAM_TEXT);
$confirm = optional_param('confirm', 0, PARAM_INT);

$cm = get_coursemodule_from_id('reengagement', $id, 0, false, MUST_EXIST);
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
$reengagement = $DB->get_record('reengagement', array('id' => $cm->instance), '*', MUST_EXIST);
$course = $DB->get_record('course', ['id' => $cm->course], '*', MUST_EXIST);
$reengagement = $DB->get_record('reengagement', ['id' => $cm->instance], '*', MUST_EXIST);

$default = new moodle_url('/mod/reengagement/view.php', ['id' => $cm->id]);
$returnurl = new moodle_url(optional_param('returnto', $default, PARAM_URL));

require_sesskey(); // This is an action script.

$PAGE->set_url('/mod/reengagement/view.php', array('id' => $id, 'formaction' => $formaction));
$PAGE->set_url('/mod/reengagement/view.php', ['id' => $id, 'formaction' => $formaction]);

require_login($course, true, $cm);

Expand Down Expand Up @@ -179,8 +179,8 @@
print '</table>';

$yesurl = new moodle_url('/mod/reengagement/bulkchange.php');
$yesparams = array('id' => $cm->id, 'formaction' => $formaction,
'userids' => implode(',', $userids), 'confirm' => 1);
$yesparams = ['id' => $cm->id, 'formaction' => $formaction,
'userids' => implode(',', $userids), 'confirm' => 1];
if ($formaction == 'resetbyspecificdate2') {
// Add timestamp to form.
$yesparams['timestamp'] = $timestamp;
Expand Down
2 changes: 1 addition & 1 deletion classes/completion/custom_completion.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static function get_defined_custom_rules(): array {
*/
public function get_custom_rule_descriptions(): array {
return [
'duration' => get_string('duration', 'reengagement')
'duration' => get_string('duration', 'reengagement'),
];
}

Expand Down
22 changes: 11 additions & 11 deletions classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ class provider implements
* @param collection $collection The initialised collection to add items to.
* @return collection A listing of user data stored through this system.
*/
public static function get_metadata(collection $collection) : collection {
public static function get_metadata(collection $collection): collection {
$collection->add_database_table(
'reengagement_inprogress',
[
'reengagement' => 'privacy:metadata:reengagement',
'userid' => 'privacy:metadata:userid',
'completiontime' => 'privacy:metadata:completiontime',
'emailtime' => 'privacy:metadata:emailtime',
'emailsent' => 'privacy:metadata:emailsent'
'emailsent' => 'privacy:metadata:emailsent',
],
'privacy:metadata:reengagement_inprogress'
);
Expand All @@ -74,7 +74,7 @@ public static function get_metadata(collection $collection) : collection {
* @param int $userid The user to search.
* @return contextlist $contextlist The contextlist containing the list of contexts used in this plugin.
*/
public static function get_contexts_for_userid(int $userid) : contextlist {
public static function get_contexts_for_userid(int $userid): contextlist {
return (new contextlist)->add_from_sql(
"SELECT ctx.id
FROM {course_modules} cm
Expand All @@ -86,7 +86,7 @@ public static function get_contexts_for_userid(int $userid) : contextlist {
[
'modulename' => 'reengagement',
'contextlevel' => CONTEXT_MODULE,
'userid' => $userid
'userid' => $userid,
]
);
}
Expand All @@ -112,7 +112,7 @@ public static function delete_data_for_all_users_in_context(context $context) {
'reengagement_inprogress',
"reengagement = :reengagementid",
[
'reengagementid' => $cm->instance
'reengagementid' => $cm->instance,
]
);
}
Expand Down Expand Up @@ -140,7 +140,7 @@ public static function delete_data_for_user(approved_contextlist $contextlist) {
"reengagement = :reengagementid AND userid = :userid",
[
'reengagementid' => $cm->instance,
'userid' => $userid
'userid' => $userid,
]
);
}
Expand All @@ -157,7 +157,7 @@ public static function export_user_data(approved_contextlist $contextlist) {
$params = [
'modulename' => 'reengagement',
'contextlevel' => CONTEXT_MODULE,
'userid' => $contextlist->get_user()->id
'userid' => $contextlist->get_user()->id,
];

list($contextsql, $contextparams) = $DB->get_in_or_equal($contextlist->get_contextids(), SQL_PARAMS_NAMED);
Expand Down Expand Up @@ -195,10 +195,10 @@ public static function export_user_data(approved_contextlist $contextlist) {
* @param array $classes An array of classes to group.
* @param string $property A common property to group the classes by.
*/
private static function group_by_property(array $classes, string $property) : array {
private static function group_by_property(array $classes, string $property): array {
return array_reduce(
$classes,
function (array $classes, stdClass $class) use ($property) : array {
function (array $classes, stdClass $class) use ($property): array {
$classes[$class->{$property}][] = $class;
return $classes;
},
Expand All @@ -215,14 +215,14 @@ function (array $classes, stdClass $class) use ($property) : array {
* @param stdClass $dbrow A row from the database containing session information.
* @return stdClass The transformed row.
*/
private static function transform_db_row_to_data(stdClass $dbrow) : stdClass {
private static function transform_db_row_to_data(stdClass $dbrow): stdClass {
return (object) [
'name' => $dbrow->reengagementname,
'userid' => $dbrow->userid,
'completiontime' => transform::datetime($dbrow->completiontime),
'emailtime' => transform::datetime($dbrow->emailtime),
'emailsent' => $dbrow->emailsent,
'completed' => $dbrow->completed
'completed' => $dbrow->completed,
];
}

Expand Down
6 changes: 3 additions & 3 deletions classes/table/reengagement_participants.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public function out($pagesize, $useinitialsbar, $downloadhelpbutton = '') {
$columns[] = 'roles';

// Get the list of fields we have to hide.
$hiddenfields = array();
$hiddenfields = [];
if (!has_capability('moodle/course:viewhiddenuserfields', $this->context)) {
$hiddenfields = array_flip(explode(',', $CFG->hiddenuserfields));
}
Expand All @@ -208,7 +208,7 @@ public function out($pagesize, $useinitialsbar, $downloadhelpbutton = '') {
}

// Show notify time and Completion time columns.
if (!in_array($this->reengagement->emailuser, array(REENGAGEMENT_EMAILUSER_NEVER, REENGAGEMENT_EMAILUSER_COMPLETION))) {
if (!in_array($this->reengagement->emailuser, [REENGAGEMENT_EMAILUSER_NEVER, REENGAGEMENT_EMAILUSER_COMPLETION])) {
$headers[] = get_string('emailtime', 'mod_reengagement');
$columns[] = 'emailtime';
}
Expand Down Expand Up @@ -333,7 +333,7 @@ public function set_filterset(filterset $filterset): void {
$cm = get_coursemodule_from_id('reengagement', $this->cmid, 0, false, MUST_EXIST);
$this->courseid = $cm->course;
$this->course = get_course($this->courseid);
$this->reengagement = $DB->get_record('reengagement', array('id' => $cm->instance), '*', MUST_EXIST);
$this->reengagement = $DB->get_record('reengagement', ['id' => $cm->instance], '*', MUST_EXIST);

$this->context = context_module::instance($this->cmid, MUST_EXIST);

Expand Down
Loading
Loading