Merge branch 'MDL-59893-32' of https://github.com/snake/moodle into MOODLE_32_STABLE

This commit is contained in:
Andrew Nicols
2017-08-22 14:33:59 +08:00
+21 -9
View File
@@ -2891,11 +2891,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()) {
@@ -2908,10 +2914,14 @@ class assign {
$prefix = clean_filename($prefix . '_' . $this->get_uniqueid_for_user($user->id) . '_');
}
$subtype = $plugin->get_subtype();
$type = $plugin->get_type();
$prefix = $prefix . $subtype . '_' . $type . '_';
// 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;
@@ -3131,7 +3141,9 @@ class assign {
$groupname = '';
if ($groupmode) {
$groupid = groups_get_activity_group($this->get_course_module(), true);
$groupname = groups_get_group_name($groupid).'-';
if (!empty($groupid)) {
$groupname = groups_get_group_name($groupid) . '-';
}
}
// Construct the zip file name.