Proyectos de Subversion Moodle

Rev

Rev 11 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 11 Rev 1441
Línea 31... Línea 31...
31
 *
31
 *
32
 * @package   core_course
32
 * @package   core_course
33
 * @copyright 2019 Victor Deniz <victor@moodle.com>
33
 * @copyright 2019 Victor Deniz <victor@moodle.com>
34
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
34
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
35
 */
35
 */
36
class targets_test extends \advanced_testcase {
36
final class targets_test extends \advanced_testcase {
Línea 37... Línea 37...
37
 
37
 
38
    /**
38
    /**
39
     * Provides course params for the {@link self::test_core_target_course_completion_analysable()} method.
39
     * Provides course params for the {@link self::test_core_target_course_completion_analysable()} method.
40
     *
40
     *
41
     * @return array
41
     * @return array
42
     */
42
     */
Línea 43... Línea 43...
43
    public function analysable_provider() {
43
    public static function analysable_provider(): array {
44
 
44
 
45
        $now = new \DateTime("now", \core_date::get_server_timezone_object());
45
        $now = new \DateTime("now", \core_date::get_server_timezone_object());
Línea 46... Línea 46...
46
        $year = $now->format('Y');
46
        $year = $now->format('Y');
47
        $month = $now->format('m');
47
        $month = $now->format('m');
48
 
48
 
49
        return [
49
        return [
50
            'coursenotyetstarted' => [
50
            'coursenotyetstarted' => [
51
                'params' => [
51
                'courseparams' => [
52
                    'enablecompletion' => 1,
52
                    'enablecompletion' => 1,
53
                    'startdate' => mktime(0, 0, 0, 10, 24, $year + 1)
53
                    'startdate' => mktime(0, 0, 0, 10, 24, $year + 1)
54
                ],
54
                ],
55
                'isvalid' => get_string('coursenotyetstarted', 'course')
55
                'isvalid' => get_string('coursenotyetstarted', 'course')
56
            ],
56
            ],
57
            'coursenostudents' => [
57
            'coursenostudents' => [
58
                'params' => [
58
                'courseparams' => [
59
                    'enablecompletion' => 1,
59
                    'enablecompletion' => 1,
60
                    'startdate' => mktime(0, 0, 0, 10, 24, $year - 2),
60
                    'startdate' => mktime(0, 0, 0, 10, 24, $year - 2),
61
                    'enddate' => mktime(0, 0, 0, 10, 24, $year - 1)
61
                    'enddate' => mktime(0, 0, 0, 10, 24, $year - 1)
62
                ],
62
                ],
63
                'isvalid' => get_string('nocoursestudents', 'course')
63
                'isvalid' => get_string('nocoursestudents', 'course')
64
            ],
64
            ],
65
            'coursenosections' => [
65
            'coursenosections' => [
66
                'params' => [
66
                'courseparams' => [
67
                    'enablecompletion' => 1,
67
                    'enablecompletion' => 1,
68
                    'format' => 'social',
68
                    'format' => 'singleactivity',
69
                    'students' => true
69
                    'students' => true
70
                ],
70
                ],
71
                'isvalid' => get_string('nocoursesections', 'course')
71
                'isvalid' => get_string('nocoursesections', 'course')
72
            ],
72
            ],
73
            'coursenoendtime' => [
73
            'coursenoendtime' => [
74
                'params' => [
74
                'courseparams' => [
75
                    'enablecompletion' => 1,
75
                    'enablecompletion' => 1,
76
                    'format' => 'topics',
76
                    'format' => 'topics',
77
                    'enddate' => 0,
77
                    'enddate' => 0,
78
                    'students' => true
78
                    'students' => true
79
                ],
79
                ],
80
                'isvalid' => get_string('nocourseendtime', 'course')
80
                'isvalid' => get_string('nocourseendtime', 'course')
81
            ],
81
            ],
82
            'courseendbeforestart' => [
82
            'courseendbeforestart' => [
83
                'params' => [
83
                'courseparams' => [
84
                    'enablecompletion' => 1,
84
                    'enablecompletion' => 1,
85
                    'enddate' => mktime(0, 0, 0, 10, 23, $year - 2),
85
                    'enddate' => mktime(0, 0, 0, 10, 23, $year - 2),
86
                    'students' => true
86
                    'students' => true
87
                ],
87
                ],
88
                'isvalid' => get_string('errorendbeforestart', 'course')
88
                'isvalid' => get_string('errorendbeforestart', 'course')
89
            ],
89
            ],
90
            'coursetoolong' => [
90
            'coursetoolong' => [
91
                'params' => [
91
                'courseparams' => [
92
                    'enablecompletion' => 1,
92
                    'enablecompletion' => 1,
93
                    'startdate' => mktime(0, 0, 0, 10, 24, $year - 2),
93
                    'startdate' => mktime(0, 0, 0, 10, 24, $year - 2),
94
                    'enddate' => mktime(0, 0, 0, 10, 23, $year),
94
                    'enddate' => mktime(0, 0, 0, 10, 23, $year),
95
                    'students' => true
95
                    'students' => true
96
                ],
96
                ],
97
                'isvalid' => get_string('coursetoolong', 'course')
97
                'isvalid' => get_string('coursetoolong', 'course')
98
            ],
98
            ],
99
            'coursealreadyfinished' => [
99
            'coursealreadyfinished' => [
100
                'params' => [
100
                'courseparams' => [
101
                    'enablecompletion' => 1,
101
                    'enablecompletion' => 1,
102
                    'startdate' => mktime(0, 0, 0, 10, 24, $year - 2),
102
                    'startdate' => mktime(0, 0, 0, 10, 24, $year - 2),
103
                    'enddate' => mktime(0, 0, 0, 10, 23, $year - 1),
103
                    'enddate' => mktime(0, 0, 0, 10, 23, $year - 1),
104
                    'students' => true
104
                    'students' => true
105
                ],
105
                ],
106
                'isvalid' => get_string('coursealreadyfinished', 'course'),
106
                'isvalid' => get_string('coursealreadyfinished', 'course'),
107
                'fortraining' => false
107
                'fortraining' => false
108
            ],
108
            ],
109
            'coursenotyetfinished' => [
109
            'coursenotyetfinished' => [
110
                'params' => [
110
                'courseparams' => [
111
                    'enablecompletion' => 1,
111
                    'enablecompletion' => 1,
112
                    'startdate' => mktime(0, 0, 0, $month - 1, 24, $year),
112
                    'startdate' => mktime(0, 0, 0, $month - 1, 24, $year),
113
                    'enddate' => mktime(0, 0, 0, $month + 2, 23, $year),
113
                    'enddate' => mktime(0, 0, 0, $month + 2, 23, $year),
114
                    'students' => true
114
                    'students' => true
115
                ],
115
                ],
116
                'isvalid' => get_string('coursenotyetfinished', 'course')
116
                'isvalid' => get_string('coursenotyetfinished', 'course')
117
            ],
117
            ],
118
            'coursenocompletion' => [
118
            'coursenocompletion' => [
119
                'params' => [
119
                'courseparams' => [
120
                    'enablecompletion' => 0,
120
                    'enablecompletion' => 0,
121
                    'startdate' => mktime(0, 0, 0, $month - 2, 24, $year),
121
                    'startdate' => mktime(0, 0, 0, $month - 2, 24, $year),
122
                    'enddate' => mktime(0, 0, 0, $month - 1, 23, $year),
122
                    'enddate' => mktime(0, 0, 0, $month - 1, 23, $year),
123
                    'students' => true
123
                    'students' => true
124
                ],
124
                ],
125
                'isvalid' => get_string('completionnotenabledforcourse', 'completion')
125
                'isvalid' => get_string('completionnotenabledforcourse', 'completion')
126
            ],
126
            ],
127
            'coursehiddentraining' => [
127
            'coursehiddentraining' => [
128
                'params' => [
128
                'courseparams' => [
129
                    'enablecompletion' => 1,
129
                    'enablecompletion' => 1,
130
                    'startdate' => mktime(0, 0, 0, $month - 1, 24, $year - 1),
130
                    'startdate' => mktime(0, 0, 0, $month - 1, 24, $year - 1),
131
                    'enddate' => mktime(0, 0, 0, $month - 1, 23, $year),
131
                    'enddate' => mktime(0, 0, 0, $month - 1, 23, $year),
132
                    'students' => true,
132
                    'students' => true,
133
                    'visible' => '0',
133
                    'visible' => '0',
134
                ],
134
                ],
135
                'isvalid' => true,
135
                'isvalid' => true,
136
            ],
136
            ],
137
            'coursehiddenprediction' => [
137
            'coursehiddenprediction' => [
138
                'params' => [
138
                'courseparams' => [
139
                    'enablecompletion' => 1,
139
                    'enablecompletion' => 1,
140
                    'startdate' => mktime(0, 0, 0, $month - 1, 24, $year),
140
                    'startdate' => mktime(0, 0, 0, $month - 1, 24, $year),
Línea 151... Línea 151...
151
    /**
151
    /**
152
     * Provides enrolment params for the {@link self::test_core_target_course_completion_samples()} method.
152
     * Provides enrolment params for the {@link self::test_core_target_course_completion_samples()} method.
153
     *
153
     *
154
     * @return array
154
     * @return array
155
     */
155
     */
156
    public function sample_provider() {
156
    public static function sample_provider(): array {
157
        $now = time();
157
        $now = time();
158
        return [
158
        return [
159
            'enrolmentendbeforecourse' => [
159
            'enrolmentendbeforecourse' => [
160
                'coursestart' => $now,
160
                'coursestart' => $now,
161
                'courseend' => $now + (WEEKSECS * 8),
161
                'courseend' => $now + (WEEKSECS * 8),
Línea 202... Línea 202...
202
    /**
202
    /**
203
     * Provides enrolment params for the {@link self::test_core_target_course_completion_samples()} method.
203
     * Provides enrolment params for the {@link self::test_core_target_course_completion_samples()} method.
204
     *
204
     *
205
     * @return array
205
     * @return array
206
     */
206
     */
207
    public function active_during_analysis_time_provider() {
207
    public static function active_during_analysis_time_provider(): array {
208
        $now = time();
208
        $now = time();
Línea 209... Línea 209...
209
 
209
 
210
        return [
210
        return [
211
            'enrol-after-end' => [
211
            'enrol-after-end' => [