Skip to content

Commit

Permalink
MDL-58859 analytics: No enddate update if wrong guess
Browse files Browse the repository at this point in the history
Part of MDL-57791 epic.
  • Loading branch information
dmonllao authored and David Monllao committed Jul 24, 2017
1 parent fa76fef commit d2cdaf6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
13 changes: 10 additions & 3 deletions admin/tool/models/cli/guess_course_start_and_end.php
Expand Up @@ -77,7 +77,7 @@
// We need admin permissions.
\core\session\manager::set_user(get_admin());

$conditions = array();
$conditions = array('id != 1');
if (!$options['guessall']) {
if ($options['guessstart']) {
$conditions[] = '(startdate is null or startdate = 0)';
Expand Down Expand Up @@ -174,10 +174,17 @@ function tool_models_calculate_course_dates($course, $options) {
// Update it to something we guess.

$course->enddate = $guessedenddate;
$notification .= PHP_EOL . ' ' . get_string('enddate') . ': ' . userdate($guessedenddate);

if ($course->enddate > $course->startdate) {
$notification .= PHP_EOL . ' ' . get_string('enddate') . ': ' . userdate($course->enddate);
} else {
$notification .= PHP_EOL . ' ' . get_string('errorendbeforestart', 'analytics', userdate($course->enddate));
}

if ($options['update']) {
update_course($course);
if ($course->enddate > $course->startdate) {
update_course($course);
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions lang/en/analytics.php
Expand Up @@ -28,6 +28,7 @@
$string['enabledtimesplittings'] = 'Time splitting methods';
$string['enabledtimesplittings_help'] = 'The time splitting method divides the course duration in parts, the predictions engine will run at the end of these parts. It is recommended that you only enable the time splitting methods you could be interested on using; the evaluation process will iterate through all of them so the more time splitting methods to go through the slower the evaluation process will be.';
$string['erroralreadypredict'] = '{$a} file has already been used to predict';
$string['errorendbeforestart'] = 'The guessed end date ({$a}) is before the course start date.';
$string['errorinvalidindicator'] = 'Invalid {$a} indicator';
$string['errorinvalidtimesplitting'] = 'Invalid time splitting, please ensure you added the class fully qualified class name';
$string['errornoindicators'] = 'This model does not have any indicator';
Expand Down

0 comments on commit d2cdaf6

Please sign in to comment.