Search in sources :

Example 6 with Solution

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);
}
Also used : SolutionList(org.olat.course.nodes.gta.model.SolutionList) VFSLeaf(org.olat.core.util.vfs.VFSLeaf) ModuleConfiguration(org.olat.modules.ModuleConfiguration) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) VFSContainer(org.olat.core.util.vfs.VFSContainer) VFSItem(org.olat.core.util.vfs.VFSItem) Solution(org.olat.course.nodes.gta.model.Solution)

Example 7 with Solution

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

Example 8 with Solution

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

Example 9 with 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;
}
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)

Example 10 with Solution

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);
}
Also used : SolutionList(org.olat.course.nodes.gta.model.SolutionList) VFSLeaf(org.olat.core.util.vfs.VFSLeaf) ModuleConfiguration(org.olat.modules.ModuleConfiguration) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) VFSContainer(org.olat.core.util.vfs.VFSContainer) VFSItem(org.olat.core.util.vfs.VFSItem) 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