| 1 | 
           efrain | 
           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 | 
           namespace mod_assign;
  | 
        
        
            | 
            | 
           18 | 
              | 
        
        
            | 
            | 
           19 | 
           use context_module;
  | 
        
        
            | 
            | 
           20 | 
           use assign;
  | 
        
        
            | 
            | 
           21 | 
              | 
        
        
            | 
            | 
           22 | 
           /**
  | 
        
        
            | 
            | 
           23 | 
            * Downloader tests class for mod_assign.
  | 
        
        
            | 
            | 
           24 | 
            *
  | 
        
        
            | 
            | 
           25 | 
            * @package    mod_assign
  | 
        
        
            | 
            | 
           26 | 
            * @category   test
  | 
        
        
            | 
            | 
           27 | 
            * @copyright  2022 Ferran Recio <ferran@moodle.com>
  | 
        
        
            | 
            | 
           28 | 
            * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  | 
        
        
            | 
            | 
           29 | 
            * @coversDefaultClass \mod_assign\downloader
  | 
        
        
            | 
            | 
           30 | 
            */
  | 
        
        
            | 
            | 
           31 | 
           class downloader_test extends \advanced_testcase {
  | 
        
        
            | 
            | 
           32 | 
               /**
  | 
        
        
            | 
            | 
           33 | 
                * Setup to ensure that fixtures are loaded.
  | 
        
        
            | 
            | 
           34 | 
                */
  | 
        
        
            | 
            | 
           35 | 
               public static function setupBeforeClass(): void {
  | 
        
        
            | 
            | 
           36 | 
                   global $CFG;
  | 
        
        
            | 
            | 
           37 | 
                   require_once($CFG->dirroot . '/mod/assign/locallib.php');
  | 
        
        
            | 
            | 
           38 | 
               }
  | 
        
        
            | 
            | 
           39 | 
              | 
        
        
            | 
            | 
           40 | 
               /**
  | 
        
        
            | 
            | 
           41 | 
                * Test for load_filelist method.
  | 
        
        
            | 
            | 
           42 | 
                *
  | 
        
        
            | 
            | 
           43 | 
                * @covers ::load_filelist
  | 
        
        
            | 
            | 
           44 | 
                * @dataProvider load_filelist_provider
  | 
        
        
            | 
            | 
           45 | 
                *
  | 
        
        
            | 
            | 
           46 | 
                * @param bool $teamsubmission if the assign must have team submissions
  | 
        
        
            | 
            | 
           47 | 
                * @param array $groupmembers the groups definition
  | 
        
        
            | 
            | 
           48 | 
                * @param array|null $filterusers the filtered users (null for all users)
  | 
        
        
            | 
            | 
           49 | 
                * @param bool $blindmarking if the assign has blind marking
  | 
        
        
            | 
            | 
           50 | 
                * @param bool $downloadasfolder if the download as folder preference is set
  | 
        
        
            | 
            | 
           51 | 
                * @param array $expected the expected file list
  | 
        
        
            | 
            | 
           52 | 
                */
  | 
        
        
            | 
            | 
           53 | 
               public function test_load_filelist(
  | 
        
        
            | 
            | 
           54 | 
                   bool $teamsubmission,
  | 
        
        
            | 
            | 
           55 | 
                   array $groupmembers,
  | 
        
        
            | 
            | 
           56 | 
                   ?array $filterusers,
  | 
        
        
            | 
            | 
           57 | 
                   bool $blindmarking,
  | 
        
        
            | 
            | 
           58 | 
                   bool $downloadasfolder,
  | 
        
        
            | 
            | 
           59 | 
                   array $expected
  | 
        
        
           | 11 | 
           efrain | 
           60 | 
               ): void {
  | 
        
        
           | 1 | 
           efrain | 
           61 | 
                   global $CFG;
  | 
        
        
            | 
            | 
           62 | 
                   $this->resetAfterTest();
  | 
        
        
            | 
            | 
           63 | 
                   $this->setAdminUser();
  | 
        
        
            | 
            | 
           64 | 
              | 
        
        
            | 
            | 
           65 | 
                   if (!$downloadasfolder) {
  | 
        
        
            | 
            | 
           66 | 
                       set_user_preference('assign_downloadasfolders', 0);
  | 
        
        
            | 
            | 
           67 | 
                   }
  | 
        
        
            | 
            | 
           68 | 
              | 
        
        
            | 
            | 
           69 | 
                   // Create course and enrols.
  | 
        
        
            | 
            | 
           70 | 
                   $course = $this->getDataGenerator()->create_course();
  | 
        
        
            | 
            | 
           71 | 
                   $users = [
  | 
        
        
            | 
            | 
           72 | 
                       'student1' => $this->getDataGenerator()->create_and_enrol($course, 'student'),
  | 
        
        
            | 
            | 
           73 | 
                       'student2' => $this->getDataGenerator()->create_and_enrol($course, 'student'),
  | 
        
        
            | 
            | 
           74 | 
                       'student3' => $this->getDataGenerator()->create_and_enrol($course, 'student'),
  | 
        
        
            | 
            | 
           75 | 
                       'student4' => $this->getDataGenerator()->create_and_enrol($course, 'student'),
  | 
        
        
            | 
            | 
           76 | 
                       'student5' => $this->getDataGenerator()->create_and_enrol($course, 'student'),
  | 
        
        
            | 
            | 
           77 | 
                   ];
  | 
        
        
            | 
            | 
           78 | 
              | 
        
        
            | 
            | 
           79 | 
                   // Generate groups.
  | 
        
        
            | 
            | 
           80 | 
                   $groups = [];
  | 
        
        
            | 
            | 
           81 | 
                   foreach ($groupmembers as $groupname => $groupusers) {
  | 
        
        
            | 
            | 
           82 | 
                       $group = $this->getDataGenerator()->create_group(['courseid' => $course->id, 'name' => $groupname]);
  | 
        
        
            | 
            | 
           83 | 
                       foreach ($groupusers as $user) {
  | 
        
        
            | 
            | 
           84 | 
                           groups_add_member($group, $users[$user]);
  | 
        
        
            | 
            | 
           85 | 
                       }
  | 
        
        
            | 
            | 
           86 | 
                       $groups[$groupname] = $group;
  | 
        
        
            | 
            | 
           87 | 
                   }
  | 
        
        
            | 
            | 
           88 | 
              | 
        
        
            | 
            | 
           89 | 
                   // Create activity.
  | 
        
        
            | 
            | 
           90 | 
                   $params = [
  | 
        
        
            | 
            | 
           91 | 
                       'course' => $course,
  | 
        
        
            | 
            | 
           92 | 
                       'assignsubmission_file_enabled' => 1,
  | 
        
        
            | 
            | 
           93 | 
                       'assignsubmission_file_maxfiles' => 12,
  | 
        
        
            | 
            | 
           94 | 
                       'assignsubmission_file_maxsizebytes' => 1024 * 1024,
  | 
        
        
            | 
            | 
           95 | 
                   ];
  | 
        
        
            | 
            | 
           96 | 
                   if ($teamsubmission) {
  | 
        
        
            | 
            | 
           97 | 
                       $params['teamsubmission'] = 1;
  | 
        
        
            | 
            | 
           98 | 
                       $params['preventsubmissionnotingroup'] = false;
  | 
        
        
            | 
            | 
           99 | 
                   }
  | 
        
        
            | 
            | 
           100 | 
                   if ($blindmarking) {
  | 
        
        
            | 
            | 
           101 | 
                       $params['blindmarking'] = 1;
  | 
        
        
            | 
            | 
           102 | 
                   }
  | 
        
        
            | 
            | 
           103 | 
                   $activity = $this->getDataGenerator()->create_module('assign', $params);
  | 
        
        
            | 
            | 
           104 | 
                   $cm = get_coursemodule_from_id('assign', $activity->cmid, 0, false, MUST_EXIST);
  | 
        
        
            | 
            | 
           105 | 
                   $context = context_module::instance($cm->id);
  | 
        
        
            | 
            | 
           106 | 
              | 
        
        
            | 
            | 
           107 | 
                   // Generate submissions.
  | 
        
        
            | 
            | 
           108 | 
                   $datagenerator = $this->getDataGenerator()->get_plugin_generator('mod_assign');
  | 
        
        
            | 
            | 
           109 | 
                   $files = [
  | 
        
        
            | 
            | 
           110 | 
                       "mod/assign/tests/fixtures/submissionsample01.txt",
  | 
        
        
            | 
            | 
           111 | 
                       "mod/assign/tests/fixtures/submissionsample02.txt"
  | 
        
        
            | 
            | 
           112 | 
                   ];
  | 
        
        
            | 
            | 
           113 | 
                   foreach ($users as $key => $user) {
  | 
        
        
            | 
            | 
           114 | 
                       if ($key == 'student5') {
  | 
        
        
            | 
            | 
           115 | 
                           continue;
  | 
        
        
            | 
            | 
           116 | 
                       }
  | 
        
        
            | 
            | 
           117 | 
                       $datagenerator->create_submission([
  | 
        
        
            | 
            | 
           118 | 
                           'userid' => $user->id,
  | 
        
        
            | 
            | 
           119 | 
                           'assignid' => $cm->id,
  | 
        
        
            | 
            | 
           120 | 
                           'file' => implode(',', $files),
  | 
        
        
            | 
            | 
           121 | 
                       ]);
  | 
        
        
            | 
            | 
           122 | 
                   }
  | 
        
        
            | 
            | 
           123 | 
              | 
        
        
            | 
            | 
           124 | 
                   // Generate file list.
  | 
        
        
            | 
            | 
           125 | 
                   if ($filterusers) {
  | 
        
        
            | 
            | 
           126 | 
                       foreach ($filterusers as $key => $identifier) {
  | 
        
        
            | 
            | 
           127 | 
                           $filterusers[$key] = $users[$identifier]->id;
  | 
        
        
            | 
            | 
           128 | 
                       }
  | 
        
        
            | 
            | 
           129 | 
                   }
  | 
        
        
            | 
            | 
           130 | 
                   $manager = new assign($context, $cm, $course);
  | 
        
        
            | 
            | 
           131 | 
                   $downloader = new downloader($manager, $filterusers);
  | 
        
        
            | 
            | 
           132 | 
                   $hasfiles = $downloader->load_filelist();
  | 
        
        
            | 
            | 
           133 | 
              | 
        
        
            | 
            | 
           134 | 
                   // Expose protected filelist attribute.
  | 
        
        
            | 
            | 
           135 | 
                   $rc = new \ReflectionClass(downloader::class);
  | 
        
        
            | 
            | 
           136 | 
                   $rcp = $rc->getProperty('filesforzipping');
  | 
        
        
            | 
            | 
           137 | 
              | 
        
        
            | 
            | 
           138 | 
                   // Add some replacements.
  | 
        
        
            | 
            | 
           139 | 
                   $search = ['PARTICIPANT', 'DEFAULTTEAM'];
  | 
        
        
            | 
            | 
           140 | 
                   $replace = [get_string('participant', 'mod_assign'), get_string('defaultteam', 'mod_assign')];
  | 
        
        
            | 
            | 
           141 | 
                   foreach ($users as $identifier => $user) {
  | 
        
        
            | 
            | 
           142 | 
                       $search[] = strtoupper($identifier . '.ID');
  | 
        
        
            | 
            | 
           143 | 
                       $replace[] = $manager->get_uniqueid_for_user($user->id);
  | 
        
        
            | 
            | 
           144 | 
                       $search[] = strtoupper($identifier);
  | 
        
        
            | 
            | 
           145 | 
                       $replace[] = $this->prepare_filename_text(fullname($user));
  | 
        
        
            | 
            | 
           146 | 
                   }
  | 
        
        
            | 
            | 
           147 | 
                   foreach ($groups as $identifier => $group) {
  | 
        
        
            | 
            | 
           148 | 
                       $search[] = strtoupper($identifier . '.ID');
  | 
        
        
            | 
            | 
           149 | 
                       $replace[] = strtoupper($group->id);
  | 
        
        
            | 
            | 
           150 | 
                       $search[] = strtoupper($identifier);
  | 
        
        
            | 
            | 
           151 | 
                       $replace[] = $this->prepare_filename_text($group->name);
  | 
        
        
            | 
            | 
           152 | 
                   }
  | 
        
        
            | 
            | 
           153 | 
              | 
        
        
            | 
            | 
           154 | 
                   // Validate values.
  | 
        
        
            | 
            | 
           155 | 
                   $filelist = $rcp->getValue($downloader);
  | 
        
        
            | 
            | 
           156 | 
                   $result = array_keys($filelist);
  | 
        
        
            | 
            | 
           157 | 
              | 
        
        
            | 
            | 
           158 | 
                   $this->assertEquals($hasfiles, !empty($expected));
  | 
        
        
            | 
            | 
           159 | 
                   $this->assertCount(count($expected), $result);
  | 
        
        
            | 
            | 
           160 | 
                   foreach ($expected as $path) {
  | 
        
        
            | 
            | 
           161 | 
                       $value = str_replace($search, $replace, $path);
  | 
        
        
            | 
            | 
           162 | 
                       $this->assertTrue(in_array($value, $result));
  | 
        
        
            | 
            | 
           163 | 
                   }
  | 
        
        
            | 
            | 
           164 | 
               }
  | 
        
        
            | 
            | 
           165 | 
              | 
        
        
            | 
            | 
           166 | 
               /**
  | 
        
        
            | 
            | 
           167 | 
                * Internal helper to clean a filename text.
  | 
        
        
            | 
            | 
           168 | 
                *
  | 
        
        
            | 
            | 
           169 | 
                * @param string $text the text to transform
  | 
        
        
            | 
            | 
           170 | 
                * @return string the clean string
  | 
        
        
            | 
            | 
           171 | 
                */
  | 
        
        
            | 
            | 
           172 | 
               private function prepare_filename_text(string $text): string {
  | 
        
        
            | 
            | 
           173 | 
                   return clean_filename(str_replace('_', ' ', $text));
  | 
        
        
            | 
            | 
           174 | 
               }
  | 
        
        
            | 
            | 
           175 | 
              | 
        
        
            | 
            | 
           176 | 
               /**
  | 
        
        
            | 
            | 
           177 | 
                * Data provider for test_load_filelist().
  | 
        
        
            | 
            | 
           178 | 
                *
  | 
        
        
            | 
            | 
           179 | 
                * @return array of scenarios
  | 
        
        
            | 
            | 
           180 | 
                */
  | 
        
        
            | 
            | 
           181 | 
               public function load_filelist_provider(): array {
  | 
        
        
            | 
            | 
           182 | 
                   $downloadasfoldertests = $this->load_filelist_downloadasfolder_scenarios();
  | 
        
        
            | 
            | 
           183 | 
                   $downloadasfilestests = $this->load_filelist_downloadasfiles_scenarios();
  | 
        
        
            | 
            | 
           184 | 
                   return array_merge(
  | 
        
        
            | 
            | 
           185 | 
                       $downloadasfoldertests,
  | 
        
        
            | 
            | 
           186 | 
                       $downloadasfilestests,
  | 
        
        
            | 
            | 
           187 | 
                   );
  | 
        
        
            | 
            | 
           188 | 
               }
  | 
        
        
            | 
            | 
           189 | 
              | 
        
        
            | 
            | 
           190 | 
               /**
  | 
        
        
            | 
            | 
           191 | 
                * Generate the standard test scenarios for load_filelist with download as file.
  | 
        
        
            | 
            | 
           192 | 
                *
  | 
        
        
            | 
            | 
           193 | 
                * The scenarios are the same as download as folder but replacing the "/" of the files
  | 
        
        
            | 
            | 
           194 | 
                * by a "_" and setting the downloadasfolder to false.
  | 
        
        
            | 
            | 
           195 | 
                *
  | 
        
        
            | 
            | 
           196 | 
                * @return array of scenarios
  | 
        
        
            | 
            | 
           197 | 
                */
  | 
        
        
            | 
            | 
           198 | 
               private function load_filelist_downloadasfiles_scenarios(): array {
  | 
        
        
            | 
            | 
           199 | 
                   $result = $this->load_filelist_downloadasfolder_scenarios("Download as files:");
  | 
        
        
            | 
            | 
           200 | 
                   // Transform paths from files.
  | 
        
        
            | 
            | 
           201 | 
                   foreach ($result as $scenario => $info) {
  | 
        
        
            | 
            | 
           202 | 
                       $info['downloadasfolder'] = false;
  | 
        
        
            | 
            | 
           203 | 
                       foreach ($info['expected'] as $key => $path) {
  | 
        
        
            | 
            | 
           204 | 
                           $info['expected'][$key] = str_replace('/', '_', $path);
  | 
        
        
            | 
            | 
           205 | 
                       }
  | 
        
        
            | 
            | 
           206 | 
                       $result[$scenario] = $info;
  | 
        
        
            | 
            | 
           207 | 
                   }
  | 
        
        
            | 
            | 
           208 | 
                   return $result;
  | 
        
        
            | 
            | 
           209 | 
               }
  | 
        
        
            | 
            | 
           210 | 
              | 
        
        
            | 
            | 
           211 | 
               /**
  | 
        
        
            | 
            | 
           212 | 
                * Generate the standard test scenarios for load_filelist with download as folder.
  | 
        
        
            | 
            | 
           213 | 
                *
  | 
        
        
            | 
            | 
           214 | 
                * @param string $prefix the scenarios prefix
  | 
        
        
            | 
            | 
           215 | 
                * @return array of scenarios
  | 
        
        
            | 
            | 
           216 | 
                */
  | 
        
        
            | 
            | 
           217 | 
               private function load_filelist_downloadasfolder_scenarios(string $prefix = "Download as folders:"): array {
  | 
        
        
            | 
            | 
           218 | 
                   return [
  | 
        
        
            | 
            | 
           219 | 
                       // Test without team submissions.
  | 
        
        
            | 
            | 
           220 | 
                       $prefix . ' All users without groups' => [
  | 
        
        
            | 
            | 
           221 | 
                           'teamsubmission' => false,
  | 
        
        
            | 
            | 
           222 | 
                           'groupmembers' => [],
  | 
        
        
            | 
            | 
           223 | 
                           'filterusers' => null,
  | 
        
        
            | 
            | 
           224 | 
                           'blindmarking' => false,
  | 
        
        
            | 
            | 
           225 | 
                           'downloadasfolder' => true,
  | 
        
        
            | 
            | 
           226 | 
                           'expected' => [
  | 
        
        
            | 
            | 
           227 | 
                               'STUDENT1_STUDENT1.ID_assignsubmission_file/submissionsample01.txt',
  | 
        
        
            | 
            | 
           228 | 
                               'STUDENT1_STUDENT1.ID_assignsubmission_file/submissionsample02.txt',
  | 
        
        
            | 
            | 
           229 | 
                               'STUDENT2_STUDENT2.ID_assignsubmission_file/submissionsample01.txt',
  | 
        
        
            | 
            | 
           230 | 
                               'STUDENT2_STUDENT2.ID_assignsubmission_file/submissionsample02.txt',
  | 
        
        
            | 
            | 
           231 | 
                               'STUDENT3_STUDENT3.ID_assignsubmission_file/submissionsample01.txt',
  | 
        
        
            | 
            | 
           232 | 
                               'STUDENT3_STUDENT3.ID_assignsubmission_file/submissionsample02.txt',
  | 
        
        
            | 
            | 
           233 | 
                               'STUDENT4_STUDENT4.ID_assignsubmission_file/submissionsample01.txt',
  | 
        
        
            | 
            | 
           234 | 
                               'STUDENT4_STUDENT4.ID_assignsubmission_file/submissionsample02.txt',
  | 
        
        
            | 
            | 
           235 | 
                           ],
  | 
        
        
            | 
            | 
           236 | 
                       ],
  | 
        
        
            | 
            | 
           237 | 
                       $prefix . ' Filtered users' => [
  | 
        
        
            | 
            | 
           238 | 
                           'teamsubmission' => false,
  | 
        
        
            | 
            | 
           239 | 
                           'groupmembers' => [],
  | 
        
        
            | 
            | 
           240 | 
                           'filterusers' => ['student1', 'student2'],
  | 
        
        
            | 
            | 
           241 | 
                           'blindmarking' => false,
  | 
        
        
            | 
            | 
           242 | 
                           'downloadasfolder' => true,
  | 
        
        
            | 
            | 
           243 | 
                           'expected' => [
  | 
        
        
            | 
            | 
           244 | 
                               'STUDENT1_STUDENT1.ID_assignsubmission_file/submissionsample01.txt',
  | 
        
        
            | 
            | 
           245 | 
                               'STUDENT1_STUDENT1.ID_assignsubmission_file/submissionsample02.txt',
  | 
        
        
            | 
            | 
           246 | 
                               'STUDENT2_STUDENT2.ID_assignsubmission_file/submissionsample01.txt',
  | 
        
        
            | 
            | 
           247 | 
                               'STUDENT2_STUDENT2.ID_assignsubmission_file/submissionsample02.txt',
  | 
        
        
            | 
            | 
           248 | 
                           ],
  | 
        
        
            | 
            | 
           249 | 
                       ],
  | 
        
        
            | 
            | 
           250 | 
                       $prefix . ' Filtering users without submissions' => [
  | 
        
        
            | 
            | 
           251 | 
                           'teamsubmission' => false,
  | 
        
        
            | 
            | 
           252 | 
                           'groupmembers' => [],
  | 
        
        
            | 
            | 
           253 | 
                           'filterusers' => ['student1', 'student5'],
  | 
        
        
            | 
            | 
           254 | 
                           'blindmarking' => false,
  | 
        
        
            | 
            | 
           255 | 
                           'downloadasfolder' => true,
  | 
        
        
            | 
            | 
           256 | 
                           'expected' => [
  | 
        
        
            | 
            | 
           257 | 
                               'STUDENT1_STUDENT1.ID_assignsubmission_file/submissionsample01.txt',
  | 
        
        
            | 
            | 
           258 | 
                               'STUDENT1_STUDENT1.ID_assignsubmission_file/submissionsample02.txt',
  | 
        
        
            | 
            | 
           259 | 
                           ],
  | 
        
        
            | 
            | 
           260 | 
                       ],
  | 
        
        
            | 
            | 
           261 | 
                       $prefix . ' Asking only for users without submissions' => [
  | 
        
        
            | 
            | 
           262 | 
                           'teamsubmission' => false,
  | 
        
        
            | 
            | 
           263 | 
                           'groupmembers' => [],
  | 
        
        
            | 
            | 
           264 | 
                           'filterusers' => ['student5'],
  | 
        
        
            | 
            | 
           265 | 
                           'blindmarking' => false,
  | 
        
        
            | 
            | 
           266 | 
                           'downloadasfolder' => true,
  | 
        
        
            | 
            | 
           267 | 
                           'expected' => [],
  | 
        
        
            | 
            | 
           268 | 
                       ],
  | 
        
        
            | 
            | 
           269 | 
                       // Test with team submissions and no default team.
  | 
        
        
            | 
            | 
           270 | 
                       $prefix . ' All users with all users in groups' => [
  | 
        
        
            | 
            | 
           271 | 
                           'teamsubmission' => true,
  | 
        
        
            | 
            | 
           272 | 
                           'groupmembers' => [
  | 
        
        
            | 
            | 
           273 | 
                               'group1' => ['student1'],
  | 
        
        
            | 
            | 
           274 | 
                               'group2' => ['student2', 'student3'],
  | 
        
        
            | 
            | 
           275 | 
                               'group3' => ['student4', 'student5'],
  | 
        
        
            | 
            | 
           276 | 
                           ],
  | 
        
        
            | 
            | 
           277 | 
                           'filterusers' => null,
  | 
        
        
            | 
            | 
           278 | 
                           'blindmarking' => false,
  | 
        
        
            | 
            | 
           279 | 
                           'downloadasfolder' => true,
  | 
        
        
            | 
            | 
           280 | 
                           'expected' => [
  | 
        
        
            | 
            | 
           281 | 
                               'GROUP1_GROUP1.ID_assignsubmission_file/submissionsample01.txt',
  | 
        
        
            | 
            | 
           282 | 
                               'GROUP1_GROUP1.ID_assignsubmission_file/submissionsample02.txt',
  | 
        
        
            | 
            | 
           283 | 
                               'GROUP2_GROUP2.ID_assignsubmission_file/submissionsample01.txt',
  | 
        
        
            | 
            | 
           284 | 
                               'GROUP2_GROUP2.ID_assignsubmission_file/submissionsample02.txt',
  | 
        
        
            | 
            | 
           285 | 
                               'GROUP3_GROUP3.ID_assignsubmission_file/submissionsample01.txt',
  | 
        
        
            | 
            | 
           286 | 
                               'GROUP3_GROUP3.ID_assignsubmission_file/submissionsample02.txt',
  | 
        
        
            | 
            | 
           287 | 
                           ],
  | 
        
        
            | 
            | 
           288 | 
                       ],
  | 
        
        
            | 
            | 
           289 | 
                       $prefix . ' Filtering users with disjoined groups' => [
  | 
        
        
            | 
            | 
           290 | 
                           'teamsubmission' => true,
  | 
        
        
            | 
            | 
           291 | 
                           'groupmembers' => [
  | 
        
        
            | 
            | 
           292 | 
                               'group1' => ['student1'],
  | 
        
        
            | 
            | 
           293 | 
                               'group2' => ['student2', 'student3'],
  | 
        
        
            | 
            | 
           294 | 
                               'group3' => ['student4', 'student5'],
  | 
        
        
            | 
            | 
           295 | 
                           ],
  | 
        
        
            | 
            | 
           296 | 
                           'filterusers' => ['student1', 'student2'],
  | 
        
        
            | 
            | 
           297 | 
                           'blindmarking' => false,
  | 
        
        
            | 
            | 
           298 | 
                           'downloadasfolder' => true,
  | 
        
        
            | 
            | 
           299 | 
                           'expected' => [
  | 
        
        
            | 
            | 
           300 | 
                               'GROUP1_GROUP1.ID_assignsubmission_file/submissionsample01.txt',
  | 
        
        
            | 
            | 
           301 | 
                               'GROUP1_GROUP1.ID_assignsubmission_file/submissionsample02.txt',
  | 
        
        
            | 
            | 
           302 | 
                               'GROUP2_GROUP2.ID_assignsubmission_file/submissionsample01.txt',
  | 
        
        
            | 
            | 
           303 | 
                               'GROUP2_GROUP2.ID_assignsubmission_file/submissionsample02.txt',
  | 
        
        
            | 
            | 
           304 | 
                           ],
  | 
        
        
            | 
            | 
           305 | 
                       ],
  | 
        
        
            | 
            | 
           306 | 
                       $prefix . ' Filtering users with default teams who does not do a submission' => [
  | 
        
        
            | 
            | 
           307 | 
                           'teamsubmission' => true,
  | 
        
        
            | 
            | 
           308 | 
                           'groupmembers' => [
  | 
        
        
            | 
            | 
           309 | 
                               'group1' => ['student1'],
  | 
        
        
            | 
            | 
           310 | 
                               'group2' => ['student2', 'student3'],
  | 
        
        
            | 
            | 
           311 | 
                               'group3' => ['student4', 'student5'],
  | 
        
        
            | 
            | 
           312 | 
                           ],
  | 
        
        
            | 
            | 
           313 | 
                           'filterusers' => ['student1', 'student5'],
  | 
        
        
            | 
            | 
           314 | 
                           'blindmarking' => false,
  | 
        
        
            | 
            | 
           315 | 
                           'downloadasfolder' => true,
  | 
        
        
            | 
            | 
           316 | 
                           'expected' => [
  | 
        
        
            | 
            | 
           317 | 
                               'GROUP1_GROUP1.ID_assignsubmission_file/submissionsample01.txt',
  | 
        
        
            | 
            | 
           318 | 
                               'GROUP1_GROUP1.ID_assignsubmission_file/submissionsample02.txt',
  | 
        
        
            | 
            | 
           319 | 
                               'GROUP3_GROUP3.ID_assignsubmission_file/submissionsample01.txt',
  | 
        
        
            | 
            | 
           320 | 
                               'GROUP3_GROUP3.ID_assignsubmission_file/submissionsample02.txt',
  | 
        
        
            | 
            | 
           321 | 
                           ],
  | 
        
        
            | 
            | 
           322 | 
                       ],
  | 
        
        
            | 
            | 
           323 | 
                       $prefix . ' Filtering users without submission but member of a group' => [
  | 
        
        
            | 
            | 
           324 | 
                           'teamsubmission' => true,
  | 
        
        
            | 
            | 
           325 | 
                           'groupmembers' => [
  | 
        
        
            | 
            | 
           326 | 
                               'group1' => ['student1'],
  | 
        
        
            | 
            | 
           327 | 
                               'group2' => ['student2', 'student3'],
  | 
        
        
            | 
            | 
           328 | 
                               'group3' => ['student4', 'student5'],
  | 
        
        
            | 
            | 
           329 | 
                           ],
  | 
        
        
            | 
            | 
           330 | 
                           'filterusers' => [
  | 
        
        
            | 
            | 
           331 | 
                               'student5'
  | 
        
        
            | 
            | 
           332 | 
                           ],
  | 
        
        
            | 
            | 
           333 | 
                           'blindmarking' => false,
  | 
        
        
            | 
            | 
           334 | 
                           'downloadasfolder' => true,
  | 
        
        
            | 
            | 
           335 | 
                           'expected' => [
  | 
        
        
            | 
            | 
           336 | 
                               'GROUP3_GROUP3.ID_assignsubmission_file/submissionsample01.txt',
  | 
        
        
            | 
            | 
           337 | 
                               'GROUP3_GROUP3.ID_assignsubmission_file/submissionsample02.txt',
  | 
        
        
            | 
            | 
           338 | 
                           ],
  | 
        
        
            | 
            | 
           339 | 
                       ],
  | 
        
        
            | 
            | 
           340 | 
                       // Test with default team.
  | 
        
        
            | 
            | 
           341 | 
                       $prefix . ' All users with users in the default team' => [
  | 
        
        
            | 
            | 
           342 | 
                           'teamsubmission' => true,
  | 
        
        
            | 
            | 
           343 | 
                           'groupmembers' => [
  | 
        
        
            | 
            | 
           344 | 
                               'group1' => ['student1', 'student2'],
  | 
        
        
            | 
            | 
           345 | 
                           ],
  | 
        
        
            | 
            | 
           346 | 
                           'filterusers' => null,
  | 
        
        
            | 
            | 
           347 | 
                           'blindmarking' => false,
  | 
        
        
            | 
            | 
           348 | 
                           'downloadasfolder' => true,
  | 
        
        
            | 
            | 
           349 | 
                           'expected' => [
  | 
        
        
            | 
            | 
           350 | 
                               'GROUP1_GROUP1.ID_assignsubmission_file/submissionsample01.txt',
  | 
        
        
            | 
            | 
           351 | 
                               'GROUP1_GROUP1.ID_assignsubmission_file/submissionsample02.txt',
  | 
        
        
            | 
            | 
           352 | 
                               'DEFAULTTEAM_assignsubmission_file/submissionsample01.txt',
  | 
        
        
            | 
            | 
           353 | 
                               'DEFAULTTEAM_assignsubmission_file/submissionsample02.txt',
  | 
        
        
            | 
            | 
           354 | 
                           ],
  | 
        
        
            | 
            | 
           355 | 
                       ],
  | 
        
        
            | 
            | 
           356 | 
                       $prefix . ' Filtered users in groups with users in the default team' => [
  | 
        
        
            | 
            | 
           357 | 
                           'teamsubmission' => true,
  | 
        
        
            | 
            | 
           358 | 
                           'groupmembers' => [
  | 
        
        
            | 
            | 
           359 | 
                               'group1' => ['student1', 'student2'],
  | 
        
        
            | 
            | 
           360 | 
                           ],
  | 
        
        
            | 
            | 
           361 | 
                           'filterusers' => ['student1', 'student2'],
  | 
        
        
            | 
            | 
           362 | 
                           'blindmarking' => false,
  | 
        
        
            | 
            | 
           363 | 
                           'downloadasfolder' => true,
  | 
        
        
            | 
            | 
           364 | 
                           'expected' => [
  | 
        
        
            | 
            | 
           365 | 
                               'GROUP1_GROUP1.ID_assignsubmission_file/submissionsample01.txt',
  | 
        
        
            | 
            | 
           366 | 
                               'GROUP1_GROUP1.ID_assignsubmission_file/submissionsample02.txt',
  | 
        
        
            | 
            | 
           367 | 
                           ],
  | 
        
        
            | 
            | 
           368 | 
                       ],
  | 
        
        
            | 
            | 
           369 | 
                       $prefix . ' Filtered users without groups with users in the default team' => [
  | 
        
        
            | 
            | 
           370 | 
                           'teamsubmission' => true,
  | 
        
        
            | 
            | 
           371 | 
                           'groupmembers' => [
  | 
        
        
            | 
            | 
           372 | 
                               'group1' => ['student1', 'student2'],
  | 
        
        
            | 
            | 
           373 | 
                           ],
  | 
        
        
            | 
            | 
           374 | 
                           'filterusers' => ['student3', 'student4'],
  | 
        
        
            | 
            | 
           375 | 
                           'blindmarking' => false,
  | 
        
        
            | 
            | 
           376 | 
                           'downloadasfolder' => true,
  | 
        
        
            | 
            | 
           377 | 
                           'expected' => [
  | 
        
        
            | 
            | 
           378 | 
                               'DEFAULTTEAM_assignsubmission_file/submissionsample01.txt',
  | 
        
        
            | 
            | 
           379 | 
                               'DEFAULTTEAM_assignsubmission_file/submissionsample02.txt',
  | 
        
        
            | 
            | 
           380 | 
                           ],
  | 
        
        
            | 
            | 
           381 | 
                       ],
  | 
        
        
            | 
            | 
           382 | 
                       $prefix . ' Filtered users with some users in the default team' => [
  | 
        
        
            | 
            | 
           383 | 
                           'teamsubmission' => true,
  | 
        
        
            | 
            | 
           384 | 
                           'groupmembers' => [
  | 
        
        
            | 
            | 
           385 | 
                               'group1' => ['student1', 'student2'],
  | 
        
        
            | 
            | 
           386 | 
                           ],
  | 
        
        
            | 
            | 
           387 | 
                           'filterusers' => ['student1', 'student3'],
  | 
        
        
            | 
            | 
           388 | 
                           'blindmarking' => false,
  | 
        
        
            | 
            | 
           389 | 
                           'downloadasfolder' => true,
  | 
        
        
            | 
            | 
           390 | 
                           'expected' => [
  | 
        
        
            | 
            | 
           391 | 
                               'GROUP1_GROUP1.ID_assignsubmission_file/submissionsample01.txt',
  | 
        
        
            | 
            | 
           392 | 
                               'GROUP1_GROUP1.ID_assignsubmission_file/submissionsample02.txt',
  | 
        
        
            | 
            | 
           393 | 
                               'DEFAULTTEAM_assignsubmission_file/submissionsample01.txt',
  | 
        
        
            | 
            | 
           394 | 
                               'DEFAULTTEAM_assignsubmission_file/submissionsample02.txt',
  | 
        
        
            | 
            | 
           395 | 
                           ],
  | 
        
        
            | 
            | 
           396 | 
                       ],
  | 
        
        
            | 
            | 
           397 | 
                       $prefix . ' Filtering users with joined groups' => [
  | 
        
        
            | 
            | 
           398 | 
                           'teamsubmission' => true,
  | 
        
        
            | 
            | 
           399 | 
                           'groupmembers' => [
  | 
        
        
            | 
            | 
           400 | 
                               'group1' => ['student1', 'student2'],
  | 
        
        
            | 
            | 
           401 | 
                               'group2' => ['student2', 'student3'],
  | 
        
        
            | 
            | 
           402 | 
                           ],
  | 
        
        
            | 
            | 
           403 | 
                           'filterusers' => ['student1', 'student2'],
  | 
        
        
            | 
            | 
           404 | 
                           'blindmarking' => false,
  | 
        
        
            | 
            | 
           405 | 
                           'downloadasfolder' => true,
  | 
        
        
            | 
            | 
           406 | 
                           'expected' => [
  | 
        
        
            | 
            | 
           407 | 
                               'GROUP1_GROUP1.ID_assignsubmission_file/submissionsample01.txt',
  | 
        
        
            | 
            | 
           408 | 
                               'GROUP1_GROUP1.ID_assignsubmission_file/submissionsample02.txt',
  | 
        
        
            | 
            | 
           409 | 
                               'DEFAULTTEAM_assignsubmission_file/submissionsample01.txt',
  | 
        
        
            | 
            | 
           410 | 
                               'DEFAULTTEAM_assignsubmission_file/submissionsample02.txt',
  | 
        
        
            | 
            | 
           411 | 
                           ],
  | 
        
        
            | 
            | 
           412 | 
                       ],
  | 
        
        
            | 
            | 
           413 | 
                       // Tests with blind marking.
  | 
        
        
            | 
            | 
           414 | 
                       $prefix . ' All users without groups and blindmarking' => [
  | 
        
        
            | 
            | 
           415 | 
                           'teamsubmission' => false,
  | 
        
        
            | 
            | 
           416 | 
                           'groupmembers' => [],
  | 
        
        
            | 
            | 
           417 | 
                           'filterusers' => null,
  | 
        
        
            | 
            | 
           418 | 
                           'blindmarking' => true,
  | 
        
        
            | 
            | 
           419 | 
                           'downloadasfolder' => true,
  | 
        
        
            | 
            | 
           420 | 
                           'expected' => [
  | 
        
        
            | 
            | 
           421 | 
                               'PARTICIPANT_STUDENT1.ID_assignsubmission_file/submissionsample01.txt',
  | 
        
        
            | 
            | 
           422 | 
                               'PARTICIPANT_STUDENT1.ID_assignsubmission_file/submissionsample02.txt',
  | 
        
        
            | 
            | 
           423 | 
                               'PARTICIPANT_STUDENT2.ID_assignsubmission_file/submissionsample01.txt',
  | 
        
        
            | 
            | 
           424 | 
                               'PARTICIPANT_STUDENT2.ID_assignsubmission_file/submissionsample02.txt',
  | 
        
        
            | 
            | 
           425 | 
                               'PARTICIPANT_STUDENT3.ID_assignsubmission_file/submissionsample01.txt',
  | 
        
        
            | 
            | 
           426 | 
                               'PARTICIPANT_STUDENT3.ID_assignsubmission_file/submissionsample02.txt',
  | 
        
        
            | 
            | 
           427 | 
                               'PARTICIPANT_STUDENT4.ID_assignsubmission_file/submissionsample01.txt',
  | 
        
        
            | 
            | 
           428 | 
                               'PARTICIPANT_STUDENT4.ID_assignsubmission_file/submissionsample02.txt',
  | 
        
        
            | 
            | 
           429 | 
                           ],
  | 
        
        
            | 
            | 
           430 | 
                       ],
  | 
        
        
            | 
            | 
           431 | 
                       $prefix . ' Filtered users without groups and blindmarking' => [
  | 
        
        
            | 
            | 
           432 | 
                           'teamsubmission' => false,
  | 
        
        
            | 
            | 
           433 | 
                           'groupmembers' => [],
  | 
        
        
            | 
            | 
           434 | 
                           'filterusers' => ['student1', 'student2'],
  | 
        
        
            | 
            | 
           435 | 
                           'blindmarking' => true,
  | 
        
        
            | 
            | 
           436 | 
                           'downloadasfolder' => true,
  | 
        
        
            | 
            | 
           437 | 
                           'expected' => [
  | 
        
        
            | 
            | 
           438 | 
                               'PARTICIPANT_STUDENT1.ID_assignsubmission_file/submissionsample01.txt',
  | 
        
        
            | 
            | 
           439 | 
                               'PARTICIPANT_STUDENT1.ID_assignsubmission_file/submissionsample02.txt',
  | 
        
        
            | 
            | 
           440 | 
                               'PARTICIPANT_STUDENT2.ID_assignsubmission_file/submissionsample01.txt',
  | 
        
        
            | 
            | 
           441 | 
                               'PARTICIPANT_STUDENT2.ID_assignsubmission_file/submissionsample02.txt',
  | 
        
        
            | 
            | 
           442 | 
                           ],
  | 
        
        
            | 
            | 
           443 | 
                       ],
  | 
        
        
            | 
            | 
           444 | 
                   ];
  | 
        
        
            | 
            | 
           445 | 
               }
  | 
        
        
            | 
            | 
           446 | 
           }
  |