Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 41... Línea 41...
41
 */
41
 */
42
class locallib_test extends \advanced_testcase {
42
class locallib_test extends \advanced_testcase {
Línea 43... Línea 43...
43
 
43
 
Línea 44... Línea 44...
44
    use \quiz_question_helper_test_trait;
44
    use \quiz_question_helper_test_trait;
45
 
45
 
46
    public function test_quiz_rescale_grade() {
46
    public function test_quiz_rescale_grade(): void {
47
        $quiz = new \stdClass();
47
        $quiz = new \stdClass();
48
        $quiz->decimalpoints = 2;
48
        $quiz->decimalpoints = 2;
49
        $quiz->questiondecimalpoints = 3;
49
        $quiz->questiondecimalpoints = 3;
Línea 84... Línea 84...
84
     * @param int|null $relativetimeclose time relative to now when the quiz closes, or null for 0.
84
     * @param int|null $relativetimeclose time relative to now when the quiz closes, or null for 0.
85
     * @param int $expectedstate expected result. One of the display_options constants.
85
     * @param int $expectedstate expected result. One of the display_options constants.
86
     * @covers ::quiz_attempt_state
86
     * @covers ::quiz_attempt_state
87
     */
87
     */
88
    public function test_quiz_attempt_state(string $attemptstate,
88
    public function test_quiz_attempt_state(string $attemptstate,
89
            ?int $relativetimefinish, ?int $relativetimeclose, int $expectedstate) {
89
            ?int $relativetimefinish, ?int $relativetimeclose, int $expectedstate): void {
Línea 90... Línea 90...
90
 
90
 
91
        $attempt = new \stdClass();
91
        $attempt = new \stdClass();
92
        $attempt->state = $attemptstate;
92
        $attempt->state = $attemptstate;
93
        if ($relativetimefinish === null) {
93
        if ($relativetimefinish === null) {
Línea 107... Línea 107...
107
    }
107
    }
Línea 108... Línea 108...
108
 
108
 
109
    /**
109
    /**
110
     * @covers ::quiz_question_tostring
110
     * @covers ::quiz_question_tostring
111
     */
111
     */
112
    public function test_quiz_question_tostring() {
112
    public function test_quiz_question_tostring(): void {
113
        $question = new \stdClass();
113
        $question = new \stdClass();
114
        $question->qtype = 'multichoice';
114
        $question->qtype = 'multichoice';
115
        $question->name = 'The question name';
115
        $question->name = 'The question name';
116
        $question->questiontext = '<p>What sort of <b>inequality</b> is x &lt; y<img alt="?" src="..."></p>';
116
        $question->questiontext = '<p>What sort of <b>inequality</b> is x &lt; y<img alt="?" src="..."></p>';
Línea 122... Línea 122...
122
    }
122
    }
Línea 123... Línea 123...
123
 
123
 
124
    /**
124
    /**
125
     * @covers ::quiz_question_tostring
125
     * @covers ::quiz_question_tostring
126
     */
126
     */
127
    public function test_quiz_question_tostring_does_not_filter() {
127
    public function test_quiz_question_tostring_does_not_filter(): void {
128
        $question = new \stdClass();
128
        $question = new \stdClass();
129
        $question->qtype = 'multichoice';
129
        $question->qtype = 'multichoice';
130
        $question->name = 'The question name';
130
        $question->name = 'The question name';
131
        $question->questiontext = '<p>No emoticons here :-)</p>';
131
        $question->questiontext = '<p>No emoticons here :-)</p>';
Línea 138... Línea 138...
138
 
138
 
139
    /**
139
    /**
140
     * Test quiz_view
140
     * Test quiz_view
141
     * @return void
141
     * @return void
142
     */
142
     */
143
    public function test_quiz_view() {
143
    public function test_quiz_view(): void {
Línea 144... Línea 144...
144
        global $CFG;
144
        global $CFG;
145
 
145
 
Línea 178... Línea 178...
178
    }
178
    }
Línea 179... Línea 179...
179
 
179
 
180
    /**
180
    /**
181
     * Return false when there are not overrides for this quiz instance.
181
     * Return false when there are not overrides for this quiz instance.
182
     */
182
     */
183
    public function test_quiz_is_overriden_calendar_event_no_override() {
183
    public function test_quiz_is_overriden_calendar_event_no_override(): void {
Línea 184... Línea 184...
184
        global $CFG, $DB;
184
        global $CFG, $DB;
185
 
185
 
Línea 202... Línea 202...
202
    }
202
    }
Línea 203... Línea 203...
203
 
203
 
204
    /**
204
    /**
205
     * Return false if the given event isn't an quiz module event.
205
     * Return false if the given event isn't an quiz module event.
206
     */
206
     */
207
    public function test_quiz_is_overriden_calendar_event_no_module_event() {
207
    public function test_quiz_is_overriden_calendar_event_no_module_event(): void {
Línea 208... Línea 208...
208
        global $CFG, $DB;
208
        global $CFG, $DB;
209
 
209
 
Línea 225... Línea 225...
225
 
225
 
226
    /**
226
    /**
227
     * Return false if there is overrides for this use but they belong to another quiz
227
     * Return false if there is overrides for this use but they belong to another quiz
228
     * instance.
228
     * instance.
229
     */
229
     */
230
    public function test_quiz_is_overriden_calendar_event_different_quiz_instance() {
230
    public function test_quiz_is_overriden_calendar_event_different_quiz_instance(): void {
Línea 231... Línea 231...
231
        global $CFG, $DB;
231
        global $CFG, $DB;
232
 
232
 
Línea 257... Línea 257...
257
    }
257
    }
Línea 258... Línea 258...
258
 
258
 
259
    /**
259
    /**
260
     * Return true if there is a user override for this event and quiz instance.
260
     * Return true if there is a user override for this event and quiz instance.
261
     */
261
     */
262
    public function test_quiz_is_overriden_calendar_event_user_override() {
262
    public function test_quiz_is_overriden_calendar_event_user_override(): void {
Línea 263... Línea 263...
263
        global $CFG, $DB;
263
        global $CFG, $DB;
264
 
264
 
Línea 288... Línea 288...
288
    }
288
    }
Línea 289... Línea 289...
289
 
289
 
290
    /**
290
    /**
291
     * Return true if there is a group override for the event and quiz instance.
291
     * Return true if there is a group override for the event and quiz instance.
292
     */
292
     */
293
    public function test_quiz_is_overriden_calendar_event_group_override() {
293
    public function test_quiz_is_overriden_calendar_event_group_override(): void {
Línea 294... Línea 294...
294
        global $CFG, $DB;
294
        global $CFG, $DB;
295
 
295
 
Línea 322... Línea 322...
322
    }
322
    }
Línea 323... Línea 323...
323
 
323
 
324
    /**
324
    /**
325
     * Test test_quiz_get_user_timeclose().
325
     * Test test_quiz_get_user_timeclose().
326
     */
326
     */
327
    public function test_quiz_get_user_timeclose() {
327
    public function test_quiz_get_user_timeclose(): void {
Línea 328... Línea 328...
328
        global $DB;
328
        global $DB;
329
 
329
 
Línea 529... Línea 529...
529
        }
529
        }
Línea 530... Línea 530...
530
 
530
 
531
        return [$quiz, $tagobjects];
531
        return [$quiz, $tagobjects];
Línea 532... Línea 532...
532
    }
532
    }
533
 
533
 
534
    public function test_quiz_override_summary() {
534
    public function test_quiz_override_summary(): void {
535
        global $DB, $PAGE;
535
        global $DB, $PAGE;
536
        $this->resetAfterTest();
536
        $this->resetAfterTest();
537
        $generator = $this->getDataGenerator();
537
        $generator = $this->getDataGenerator();
Línea 634... Línea 634...
634
    }
634
    }
Línea 635... Línea 635...
635
 
635
 
636
    /**
636
    /**
637
     *  Test quiz_send_confirmation function.
637
     *  Test quiz_send_confirmation function.
638
     */
638
     */
639
    public function test_quiz_send_confirmation() {
639
    public function test_quiz_send_confirmation(): void {
Línea 640... Línea 640...
640
        global $CFG, $DB;
640
        global $CFG, $DB;
641
 
641
 
642
        $this->resetAfterTest();
642
        $this->resetAfterTest();