public function download_rewrite_pluginfile_urls($text, $user, $plugin) {
        // The groupname prefix for the urls doesn't depend on the group mode of the assignment instance.
        // Rather, it should be determined by checking the group submission settings of the instance,
        // which is what download_submission() does when generating the file name prefixes.
        $groupname = '';
        if ($this->get_instance()->teamsubmission) {
            $submissiongroup = $this->get_submission_group($user->id);
            if ($submissiongroup) {
                $groupname = $submissiongroup->name . '-';
            } else {
                $groupname = get_string('defaultteam', 'assign') . '-';
            }
        }

        if ($this->is_blind_marking()) {
            $prefix = $groupname . get_string('participant', 'assign');
            $prefix = str_replace('_', ' ', $prefix);
            $prefix = clean_filename($prefix . '_' . $this->get_uniqueid_for_user($user->id) . '_');
        } else {
            $prefix = $groupname . fullname($user);
            $prefix = str_replace('_', ' ', $prefix);
            $prefix = clean_filename($prefix . '_' . $this->get_uniqueid_for_user($user->id) . '_');
        }

        // Only prefix files if downloadasfolders user preference is NOT set.
        if (!get_user_preferences('assign_downloadasfolders', 1)) {
            $subtype = $plugin->get_subtype();
            $type = $plugin->get_type();
            $prefix = $prefix . $subtype . '_' . $type . '_';
        } else {
            $prefix = "";
        }
        $result = str_replace('@@PLUGINFILE@@/', $prefix, $text);

        return $result;
    }