mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 17:06:53 +02:00
MDL-52489 mod_assign: added support for old structure
This commit is contained in:
parent
5a2c7af2d3
commit
aa75dca3d8
1 changed files with 19 additions and 4 deletions
|
@ -236,14 +236,29 @@ class assignfeedback_file_zip_importer {
|
||||||
if ($this->is_valid_filename_for_import($assignment, $unzippedfile, $participants, $user, $plugin, $filename)) {
|
if ($this->is_valid_filename_for_import($assignment, $unzippedfile, $participants, $user, $plugin, $filename)) {
|
||||||
if ($this->is_file_modified($assignment, $user, $plugin, $filename, $unzippedfile)) {
|
if ($this->is_file_modified($assignment, $user, $plugin, $filename, $unzippedfile)) {
|
||||||
$grade = $assignment->get_user_grade($user->id, true);
|
$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);
|
$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,
|
if ($oldfile = $fs->get_file($contextid,
|
||||||
'assignfeedback_file',
|
'assignfeedback_file',
|
||||||
ASSIGNFEEDBACK_FILE_FILEAREA,
|
ASSIGNFEEDBACK_FILE_FILEAREA,
|
||||||
$grade->id,
|
$grade->id,
|
||||||
$path['dirname'],
|
$dirname,
|
||||||
$path['basename'])) {
|
$basename)) {
|
||||||
// Update existing feedback file.
|
// Update existing feedback file.
|
||||||
$oldfile->replace_file_with($unzippedfile);
|
$oldfile->replace_file_with($unzippedfile);
|
||||||
$feedbackfilesupdated++;
|
$feedbackfilesupdated++;
|
||||||
|
@ -253,8 +268,8 @@ class assignfeedback_file_zip_importer {
|
||||||
$newfilerecord->contextid = $contextid;
|
$newfilerecord->contextid = $contextid;
|
||||||
$newfilerecord->component = 'assignfeedback_file';
|
$newfilerecord->component = 'assignfeedback_file';
|
||||||
$newfilerecord->filearea = ASSIGNFEEDBACK_FILE_FILEAREA;
|
$newfilerecord->filearea = ASSIGNFEEDBACK_FILE_FILEAREA;
|
||||||
$newfilerecord->filename = $path['basename'];
|
$newfilerecord->filename = $basename;
|
||||||
$newfilerecord->filepath = $path['dirname']."/";
|
$newfilerecord->filepath = $dirnamewslash;
|
||||||
$newfilerecord->itemid = $grade->id;
|
$newfilerecord->itemid = $grade->id;
|
||||||
$fs->create_file_from_storedfile($newfilerecord, $unzippedfile);
|
$fs->create_file_from_storedfile($newfilerecord, $unzippedfile);
|
||||||
$feedbackfilesadded++;
|
$feedbackfilesadded++;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue