Search in sources :

Example 1 with Solution

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();
}
Also used : DownloadLink(org.olat.core.gui.components.form.flexible.elements.DownloadLink) VFSLeaf(org.olat.core.util.vfs.VFSLeaf) ArrayList(java.util.ArrayList) MetaTagged(org.olat.core.commons.modules.bc.meta.tagged.MetaTagged) MetaInfo(org.olat.core.commons.modules.bc.meta.MetaInfo) VFSItem(org.olat.core.util.vfs.VFSItem) Solution(org.olat.course.nodes.gta.model.Solution)

Example 2 with Solution

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);
}
Also used : Solution(org.olat.course.nodes.gta.model.Solution)

Example 3 with Solution

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;
}
Also used : Solution(org.olat.course.nodes.gta.model.Solution)

Example 4 with 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();
}
Also used : DownloadLink(org.olat.core.gui.components.form.flexible.elements.DownloadLink) VFSLeaf(org.olat.core.util.vfs.VFSLeaf) ArrayList(java.util.ArrayList) MetaTagged(org.olat.core.commons.modules.bc.meta.tagged.MetaTagged) MetaInfo(org.olat.core.commons.modules.bc.meta.MetaInfo) VFSItem(org.olat.core.util.vfs.VFSItem) Solution(org.olat.course.nodes.gta.model.Solution)

Example 5 with Solution

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;
}
Also used : Path(java.nio.file.Path) SolutionList(org.olat.course.nodes.gta.model.SolutionList) ModuleConfiguration(org.olat.modules.ModuleConfiguration) ArrayList(java.util.ArrayList) Solution(org.olat.course.nodes.gta.model.Solution)

Aggregations

Solution (org.olat.course.nodes.gta.model.Solution)10 ArrayList (java.util.ArrayList)4 VFSItem (org.olat.core.util.vfs.VFSItem)4 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)4 SolutionList (org.olat.course.nodes.gta.model.SolutionList)4 ModuleConfiguration (org.olat.modules.ModuleConfiguration)4 Path (java.nio.file.Path)2 MetaInfo (org.olat.core.commons.modules.bc.meta.MetaInfo)2 MetaTagged (org.olat.core.commons.modules.bc.meta.tagged.MetaTagged)2 OlatRootFolderImpl (org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)2 DownloadLink (org.olat.core.gui.components.form.flexible.elements.DownloadLink)2 VFSContainer (org.olat.core.util.vfs.VFSContainer)2