Merge branch 'MDL-66970_master' of git://github.com/dmonllao/moodle
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user