Differences Between: [Versions 311 and 402] [Versions 311 and 403]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Tests for the progress report sorting. 19 * 20 * @package report_progress 21 * @copyright 2021 The Open University 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. 23 */ 24 25 defined('MOODLE_INTERNAL') || die(); 26 27 /** 28 * Class for testing report progress helper. 29 * 30 * @copyright 2021 The Open University 31 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. 32 */ 33 class report_progress_helper_testcase extends advanced_testcase { 34 35 /** 36 * Set up testcase. 37 */ 38 public function setUp(): void { 39 global $CFG; 40 41 $CFG->enablecompletion = true; 42 $this->setAdminUser(); 43 $this->resetAfterTest(); 44 $this->generator = $this->getDataGenerator(); 45 } 46 47 /** 48 * Test process_activities_by_filter_options function. 49 */ 50 public function test_sort_activities() { 51 $expectedactivitytypes = ['all' => 'All activities and resources', 'assign' => 'Assignments', 'quiz' => 'Quizzes']; 52 53 // Generate test data. 54 $course = $this->getDataGenerator()->create_course(array('enablecompletion' => 1)); 55 $quiz2 = $this->generator->create_module('quiz', ['course' => $course->id, 'name' => 'Quiz 2'], 56 ['completion' => 1]); 57 $quiz1 = $this->generator->create_module('quiz', ['course' => $course->id, 'name' => 'Quiz 1'], 58 ['completion' => 1]); 59 $assign1 = $this->generator->create_module('assign', ['course' => $course->id, 'name' => 'Assignment'], 60 ['completion' => 1]); 61 $completion = new completion_info($course); 62 // Sort the activities by name. 63 list($activitytypes, $activities) = \report_progress\local\helper::get_activities_to_show($completion, 'quiz', 64 'alphabetical'); 65 66 // Check weather the result is filtered and sorted. 67 $this->assertEquals(2, count($activities)); 68 $this->assertEquals('Quiz 1', $activities[0]->name); 69 $this->assertEquals('Quiz 2', $activities[1]->name); 70 $this->assertEquals($activitytypes, $expectedactivitytypes); 71 } 72 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body