diff --git a/Moosh/Command/Moodle39/Course/CourseReset.php b/Moosh/Command/Moodle39/Course/CourseReset.php index 577672cf..db06888b 100755 --- a/Moosh/Command/Moodle39/Course/CourseReset.php +++ b/Moosh/Command/Moodle39/Course/CourseReset.php @@ -1,4 +1,5 @@ addArgument('id'); $this->addOption('n|no-action', 'no action, only show settings'); $this->addOption('s|settings:', 'course restore settings'); - } public function execute() @@ -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; + } } } @@ -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"; } - } } }