Merge branch 'MDL-66970_master' of git://github.com/dmonllao/moodle

This commit is contained in:
Eloy Lafuente (stronk7)
2019-10-21 23:59:18 +02:00
2 changed files with 39 additions and 6 deletions
@@ -302,8 +302,20 @@ abstract class course_enrolments extends \core_analytics\local\target\binary {
protected function enrolment_active_during_analysis_time(int $sampleid, int $starttime, int $endtime) {
$userenrol = $this->retrieve('user_enrolments', $sampleid);
$enrolstart = $userenrol->timestart ?? $userenrol->timecreated;
$enrolend = $userenrol->timeend ?? PHP_INT_MAX;
if (!empty($userenrol->timestart)) {
$enrolstart = $userenrol->timestart;
} else {
// This is always set.
$enrolstart = $userenrol->timecreated;
}
if (!empty($userenrol->timeend)) {
$enrolend = $userenrol->timeend;
} else {
// Default to tre end of the world.
$enrolend = PHP_INT_MAX;
}
if ($endtime && $endtime < $enrolstart) {
/* The enrolment starts/ed after the analysis end time.
+25 -4
View File
@@ -272,8 +272,8 @@ class core_analytics_targets_testcase extends advanced_testcase {
],
'enrol-partly-active-ends-afterwards' => [
'starttime' => $now,
'endtime' => $now + (WEEKSECS * 9),
'timestart' => $now + (WEEKSECS * 10),
'endtime' => $now + (WEEKSECS * 10),
'timestart' => $now + (WEEKSECS * 9),
'timeend' => $now + (WEEKSECS * 11),
'nullcalculation' => true,
],
@@ -291,12 +291,33 @@ class core_analytics_targets_testcase extends advanced_testcase {
'timeend' => false,
'nullcalculation' => true,
],
'enrol-mostly-active-no-enrolment-end' => [
'enrol-mostly-active-no-enrolment-end-false' => [
'starttime' => $now,
'endtime' => $now + (WEEKSECS * 10),
'timestart' => $now + WEEKSECS,
'timeend' => false,
'nullcalculation' => true,
'nullcalculation' => false,
],
'enrol-mostly-active-no-enrolment-end-zero' => [
'starttime' => $now,
'endtime' => $now + (WEEKSECS * 10),
'timestart' => $now + WEEKSECS,
'timeend' => 0,
'nullcalculation' => false,
],
'enrol-no-enrolment-start-false' => [
'starttime' => $now,
'endtime' => $now + (WEEKSECS * 10),
'timestart' => false,
'timeend' => $now + (WEEKSECS * 9),
'nullcalculation' => false,
],
'enrol-no-enrolment-start-zero' => [
'starttime' => $now,
'endtime' => $now + (WEEKSECS * 10),
'timestart' => 0,
'timeend' => $now + (WEEKSECS * 9),
'nullcalculation' => false,
],
'no-start' => [
'starttime' => 0,