Skip to content

Commit

Permalink
MDL-57576 assignment: Overwrite feedback file if it has the same name.
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Thee Roperto committed Jan 5, 2017
1 parent 6b5bff8 commit 33952ce
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions mod/assign/feedback/file/locallib.php
Expand Up @@ -179,6 +179,20 @@ private function copy_area_files(file_storage $fs,
// automatically with current timestamp.
continue;
}

$existingfile = $fs->get_file(
$newfilerecord->contextid,
$newfilerecord->component,
$newfilerecord->filearea,
$newfilerecord->itemid,
$file->get_filepath(),
$file->get_filename()
);
if ($existingfile) {
// If the file already exists, remove it so it can be updated.
$existingfile->delete();
}

$newfile = $fs->create_file_from_storedfile($newfilerecord, $file);
}
}
Expand Down

0 comments on commit 33952ce

Please sign in to comment.