use of org.olat.course.nodes.gta.model.SolutionList in project OpenOLAT by OpenOLAT.
the class GTAManagerImpl method storeSolutions.
private void storeSolutions(List<Solution> solutions, CourseEnvironment courseEnv, GTACourseNode cNode) {
SolutionList list = new SolutionList();
list.setSolutions(solutions);
Path solutionsPath = Paths.get(FolderConfig.getCanonicalRoot(), courseEnv.getCourseBaseContainer().getRelPath(), "gtasks", cNode.getIdent(), SOLUTIONS_DEFINITIONS);
XStreamHelper.writeObject(taskDefinitionsXstream, solutionsPath.toFile(), list);
}
use of org.olat.course.nodes.gta.model.SolutionList in project OpenOLAT by OpenOLAT.
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.SolutionList 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.SolutionList in project openolat by klemens.
the class GTAManagerImpl method storeSolutions.
private void storeSolutions(List<Solution> solutions, CourseEnvironment courseEnv, GTACourseNode cNode) {
SolutionList list = new SolutionList();
list.setSolutions(solutions);
Path solutionsPath = Paths.get(FolderConfig.getCanonicalRoot(), courseEnv.getCourseBaseContainer().getRelPath(), "gtasks", cNode.getIdent(), SOLUTIONS_DEFINITIONS);
XStreamHelper.writeObject(taskDefinitionsXstream, solutionsPath.toFile(), list);
}
use of org.olat.course.nodes.gta.model.SolutionList 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;
}
Aggregations