Skip to content
Snippets Groups Projects
Commit bdac9cbd authored by srosse's avatar srosse
Browse files

OO-1758: rename solution if needed on "Add solution", delete old solution on "Replace"

parent 6b71591b
No related branches found
No related tags found
No related merge requests found
......@@ -39,6 +39,7 @@ import org.olat.core.gui.control.WindowControl;
import org.olat.core.util.StringHelper;
import org.olat.core.util.vfs.VFSContainer;
import org.olat.core.util.vfs.VFSItem;
import org.olat.core.util.vfs.VFSManager;
import org.olat.course.nodes.gta.model.Solution;
......@@ -60,12 +61,12 @@ public class EditSolutionController extends FormBasicController {
public EditSolutionController(UserRequest ureq, WindowControl wControl,
File solutionDir, VFSContainer solutionContainer) {
this(ureq, wControl, new Solution(), solutionDir, solutionContainer, true);
this(ureq, wControl, new Solution(), solutionDir, solutionContainer, false);
}
public EditSolutionController(UserRequest ureq, WindowControl wControl, Solution solution,
File solutionDir, VFSContainer solutionContainer) {
this(ureq, wControl, solution, solutionDir, solutionContainer, false);
this(ureq, wControl, solution, solutionDir, solutionContainer, true);
}
private EditSolutionController(UserRequest ureq, WindowControl wControl,
......@@ -145,6 +146,13 @@ public class EditSolutionController extends FormBasicController {
}
String filename = fileEl.getUploadFileName();
if(!replaceFile) {
File currentFile = new File(solutionDir, filename);
if(currentFile.exists()) {
filename = VFSManager.rename(solutionContainer, filename);
}
}
solution.setFilename(filename);
try {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment