Skip to content

Commit

Permalink
Fix: ci codechecker errors
Browse files Browse the repository at this point in the history
  • Loading branch information
rajandangi committed Aug 27, 2024
1 parent a3e468f commit 4f6f7d6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
27 changes: 14 additions & 13 deletions classes/task/reengagement_adhoc_task.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ private function process_completed_reengagements($timenow, $reengagementid) {
JOIN {user} u ON u.id = ri.userid
WHERE u.deleted = 0 AND
completiontime < ? AND completed = 0 AND ri.reengagement = ?';
$inprogresses = $DB->get_recordset_sql($inprogresssql, array($timenow, $reengagementid));
$inprogresses = $DB->get_recordset_sql($inprogresssql, [$timenow, $reengagementid]);
$completeripcount = 0;
foreach ($inprogresses as $inprogress) {
$completeripcount++;
Expand All @@ -141,14 +141,15 @@ private function process_completed_reengagements($timenow, $reengagementid) {
// Check if user is still enrolled in the course.
$context = context_module::instance($reengagement->cmid);
if (!is_enrolled($context, $userid, 'mod/reengagement:startreengagement', true)) {
$DB->delete_records('reengagement_inprogress', array('id' => $inprogress->id));
$DB->delete_records('reengagement_inprogress', ['id' => $inprogress->id]);
continue;
}

// Update completion record to indicate completion so the user can continue with any dependant activities.
$completionrecord = $DB->get_record('course_modules_completion', array('coursemoduleid' => $cmid, 'userid' => $userid));
$completionrecord = $DB->get_record('course_modules_completion', ['coursemoduleid' => $cmid, 'userid' => $userid]);
if (empty($completionrecord)) {
mtrace("Could not find completion record to update complete state, userid: $userid, cmid: $cmid - recreating record.");
mtrace("Could not find completion record to update complete state, userid: $userid,
cmid: $cmid - recreating record.");
// This might happen when reset_all_state has been triggered, deleting an "in-progress" record. so recreate it.
$completionrecord = new stdClass();
$completionrecord->coursemoduleid = $cmid;
Expand All @@ -170,14 +171,14 @@ private function process_completed_reengagements($timenow, $reengagementid) {

$cmcontext = context_module::instance($cmid, MUST_EXIST);
// Trigger an event for course module completion changed.
$event = \core\event\course_module_completion_updated::create(array(
$event = \core\event\course_module_completion_updated::create([
'objectid' => $completionrecord->id,
'context' => $cmcontext,
'relateduserid' => $userid,
'other' => array(
'relateduserid' => $userid
)
));
'other' => [
'relateduserid' => $userid,
],
]);
$event->add_record_snapshot('course_modules_completion', $completionrecord);
$event->trigger();

Expand All @@ -190,7 +191,7 @@ private function process_completed_reengagements($timenow, $reengagementid) {
// Delete inprogress record.
debugging('', DEBUG_DEVELOPER) && mtrace("mode $reengagement->emailuser reengagementid $reengagement->id.
User marked complete, deleting inprogress record for user $userid");
$result = $DB->delete_records('reengagement_inprogress', array('id' => $inprogress->id));
$result = $DB->delete_records('reengagement_inprogress', ['id' => $inprogress->id]);
} else {
// Update inprogress record to indicate completion done.
debugging('', DEBUG_DEVELOPER) && mtrace("mode $reengagement->emailuser reengagementid $reengagement->id
Expand Down Expand Up @@ -229,7 +230,7 @@ private function process_completed_reengagements($timenow, $reengagementid) {
AND u.deleted = 0
AND ip.reengagement = :reengagementid
ORDER BY r.id ASC';
$params = array('emailtime' => $timenow, 'reengagementid' => $reengagementid);
$params = ['emailtime' => $timenow, 'reengagementid' => $reengagementid];

$inprogresses = $DB->get_recordset_sql($inprogresssql, $params);
$emailduecount = 0;
Expand All @@ -241,14 +242,14 @@ private function process_completed_reengagements($timenow, $reengagementid) {
// Check if user is still enrolled in the course.
$context = context_module::instance($reengagement->cmid);
if (!is_enrolled($context, $userid, 'mod/reengagement:startreengagement', true)) {
$DB->delete_records('reengagement_inprogress', array('id' => $inprogress->id));
$DB->delete_records('reengagement_inprogress', ['id' => $inprogress->id]);
continue;
}

if ($inprogress->completed == COMPLETION_COMPLETE) {
debugging('', DEBUG_DEVELOPER) && mtrace("mode $reengagement->emailuser reengagementid $reengagement->id.
User already marked complete. Deleting inprogress record for user $userid");
$result = $DB->delete_records('reengagement_inprogress', array('id' => $inprogress->id));
$result = $DB->delete_records('reengagement_inprogress', ['id' => $inprogress->id]);
} else {
debugging('', DEBUG_DEVELOPER) && mtrace("mode $reengagement->emailuser reengagementid $reengagement->id.
Updating inprogress record to indicate email sent for user $userid");
Expand Down
10 changes: 5 additions & 5 deletions db/tasks.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@

defined('MOODLE_INTERNAL') || die();

$tasks = array(
array(
$tasks = [
[
'classname' => 'mod_reengagement\task\cron_task',
'blocking' => 0,
'minute' => '*/5',
'hour' => '*',
'day' => '*',
'month' => '*',
'dayofweek' => '*'
)
);
'dayofweek' => '*',
],
];
2 changes: 1 addition & 1 deletion lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ function reengagement_template_variables($reengagement, $inprogress, $user) {
$options = array(
'context' => context_course::instance($reengagement->courseid),
'noclean' => true,
'trusted' => true
'trusted' => true,
);
$subjectfields = array('emailsubject', 'emailsubjectmanager', 'emailsubjectthirdparty');
foreach ($subjectfields as $field) {
Expand Down

0 comments on commit 4f6f7d6

Please sign in to comment.