use of org.olat.course.nodes.gta.model.Solution in project OpenOLAT by OpenOLAT.
the class GTASampleSolutionsEditController method updateModel.
private void updateModel() {
List<Solution> solutionList = gtaManager.getSolutions(courseEnv, gtaNode);
List<SolutionRow> rows = new ArrayList<>(solutionList.size());
for (Solution solution : solutionList) {
String filename = solution.getFilename();
String author = null;
VFSItem item = solutionContainer.resolve(filename);
if (item instanceof MetaTagged) {
MetaInfo metaInfo = ((MetaTagged) item).getMetaInfo();
if (metaInfo != null && metaInfo.getAuthorIdentityKey() != null) {
author = userManager.getUserDisplayName(metaInfo.getAuthorIdentityKey());
}
}
DownloadLink downloadLink = null;
if (item instanceof VFSLeaf) {
downloadLink = uifactory.addDownloadLink("file_" + (++linkCounter), filename, null, (VFSLeaf) item, solutionTable);
}
rows.add(new SolutionRow(solution, author, downloadLink));
}
solutionModel.setObjects(rows);
solutionTable.reset();
}
use of org.olat.course.nodes.gta.model.Solution in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
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 GTASampleSolutionsEditController method updateModel.
private void updateModel() {
List<Solution> solutionList = gtaManager.getSolutions(courseEnv, gtaNode);
List<SolutionRow> rows = new ArrayList<>(solutionList.size());
for (Solution solution : solutionList) {
String filename = solution.getFilename();
String author = null;
VFSItem item = solutionContainer.resolve(filename);
if (item instanceof MetaTagged) {
MetaInfo metaInfo = ((MetaTagged) item).getMetaInfo();
if (metaInfo != null && metaInfo.getAuthorIdentityKey() != null) {
author = userManager.getUserDisplayName(metaInfo.getAuthorIdentityKey());
}
}
DownloadLink downloadLink = null;
if (item instanceof VFSLeaf) {
downloadLink = uifactory.addDownloadLink("file_" + (++linkCounter), filename, null, (VFSLeaf) item, solutionTable);
}
rows.add(new SolutionRow(solution, author, downloadLink));
}
solutionModel.setObjects(rows);
solutionTable.reset();
}
use of org.olat.course.nodes.gta.model.Solution 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;
}
Aggregations