Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 235... Línea 235...
235
            2, // Days until completion.
235
            2, // Days until completion.
236
            '42.50', // Grade.
236
            '42.50', // Grade.
237
        ], array_values($content[0]));
237
        ], array_values($content[0]));
238
    }
238
    }
Línea -... Línea 239...
-
 
239
 
-
 
240
 
-
 
241
    /**
-
 
242
     * Test creating participants report, with aggregated last access date (minimum and maximum)
-
 
243
     */
-
 
244
    public function test_course_last_access_aggregation(): void {
-
 
245
        $this->resetAfterTest();
-
 
246
 
-
 
247
        $course = $this->getDataGenerator()->create_course();
-
 
248
 
-
 
249
        $userone = $this->getDataGenerator()->create_and_enrol($course);
-
 
250
        $useronelastaccess = $this->getDataGenerator()->create_user_course_lastaccess($userone, $course, 1622502000);
-
 
251
 
-
 
252
        $usertwo = $this->getDataGenerator()->create_and_enrol($course);
-
 
253
        $usertwolastaccess = $this->getDataGenerator()->create_user_course_lastaccess($usertwo, $course, 1622847600);
-
 
254
 
-
 
255
        /** @var core_reportbuilder_generator $generator */
-
 
256
        $generator = $this->getDataGenerator()->get_plugin_generator('core_reportbuilder');
-
 
257
 
-
 
258
        $report = $generator->create_report(['name' => 'Participants', 'source' => participants::class, 'default' => 0]);
-
 
259
        $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'course:fullname']);
-
 
260
        $column = $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'access:timeaccess']);
-
 
261
 
-
 
262
        // Course aggregated with "Minimum" last access.
-
 
263
        $column->set('aggregation', 'min')->update();
-
 
264
        $content = $this->get_custom_report_content($report->get('id'));
-
 
265
        $this->assertEquals([
-
 
266
            [$course->fullname, userdate($useronelastaccess->timeaccess)],
-
 
267
        ], array_map('array_values', $content));
-
 
268
 
-
 
269
        // Course aggregated with "Maximum" last access.
-
 
270
        $column->set('aggregation', 'max')->update();
-
 
271
        $content = $this->get_custom_report_content($report->get('id'));
-
 
272
        $this->assertEquals([
-
 
273
            [$course->fullname, userdate($usertwolastaccess->timeaccess)],
-
 
274
        ], array_map('array_values', $content));
-
 
275
    }
-
 
276
 
-
 
277
    /**
-
 
278
     * Test creating participants report, with aggregated days taking course column
-
 
279
     */
-
 
280
    public function test_completion_days_taking_course_aggregation(): void {
-
 
281
        $this->resetAfterTest();
-
 
282
 
-
 
283
        $courseone = $this->getDataGenerator()->create_course(['fullname' => 'Course 1', 'startdate' => 1622502000]);
-
 
284
        $coursetwo = $this->getDataGenerator()->create_course(['fullname' => 'Course 2']);
-
 
285
 
-
 
286
        // User one completed the course in two days.
-
 
287
        $userone = $this->getDataGenerator()->create_and_enrol($courseone);
-
 
288
        $completion = new completion_completion(['course' => $courseone->id, 'userid' => $userone->id]);
-
 
289
        $completion->mark_complete(1622502000 + (2 * DAYSECS));
-
 
290
 
-
 
291
        // User two completed the course in three days (lazy bum).
-
 
292
        $usertwo = $this->getDataGenerator()->create_and_enrol($courseone);
-
 
293
        $completion = new completion_completion(['course' => $courseone->id, 'userid' => $usertwo->id]);
-
 
294
        $completion->mark_complete(1622502000 + (3 * DAYSECS));
-
 
295
 
-
 
296
        /** @var core_reportbuilder_generator $generator */
-
 
297
        $generator = $this->getDataGenerator()->get_plugin_generator('core_reportbuilder');
-
 
298
 
-
 
299
        $report = $generator->create_report(['name' => 'Participants', 'source' => participants::class, 'default' => 0]);
-
 
300
        $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'course:fullname', 'sortenabled' => 1]);
-
 
301
        $generator->create_column([
-
 
302
            'reportid' => $report->get('id'),
-
 
303
            'uniqueidentifier' => 'completion:dayscourse',
-
 
304
            'aggregation' => 'avg',
-
 
305
        ]);
-
 
306
 
-
 
307
        $content = $this->get_custom_report_content($report->get('id'));
-
 
308
        $this->assertEquals([
-
 
309
            [$courseone->fullname, '2.5'],
-
 
310
            [$coursetwo->fullname, ''],
-
 
311
        ], array_map('array_values', $content));
-
 
312
    }
239
 
313
 
240
    /**
314
    /**
241
     * Data provider for {@see test_datasource_filters}
315
     * Data provider for {@see test_datasource_filters}
242
     *
316
     *
243
     * @return array
317
     * @return array