Skip to content

Commit

Permalink
Fix a bug for two missing values reset_start_date_old and reset_end_d…
Browse files Browse the repository at this point in the history
…ate_old
  • Loading branch information
MathiasLinux authored and tmuras committed May 29, 2024
1 parent b51bd58 commit 13f63a3
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions Moosh/Command/Moodle39/Course/CourseReset.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* moosh - Moodle Shell
*
Expand All @@ -19,7 +20,6 @@ public function __construct()
$this->addArgument('id');
$this->addOption('n|no-action', 'no action, only show settings');
$this->addOption('s|settings:', 'course restore settings');

}

public function execute()
Expand Down Expand Up @@ -55,6 +55,19 @@ public function execute()
}
}
$defaults->$key = $value;

/* If the key is equal to "reset_start_date" it means that the user wants to reset the start date of the course.
* In this case we must set the "reset_start_date_old" to the current value of the course start date.
* If we don't do this, all the activies of the course will have wrong dates.
*/
if ($key == 'reset_start_date') {
$defaults->reset_start_date_old = $this->course->startdate;
}

// We do the same for the end date (reset_end_date) and the old end date (reset_end_date_old).
if ($key == 'reset_end_date') {
$defaults->reset_end_date_old = $this->course->enddate;
}
}
}

Expand Down Expand Up @@ -100,11 +113,10 @@ protected function print_settings($settings)
{
foreach ($settings as $k => $setting) {
if (is_array($setting)) {
echo "$k=" . implode(',', $setting)."\n";
echo "$k=" . implode(',', $setting) . "\n";
} else {
echo "$k=$setting\n";
}

}
}
}

0 comments on commit 13f63a3

Please sign in to comment.