Search in sources :

Example 1 with PFCourseNode

use of org.olat.course.nodes.PFCourseNode in project OpenOLAT by OpenOLAT.

the class PFManagerTest method provideParticipantContainer.

@Test
public void provideParticipantContainer() {
    // prepare
    Identity initialAuthor = JunitTestHelper.createAndPersistIdentityAsRndUser("check-15");
    IdentityEnvironment ienv = new IdentityEnvironment();
    ienv.setIdentity(initialAuthor);
    PFCourseNode pfNode = new PFCourseNode();
    pfNode.getModuleConfiguration().setBooleanEntry(PFCourseNode.CONFIG_KEY_COACHBOX, true);
    pfNode.getModuleConfiguration().setBooleanEntry(PFCourseNode.CONFIG_KEY_PARTICIPANTBOX, true);
    // import "Demo course" into the bcroot_junittest
    RepositoryEntry entry = JunitTestHelper.deployDemoCourse(initialAuthor);
    Long resourceableId = entry.getOlatResource().getResourceableId();
    ICourse course = CourseFactory.loadCourse(resourceableId);
    UserCourseEnvironment userCourseEnv = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
    Identity check3 = JunitTestHelper.createAndPersistIdentityAsRndUser("check-3");
    repositoryEntryRelationDao.addRole(check3, entry, GroupRoles.participant.name());
    VFSContainer vfsContainer = pfManager.provideCoachOrParticipantContainer(pfNode, userCourseEnv, check3, false);
    Assert.assertNotNull(vfsContainer);
    Assert.assertTrue(vfsContainer.exists());
}
Also used : PFCourseNode(org.olat.course.nodes.PFCourseNode) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) VFSContainer(org.olat.core.util.vfs.VFSContainer) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) IdentityEnvironment(org.olat.core.id.IdentityEnvironment) Test(org.junit.Test)

Example 2 with PFCourseNode

use of org.olat.course.nodes.PFCourseNode in project OpenOLAT by OpenOLAT.

the class PFManagerTest method provideCoachContainer.

@Test
public void provideCoachContainer() {
    // prepare
    Identity initialAuthor = JunitTestHelper.createAndPersistIdentityAsRndUser("check-16");
    IdentityEnvironment ienv = new IdentityEnvironment();
    ienv.setIdentity(initialAuthor);
    PFCourseNode pfNode = new PFCourseNode();
    pfNode.getModuleConfiguration().setBooleanEntry(PFCourseNode.CONFIG_KEY_COACHBOX, true);
    pfNode.getModuleConfiguration().setBooleanEntry(PFCourseNode.CONFIG_KEY_PARTICIPANTBOX, true);
    // import "Demo course" into the bcroot_junittest
    RepositoryEntry entry = JunitTestHelper.deployDemoCourse(initialAuthor);
    Long resourceableId = entry.getOlatResource().getResourceableId();
    ICourse course = CourseFactory.loadCourse(resourceableId);
    UserCourseEnvironment userCourseEnv = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
    Identity check4 = JunitTestHelper.createAndPersistIdentityAsRndUser("check-4");
    repositoryEntryRelationDao.addRole(check4, entry, GroupRoles.coach.name());
    VFSContainer vfsContainer = pfManager.provideCoachOrParticipantContainer(pfNode, userCourseEnv, check4, false);
    Assert.assertNotNull(vfsContainer);
}
Also used : PFCourseNode(org.olat.course.nodes.PFCourseNode) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) VFSContainer(org.olat.core.util.vfs.VFSContainer) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) IdentityEnvironment(org.olat.core.id.IdentityEnvironment) Test(org.junit.Test)

Example 3 with PFCourseNode

use of org.olat.course.nodes.PFCourseNode in project OpenOLAT by OpenOLAT.

the class MergedCourseContainer method addFoldersForAdmin.

/**
 * Internal method to recursively add all course building blocks of type
 * BC to a given VFS container. This should only be used for an author view,
 * it does not test for security.
 *
 * @param course
 * @param nodesContainer
 * @param courseNode
 * @return container for the current course node
 */
private void addFoldersForAdmin(PersistingCourseImpl course, MergeSource nodesContainer, CourseNode courseNode) {
    for (int i = 0; i < courseNode.getChildCount(); i++) {
        CourseNode child = (CourseNode) courseNode.getChildAt(i);
        String folderName = RequestUtil.normalizeFilename(child.getShortTitle());
        if (child instanceof BCCourseNode) {
            final BCCourseNode bcNode = (BCCourseNode) child;
            // add folder not to merge source. Use name and node id to have unique name
            VFSContainer rootFolder = getBCContainer(course, bcNode, null, true);
            if (courseReadOnly) {
                rootFolder.setLocalSecurityCallback(new ReadOnlyCallback());
            }
            folderName = getFolderName(nodesContainer, bcNode, folderName);
            if (rootFolder != null) {
                // Create a container for this node content and wrap it with a merge source which is attached to tree
                VFSContainer nodeContentContainer = new NamedContainerImpl(folderName, rootFolder);
                MergeSource courseNodeContainer = new MergeSource(nodesContainer, folderName);
                courseNodeContainer.addContainersChildren(nodeContentContainer, true);
                nodesContainer.addContainer(courseNodeContainer);
                // Do recursion for all children
                addFoldersForAdmin(course, courseNodeContainer, child);
            }
        } else if (child instanceof PFCourseNode) {
            final PFCourseNode pfNode = (PFCourseNode) child;
            // add folder not to merge source. Use name and node id to have unique name
            PFManager pfManager = CoreSpringFactory.getImpl(PFManager.class);
            folderName = getFolderName(nodesContainer, pfNode, folderName);
            MergeSource courseNodeContainer = new MergeSource(nodesContainer, folderName);
            VFSContainer rootFolder = pfManager.provideAdminContainer(pfNode, course.getCourseEnvironment());
            VFSContainer nodeContentContainer = new NamedContainerImpl(folderName, rootFolder);
            courseNodeContainer.addContainersChildren(nodeContentContainer, true);
            nodesContainer.addContainer(courseNodeContainer);
            // Do recursion for all children
            addFoldersForAdmin(course, courseNodeContainer, child);
        } else {
            // For non-folder course nodes, add merge source (no files to show) ...
            MergeSource courseNodeContainer = new MergeSource(null, folderName);
            // , then do recursion for all children ...
            addFoldersForAdmin(course, courseNodeContainer, child);
            // ... but only add this container if it contains any children with at least one BC course node
            if (!courseNodeContainer.getItems().isEmpty()) {
                nodesContainer.addContainer(courseNodeContainer);
            }
        }
    }
}
Also used : PFCourseNode(org.olat.course.nodes.PFCourseNode) PFManager(org.olat.course.nodes.pf.manager.PFManager) BCCourseNode(org.olat.course.nodes.BCCourseNode) MergeSource(org.olat.core.util.vfs.MergeSource) ReadOnlyCallback(org.olat.core.util.vfs.callbacks.ReadOnlyCallback) VFSContainer(org.olat.core.util.vfs.VFSContainer) PFCourseNode(org.olat.course.nodes.PFCourseNode) CourseNode(org.olat.course.nodes.CourseNode) BCCourseNode(org.olat.course.nodes.BCCourseNode) NamedContainerImpl(org.olat.core.util.vfs.NamedContainerImpl)

Example 4 with PFCourseNode

use of org.olat.course.nodes.PFCourseNode in project OpenOLAT by OpenOLAT.

the class ArchiverMainController method launchArchiveControllers.

private void launchArchiveControllers(UserRequest ureq, String menuCommand) {
    if (menuCommand.equals(CMD_INDEX)) {
        main.setContent(intro);
    } else {
        removeAsListenerAndDispose(contentCtr);
        if (menuCommand.equals(CMD_QTISURVRESULTS)) {
            contentCtr = new GenericArchiveController(ureq, getWindowControl(), ores, new IQSURVCourseNode());
            main.setContent(contentCtr.getInitialComponent());
        } else if (menuCommand.equals(CMD_QTITESTRESULTS)) {
            contentCtr = new TestArchiveController(ureq, getWindowControl(), ores, new IQTESTCourseNode(), new IQSELFCourseNode());
            main.setContent(contentCtr.getInitialComponent());
        } else if (menuCommand.equals(CMD_SCOREACCOUNTING)) {
            contentCtr = new ScoreAccountingArchiveController(ureq, getWindowControl(), ores);
            main.setContent(contentCtr.getInitialComponent());
        } else if (menuCommand.equals(CMD_ARCHIVELOGFILES)) {
            contentCtr = new CourseLogsArchiveController(ureq, getWindowControl(), ores);
            main.setContent(contentCtr.getInitialComponent());
        } else if (menuCommand.equals(CMD_HANDEDINTASKS)) {
            // TACourseNode
            contentCtr = new GenericArchiveController(ureq, getWindowControl(), ores, new TACourseNode());
            main.setContent(contentCtr.getInitialComponent());
        } else if (menuCommand.equals(CMD_GROUPTASKS)) {
            contentCtr = new GenericArchiveController(ureq, getWindowControl(), ores, new GTACourseNode(), new GTACourseNode(GTACourseNode.TYPE_INDIVIDUAL));
            main.setContent(contentCtr.getInitialComponent());
        } else if (menuCommand.equals(CMD_PROJECTBROKER)) {
            contentCtr = new GenericArchiveController(ureq, getWindowControl(), ores, new ProjectBrokerCourseNode());
            main.setContent(contentCtr.getInitialComponent());
        } else if (menuCommand.equals(CMD_FORUMS)) {
            contentCtr = new GenericArchiveController(ureq, getWindowControl(), ores, new FOCourseNode());
            main.setContent(contentCtr.getInitialComponent());
        } else if (menuCommand.equals(CMD_DIALOGS)) {
            contentCtr = new GenericArchiveController(ureq, getWindowControl(), ores, new DialogCourseNode());
            main.setContent(contentCtr.getInitialComponent());
        } else if (menuCommand.equals(CMD_WIKIS)) {
            contentCtr = new GenericArchiveController(ureq, getWindowControl(), ores, new WikiCourseNode());
            main.setContent(contentCtr.getInitialComponent());
        } else if (menuCommand.equals(CMD_SCORM)) {
            contentCtr = new GenericArchiveController(ureq, getWindowControl(), ores, new ScormCourseNode());
            main.setContent(contentCtr.getInitialComponent());
        } else if (menuCommand.equals(CMD_CHECKLIST)) {
            contentCtr = new GenericArchiveController(ureq, getWindowControl(), ores, new CheckListCourseNode());
            main.setContent(contentCtr.getInitialComponent());
        } else if (menuCommand.equals(CMD_PARTICIPANTFOLDER)) {
            contentCtr = new GenericArchiveController(ureq, getWindowControl(), ores, new PFCourseNode());
            main.setContent(contentCtr.getInitialComponent());
        }
        listenTo(contentCtr);
    }
}
Also used : PFCourseNode(org.olat.course.nodes.PFCourseNode) IQSURVCourseNode(org.olat.course.nodes.IQSURVCourseNode) GTACourseNode(org.olat.course.nodes.GTACourseNode) FOCourseNode(org.olat.course.nodes.FOCourseNode) TACourseNode(org.olat.course.nodes.TACourseNode) GTACourseNode(org.olat.course.nodes.GTACourseNode) CheckListCourseNode(org.olat.course.nodes.CheckListCourseNode) ScormCourseNode(org.olat.course.nodes.ScormCourseNode) IQTESTCourseNode(org.olat.course.nodes.IQTESTCourseNode) IQSELFCourseNode(org.olat.course.nodes.IQSELFCourseNode) DialogCourseNode(org.olat.course.nodes.DialogCourseNode) WikiCourseNode(org.olat.course.nodes.WikiCourseNode) ProjectBrokerCourseNode(org.olat.course.nodes.ProjectBrokerCourseNode)

Example 5 with PFCourseNode

use of org.olat.course.nodes.PFCourseNode in project openolat by klemens.

the class PFManagerTest method provideCoachContainer.

@Test
public void provideCoachContainer() {
    // prepare
    Identity initialAuthor = JunitTestHelper.createAndPersistIdentityAsRndUser("check-16");
    IdentityEnvironment ienv = new IdentityEnvironment();
    ienv.setIdentity(initialAuthor);
    PFCourseNode pfNode = new PFCourseNode();
    pfNode.getModuleConfiguration().setBooleanEntry(PFCourseNode.CONFIG_KEY_COACHBOX, true);
    pfNode.getModuleConfiguration().setBooleanEntry(PFCourseNode.CONFIG_KEY_PARTICIPANTBOX, true);
    // import "Demo course" into the bcroot_junittest
    RepositoryEntry entry = JunitTestHelper.deployDemoCourse(initialAuthor);
    Long resourceableId = entry.getOlatResource().getResourceableId();
    ICourse course = CourseFactory.loadCourse(resourceableId);
    UserCourseEnvironment userCourseEnv = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
    Identity check4 = JunitTestHelper.createAndPersistIdentityAsRndUser("check-4");
    repositoryEntryRelationDao.addRole(check4, entry, GroupRoles.coach.name());
    VFSContainer vfsContainer = pfManager.provideCoachOrParticipantContainer(pfNode, userCourseEnv, check4, false);
    Assert.assertNotNull(vfsContainer);
}
Also used : PFCourseNode(org.olat.course.nodes.PFCourseNode) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) VFSContainer(org.olat.core.util.vfs.VFSContainer) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) IdentityEnvironment(org.olat.core.id.IdentityEnvironment) Test(org.junit.Test)

Aggregations

PFCourseNode (org.olat.course.nodes.PFCourseNode)14 VFSContainer (org.olat.core.util.vfs.VFSContainer)12 UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)10 Test (org.junit.Test)8 Identity (org.olat.core.id.Identity)8 IdentityEnvironment (org.olat.core.id.IdentityEnvironment)8 ICourse (org.olat.course.ICourse)8 RepositoryEntry (org.olat.repository.RepositoryEntry)8 UserCourseEnvironmentImpl (org.olat.course.run.userview.UserCourseEnvironmentImpl)6 File (java.io.File)4 URL (java.net.URL)4 Path (java.nio.file.Path)4 OlatRootFolderImpl (org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)4 MergeSource (org.olat.core.util.vfs.MergeSource)4 NamedContainerImpl (org.olat.core.util.vfs.NamedContainerImpl)4 ReadOnlyCallback (org.olat.core.util.vfs.callbacks.ReadOnlyCallback)4 BCCourseNode (org.olat.course.nodes.BCCourseNode)4 CourseNode (org.olat.course.nodes.CourseNode)4 PFManager (org.olat.course.nodes.pf.manager.PFManager)4 CourseEnvironment (org.olat.course.run.environment.CourseEnvironment)4