mirror of
https://github.com/moodle/moodle.git
synced 2025-08-08 10:26:40 +02:00
MDL-59893 assign: fixes for groupname prefix when downloading
assign->download_submissions(): - groupname now only added to zip file name if not empty, fixing a double hyphen bug in the file name. assign->download_rewrite_pluginfile_urls(): - groupname is now correctly determined using get_submission_group() instead of using groups_get_activity_group() which fails when there is no active activity group set. Uses the same logic that download_submission() uses to prefix file names. Fixes a bug where an empty groupname prefix was generated, resulting in broken links.
This commit is contained in:
parent
27466d7548
commit
a15dfc6682
1 changed files with 13 additions and 5 deletions
|
@ -2944,11 +2944,17 @@ class assign {
|
|||
* @param assign_plugin $plugin - The assignment plugin
|
||||
*/
|
||||
public function download_rewrite_pluginfile_urls($text, $user, $plugin) {
|
||||
$groupmode = groups_get_activity_groupmode($this->get_course_module());
|
||||
// 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 ($groupmode) {
|
||||
$groupid = groups_get_activity_group($this->get_course_module(), true);
|
||||
$groupname = groups_get_group_name($groupid).'-';
|
||||
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()) {
|
||||
|
@ -3172,8 +3178,10 @@ class assign {
|
|||
$groupname = '';
|
||||
if ($groupmode) {
|
||||
$groupid = groups_get_activity_group($this->get_course_module(), true);
|
||||
if (!empty($groupid)) {
|
||||
$groupname = groups_get_group_name($groupid) . '-';
|
||||
}
|
||||
}
|
||||
|
||||
// Construct the zip file name.
|
||||
$filename = clean_filename($this->get_course()->shortname . '-' .
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue