use of org.olat.course.nodes.gta.model.Solution in project OpenOLAT by OpenOLAT.
the class ConvertToGTACourseNode method copySolutions.
private void copySolutions(TACourseNode sourceNode, GTACourseNode gtaNode, CourseEnvironment courseEnv) {
ModuleConfiguration gtaConfig = gtaNode.getModuleConfiguration();
String solutionPath = SolutionController.getSolutionPathRelToFolderRoot(courseEnv, sourceNode);
OlatRootFolderImpl solutionContainer = new OlatRootFolderImpl(solutionPath, null);
VFSContainer solutionDirectory = gtaManager.getSolutionsContainer(courseEnv, gtaNode);
SolutionList solutionList = new SolutionList();
for (VFSItem solution : solutionContainer.getItems()) {
if (solution instanceof VFSLeaf) {
VFSLeaf solutionDocument = solutionDirectory.createChildLeaf(solution.getName());
VFSManager.copyContent((VFSLeaf) solution, solutionDocument);
Solution solDef = new Solution();
convertMetada(solutionContainer, solutionDirectory, solution.getName(), null, solDef);
solDef.setFilename(solution.getName());
solutionList.getSolutions().add(solDef);
}
}
gtaConfig.set(GTACourseNode.GTASK_SOLUTIONS, solutionList);
}
use of org.olat.course.nodes.gta.model.Solution in project openolat by klemens.
the class GTASampleSolutionsEditController method event.
@Override
protected void event(UserRequest ureq, Controller source, Event event) {
if (addSolutionCtrl == source) {
if (event == Event.DONE_EVENT) {
Solution newSolution = addSolutionCtrl.getSolution();
gtaManager.addSolution(newSolution, courseEnv, gtaNode);
fireEvent(ureq, Event.DONE_EVENT);
updateModel();
notificationsManager.markPublisherNews(subscriptionContext, null, false);
}
cmc.deactivate();
cleanUp();
} else if (editSolutionCtrl == source) {
if (event == Event.DONE_EVENT) {
gtaManager.updateSolution(editSolutionCtrl.getFilenameToReplace(), editSolutionCtrl.getSolution(), courseEnv, gtaNode);
fireEvent(ureq, Event.DONE_EVENT);
updateModel();
notificationsManager.markPublisherNews(subscriptionContext, null, false);
}
cmc.deactivate();
cleanUp();
} else if (newSolutionCtrl == source) {
Solution newSolution = newSolutionCtrl.getSolution();
cmc.deactivate();
cleanUp();
if (event == Event.DONE_EVENT) {
gtaManager.addSolution(newSolution, courseEnv, gtaNode);
doCreateSolutionEditor(ureq, newSolution);
updateModel();
notificationsManager.markPublisherNews(subscriptionContext, null, false);
}
} else if (newSolutionEditorCtrl == source) {
if (event == Event.DONE_EVENT) {
updateModel();
fireEvent(ureq, Event.DONE_EVENT);
notificationsManager.markPublisherNews(subscriptionContext, null, false);
}
cmc.deactivate();
cleanUp();
} else if (editSolutionEditorCtrl == source) {
// edit solution cannot update the title or the description
notificationsManager.markPublisherNews(subscriptionContext, null, false);
cmc.deactivate();
cleanUp();
} else if (cmc == source) {
cleanUp();
}
super.event(ureq, source, event);
}
use of org.olat.course.nodes.gta.model.Solution in project openolat by klemens.
the class NewSolutionController method getSolution.
public Solution getSolution() {
Solution solution = new Solution();
solution.setTitle(titleEl.getValue());
solution.setFilename(getFilename());
return solution;
}
use of org.olat.course.nodes.gta.model.Solution in project openolat by klemens.
the class GTAManagerImpl method getSolutions.
@Override
public List<Solution> getSolutions(CourseEnvironment courseEnv, GTACourseNode cNode) {
Path solutionDefinitionsPath = Paths.get(FolderConfig.getCanonicalRoot(), courseEnv.getCourseBaseContainer().getRelPath(), "gtasks", cNode.getIdent(), SOLUTIONS_DEFINITIONS);
List<Solution> solutionsDefinitions = new ArrayList<>();
if (Files.exists(solutionDefinitionsPath)) {
SolutionList solutionDefinitionsList = (SolutionList) taskDefinitionsXstream.fromXML(solutionDefinitionsPath.toFile());
if (solutionDefinitionsList != null && solutionDefinitionsList.getSolutions() != null) {
solutionsDefinitions.addAll(solutionDefinitionsList.getSolutions());
}
} else {
syncWithTaskList(courseEnv, cNode, new TaskListSynched() {
@Override
public void sync() {
ModuleConfiguration config = cNode.getModuleConfiguration();
SolutionList solutions = (SolutionList) config.get(GTACourseNode.GTASK_SOLUTIONS);
if (solutions != null && solutions.getSolutions() != null) {
solutionsDefinitions.addAll(solutions.getSolutions());
}
storeSolutions(solutionsDefinitions, courseEnv, cNode);
}
});
}
return solutionsDefinitions;
}
use of org.olat.course.nodes.gta.model.Solution in project openolat by klemens.
the class ConvertToGTACourseNode method copySolutions.
private void copySolutions(TACourseNode sourceNode, GTACourseNode gtaNode, CourseEnvironment courseEnv) {
ModuleConfiguration gtaConfig = gtaNode.getModuleConfiguration();
String solutionPath = SolutionController.getSolutionPathRelToFolderRoot(courseEnv, sourceNode);
OlatRootFolderImpl solutionContainer = new OlatRootFolderImpl(solutionPath, null);
VFSContainer solutionDirectory = gtaManager.getSolutionsContainer(courseEnv, gtaNode);
SolutionList solutionList = new SolutionList();
for (VFSItem solution : solutionContainer.getItems()) {
if (solution instanceof VFSLeaf) {
VFSLeaf solutionDocument = solutionDirectory.createChildLeaf(solution.getName());
VFSManager.copyContent((VFSLeaf) solution, solutionDocument);
Solution solDef = new Solution();
convertMetada(solutionContainer, solutionDirectory, solution.getName(), null, solDef);
solDef.setFilename(solution.getName());
solutionList.getSolutions().add(solDef);
}
}
gtaConfig.set(GTACourseNode.GTASK_SOLUTIONS, solutionList);
}
Aggregations