mirror of
https://github.com/moodle/moodle.git
synced 2025-04-20 07:56:06 +02:00
Merge branch 'MDL-52489_master' of git://github.com/markn86/moodle
This commit is contained in:
commit
121a0d12fb
@ -81,6 +81,7 @@ class assignfeedback_file_import_zip_form extends moodleform implements renderab
|
||||
if ($importer->is_file_modified($assignment, $user, $plugin, $filename, $unzippedfile)) {
|
||||
// Get a string we can show to identify this user.
|
||||
$userdesc = fullname($user);
|
||||
$path = pathinfo($filename);
|
||||
if ($assignment->is_blind_marking()) {
|
||||
$userdesc = get_string('hiddenuser', 'assign') .
|
||||
$assignment->get_uniqueid_for_user($user->id);
|
||||
@ -93,8 +94,8 @@ class assignfeedback_file_import_zip_form extends moodleform implements renderab
|
||||
'assignfeedback_file',
|
||||
ASSIGNFEEDBACK_FILE_FILEAREA,
|
||||
$grade->id,
|
||||
'/',
|
||||
$filename);
|
||||
$path['dirname'],
|
||||
$path['basename']);
|
||||
}
|
||||
|
||||
if (!$grade || !$exists) {
|
||||
|
@ -59,7 +59,7 @@ class assignfeedback_file_zip_importer {
|
||||
return false;
|
||||
}
|
||||
|
||||
$info = explode('_', $fileinfo->get_filename(), 5);
|
||||
$info = explode('_', $fileinfo->get_filepath() . $fileinfo->get_filename(), 5);
|
||||
|
||||
if (count($info) < 5) {
|
||||
return false;
|
||||
@ -192,18 +192,9 @@ class assignfeedback_file_zip_importer {
|
||||
'assignfeedback_file',
|
||||
ASSIGNFEEDBACK_FILE_IMPORT_FILEAREA,
|
||||
$USER->id,
|
||||
'/import/');
|
||||
'/import/', true); // Get files recursive (all levels).
|
||||
|
||||
$keys = array_keys($files);
|
||||
if (count($files) == 1 && $files[$keys[0]]->is_directory()) {
|
||||
// An entire folder was zipped, rather than its contents.
|
||||
// We need to return the contents of the folder instead, so the import can continue.
|
||||
$files = $fs->get_directory_files($contextid,
|
||||
'assignfeedback_file',
|
||||
ASSIGNFEEDBACK_FILE_IMPORT_FILEAREA,
|
||||
$USER->id,
|
||||
$files[$keys[0]]->get_filepath());
|
||||
}
|
||||
|
||||
return $files;
|
||||
}
|
||||
@ -246,12 +237,28 @@ class assignfeedback_file_zip_importer {
|
||||
if ($this->is_file_modified($assignment, $user, $plugin, $filename, $unzippedfile)) {
|
||||
$grade = $assignment->get_user_grade($user->id, true);
|
||||
|
||||
// In 3.1 the download structure of the submission files changed so that each student had their own
|
||||
// separate folder, the files were not renamed and the folder structure was kept. It is possible that
|
||||
// a user downloaded the submission files in 3.0 (or earlier) and edited the zip to add feedback and
|
||||
// in that time the site was updated to 3.1, the following code means that we will still support the
|
||||
// old file structure. For more information please see - MDL-52489.
|
||||
$path = pathinfo($filename);
|
||||
if ($path['dirname'] == '.') { // Old structure as students are not in separate folders.
|
||||
$basename = $filename;
|
||||
$dirname = "/";
|
||||
$dirnamewslash = "/";
|
||||
} else {
|
||||
$basename = $path['basename'];
|
||||
$dirname = $path['dirname'];
|
||||
$dirnamewslash = $dirname . "/";
|
||||
}
|
||||
|
||||
if ($oldfile = $fs->get_file($contextid,
|
||||
'assignfeedback_file',
|
||||
ASSIGNFEEDBACK_FILE_FILEAREA,
|
||||
$grade->id,
|
||||
'/',
|
||||
$filename)) {
|
||||
$dirname,
|
||||
$basename)) {
|
||||
// Update existing feedback file.
|
||||
$oldfile->replace_file_with($unzippedfile);
|
||||
$feedbackfilesupdated++;
|
||||
@ -261,8 +268,8 @@ class assignfeedback_file_zip_importer {
|
||||
$newfilerecord->contextid = $contextid;
|
||||
$newfilerecord->component = 'assignfeedback_file';
|
||||
$newfilerecord->filearea = ASSIGNFEEDBACK_FILE_FILEAREA;
|
||||
$newfilerecord->filename = $filename;
|
||||
$newfilerecord->filepath = '/';
|
||||
$newfilerecord->filename = $basename;
|
||||
$newfilerecord->filepath = $dirnamewslash;
|
||||
$newfilerecord->itemid = $grade->id;
|
||||
$fs->create_file_from_storedfile($newfilerecord, $unzippedfile);
|
||||
$feedbackfilesadded++;
|
||||
|
@ -2727,26 +2727,35 @@ class assign {
|
||||
|
||||
if ($this->is_blind_marking()) {
|
||||
$prefix = str_replace('_', ' ', $groupname . get_string('participant', 'assign'));
|
||||
$prefix = clean_filename($prefix . '_' . $this->get_uniqueid_for_user($userid) . '_');
|
||||
$prefix = clean_filename($prefix . '_' . $this->get_uniqueid_for_user($userid));
|
||||
} else {
|
||||
$prefix = str_replace('_', ' ', $groupname . fullname($student));
|
||||
$prefix = clean_filename($prefix . '_' . $this->get_uniqueid_for_user($userid) . '_');
|
||||
$prefix = clean_filename($prefix . '_' . $this->get_uniqueid_for_user($userid));
|
||||
}
|
||||
|
||||
if ($submission) {
|
||||
foreach ($this->submissionplugins as $plugin) {
|
||||
if ($plugin->is_enabled() && $plugin->is_visible()) {
|
||||
$pluginfiles = $plugin->get_files($submission, $student);
|
||||
foreach ($pluginfiles as $zipfilename => $file) {
|
||||
foreach ($pluginfiles as $zipfilepath => $file) {
|
||||
$subtype = $plugin->get_subtype();
|
||||
$type = $plugin->get_type();
|
||||
$zipfilename = basename($zipfilepath);
|
||||
$prefixedfilename = clean_filename($prefix .
|
||||
'_' .
|
||||
$subtype .
|
||||
'_' .
|
||||
$type .
|
||||
'_' .
|
||||
$zipfilename);
|
||||
$filesforzipping[$prefixedfilename] = $file;
|
||||
'_');
|
||||
if ($type == 'file') {
|
||||
$pathfilename = $prefixedfilename . $file->get_filepath() . $zipfilename;
|
||||
} else if ($type == 'onlinetext') {
|
||||
$pathfilename = $prefixedfilename . '/' . $zipfilename;
|
||||
} else {
|
||||
$pathfilename = $prefixedfilename . '/' . $zipfilename;
|
||||
}
|
||||
$pathfilename = clean_param($pathfilename, PARAM_PATH);
|
||||
$filesforzipping[$pathfilename] = $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -304,7 +304,7 @@ class assign_submission_file extends assign_submission_plugin {
|
||||
false);
|
||||
|
||||
foreach ($files as $file) {
|
||||
$result[$file->get_filename()] = $file;
|
||||
$result[$file->get_filepath().$file->get_filename()] = $file;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
@ -3,6 +3,8 @@ This files describes API changes in the assign code.
|
||||
=== 3.1 ===
|
||||
* The feedback plugins now need to implement the is_feedback_modified() method. The default is to return true
|
||||
for backwards compatibiltiy.
|
||||
* When downloading all submissions as a zip each students' files are in a separate folder, are no longer renamed
|
||||
and the folder structure is kept intact.
|
||||
|
||||
=== 3.0 ===
|
||||
* assign_submission_status renderable now requires $usergroups in its constructor
|
||||
|
Loading…
x
Reference in New Issue
Block a user