Skip to content

Commit

Permalink
Merge pull request #144 from guillogo/MOODLE_401_STABLE_issue142
Browse files Browse the repository at this point in the history
Issue #142: Get the config from local_recompletion_get_config
  • Loading branch information
danmarsden authored Jan 23, 2024
2 parents 9489d6d + 9f06f9c commit 3facb05
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 5 additions & 4 deletions classes/task/check_recompletion.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ public function execute() {

// Get recompletion config for this course (at most once).
if (!isset($configs[$user->course])) {
$rc = $DB->get_records_list('local_recompletion_config', 'course', [$course->id], '', 'name, id, value');
$configs[$user->course] = (object) local_recompletion_get_data($rc);
$config = local_recompletion_get_config($course);
$configs[$user->course] = $config;
}
$config = $configs[$user->course];

Expand All @@ -122,8 +122,9 @@ public function execute() {
if (!isset($updateresettimes[$course->id]) && isset($user->schedule)) {
// Update next reset time.
$newconfig = new \stdClass();
if (isset($rc['nextresettime'])) {
$newconfig->id = $rc['nextresettime']->id;
if (isset($config->nextresettime)) {
$newconfig->id = $DB->get_field('local_recompletion_config', 'id',
['course' => $course->id, 'name' => 'nextresettime']);
}
$newconfig->course = $course->id;
$newconfig->name = 'nextresettime';
Expand Down
6 changes: 5 additions & 1 deletion locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,18 @@ function local_recompletion_get_config($course) {
// Ideally this would be picked up directly from settings or the override form.
// Values if not set in the form are set to 0.
$defaultconfig = [
'enable' => 0,
'recompletiontype' => '',
'recompletionduration' => 0,
'recompletionschedule' => '',
'assignevent' => null,
'archivecompletiondata' => 0,
'recompletionemailenable' => 0,
'recompletionunenrolenable' => 0,
'recompletionemailbody' => '',
'recompletionemailbody_format' => FORMAT_HTML,
'recompletionemailsubject' => '',
'deletegradedata' => 0,
'nextresettime' => 0,
'course' => null // This isn't in the form.
];

Expand Down

0 comments on commit 3facb05

Please sign in to comment.