Search in sources :

Example 91 with OLATResourceable

use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.

the class CategoryDAOTest method createRelationToCategory.

@Test
public void createRelationToCategory() {
    Category category = categoryDao.createAndPersistCategory("Cool");
    dbInstance.commitAndCloseSession();
    // create relation
    String rndType = UUID.randomUUID().toString();
    OLATResourceable ores = OresHelper.createOLATResourceableInstance(rndType, 234l);
    categoryDao.appendRelation(ores, category);
    dbInstance.commitAndCloseSession();
    // load relation
    List<Category> categories = categoryDao.getCategories(ores);
    Assert.assertNotNull(categories);
    Assert.assertEquals(1, categories.size());
    Assert.assertEquals(category, categories.get(0));
}
Also used : Category(org.olat.modules.portfolio.Category) OLATResourceable(org.olat.core.id.OLATResourceable) Test(org.junit.Test)

Example 92 with OLATResourceable

use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.

the class ReferenceManagerTest method testAddReference.

@Test
public void testAddReference() {
    OLATResource oressource = JunitTestHelper.createRandomResource();
    OLATResource orestarget = JunitTestHelper.createRandomResource();
    String udata = "üserdätä";
    // add a reference
    referenceManager.addReference(oressource, orestarget, udata);
    dbInstance.commitAndCloseSession();
    OLATResourceable targetOres = OresHelper.createOLATResourceableInstance(orestarget.getResourceableTypeName(), orestarget.getResourceableId());
    OLATResource orestarget2 = resourceManager.findOrPersistResourceable(targetOres);
    List<Reference> refs = referenceManager.getReferencesTo(orestarget2);
    Assert.assertNotNull(refs);
    Assert.assertEquals("only one reference may exist", 1, refs.size());
    Assert.assertEquals(oressource, refs.get(0).getSource());
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) OLATResource(org.olat.resource.OLATResource) Test(org.junit.Test)

Example 93 with OLATResourceable

use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.

the class OpenMeetingsCourseNode method createNodeRunConstructionResult.

@Override
public NodeRunConstructionResult createNodeRunConstructionResult(UserRequest ureq, WindowControl wControl, UserCourseEnvironment userCourseEnv, NodeEvaluation ne, String nodecmd) {
    updateModuleConfigDefaults(false);
    Roles roles = ureq.getUserSession().getRoles();
    // check if user is moderator of the virtual classroom
    boolean admin = roles.isOLATAdmin();
    boolean moderator = admin;
    RepositoryEntry re = userCourseEnv.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
    if (!admin) {
        RepositoryManager rm = RepositoryManager.getInstance();
        if (re != null) {
            admin = rm.isOwnerOfRepositoryEntry(ureq.getIdentity(), re) || rm.isInstitutionalRessourceManagerFor(ureq.getIdentity(), roles, re);
            moderator = admin || rm.isIdentityInTutorSecurityGroup(ureq.getIdentity(), re) || isCoach(re, ureq.getIdentity());
        }
    }
    // create run controller
    OLATResourceable ores = OresHelper.clone(userCourseEnv.getCourseEnvironment().getCourseGroupManager().getCourseResource());
    Controller runCtr = new OpenMeetingsRunController(ureq, wControl, null, ores, getIdent(), admin, moderator, userCourseEnv.isCourseReadOnly());
    Controller controller = TitledWrapperHelper.getWrapper(ureq, wControl, runCtr, this, "o_openmeetings_icon");
    return new NodeRunConstructionResult(controller);
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) OpenMeetingsRunController(org.olat.modules.openmeetings.ui.OpenMeetingsRunController) Roles(org.olat.core.id.Roles) RepositoryManager(org.olat.repository.RepositoryManager) RepositoryEntry(org.olat.repository.RepositoryEntry) TabbableController(org.olat.core.gui.control.generic.tabbable.TabbableController) OpenMeetingsEditController(org.olat.course.nodes.openmeetings.OpenMeetingsEditController) OpenMeetingsPeekViewController(org.olat.course.nodes.openmeetings.OpenMeetingsPeekViewController) OpenMeetingsRunController(org.olat.modules.openmeetings.ui.OpenMeetingsRunController) CPEditController(org.olat.course.nodes.cp.CPEditController) Controller(org.olat.core.gui.control.Controller) NodeEditController(org.olat.course.editor.NodeEditController) OpenMeetingsRoomEditController(org.olat.modules.openmeetings.ui.OpenMeetingsRoomEditController) ConditionEditController(org.olat.course.condition.ConditionEditController) NodeRunConstructionResult(org.olat.course.run.navigation.NodeRunConstructionResult)

Example 94 with OLATResourceable

use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.

the class SPRunController method doInlineIntegration.

private void doInlineIntegration(UserRequest ureq, boolean hasEditRightsTo) {
    boolean allowRelativeLinks = config.getBooleanSafe(SPEditController.CONFIG_KEY_ALLOW_RELATIVE_LINKS);
    // create the possibility to float
    OLATResourceable ores = OresHelper.createOLATResourceableInstance(ICourse.class, userCourseEnv.getCourseEnvironment().getCourseResourceableId());
    DeliveryOptions deliveryOptions = (DeliveryOptions) config.get(SPEditController.CONFIG_KEY_DELIVERYOPTIONS);
    spCtr = new SinglePageController(ureq, getWindowControl(), courseFolderContainer, fileName, allowRelativeLinks, null, ores, deliveryOptions, userCourseEnv.getCourseEnvironment().isPreview());
    spCtr.setAllowDownload(true);
    // only for inline integration: register for controller event to forward a olatcmd to the course,
    // and also to remember latest position in the script
    listenTo(spCtr);
    // enable edit mode if user has the according rights
    if (hasEditRightsTo) {
        spCtr.allowPageEditing();
        // set the link tree model to internal for the HTML editor
        if (linkTreeModel != null) {
            spCtr.setInternalLinkTreeModel(linkTreeModel);
        }
    }
    // create clone wrapper layout
    CloneLayoutControllerCreatorCallback clccc = new CloneLayoutControllerCreatorCallback() {

        public ControllerCreator createLayoutControllerCreator(UserRequest uureq, final ControllerCreator contentControllerCreator) {
            return BaseFullWebappPopupLayoutFactory.createAuthMinimalPopupLayout(uureq, new ControllerCreator() {

                public Controller createController(UserRequest lureq, WindowControl lwControl) {
                    // Wrap in column layout, popup window needs a layout controller
                    Controller ctr = contentControllerCreator.createController(lureq, lwControl);
                    LayoutMain3ColsController layoutCtr = new LayoutMain3ColsController(lureq, lwControl, ctr);
                    layoutCtr.setCustomCSS(CourseFactory.getCustomCourseCss(lureq.getUserSession(), userCourseEnv.getCourseEnvironment()));
                    // Controller titledCtrl = TitledWrapperHelper.getWrapper(lureq, lwControl, ctr, courseNode, "o_sp_icon");
                    layoutCtr.addDisposableChildController(ctr);
                    return layoutCtr;
                }
            });
        }
    };
    Controller ctrl = TitledWrapperHelper.getWrapper(ureq, getWindowControl(), spCtr, courseNode, "o_sp_icon");
    if (ctrl instanceof CloneableController) {
        cloneC = new CloneController(ureq, getWindowControl(), (CloneableController) ctrl, clccc);
        listenTo(cloneC);
        main.setContent(cloneC.getInitialComponent());
    } else {
        throw new AssertException("Controller must be cloneable");
    }
}
Also used : AssertException(org.olat.core.logging.AssertException) OLATResourceable(org.olat.core.id.OLATResourceable) CloneableController(org.olat.core.gui.control.generic.clone.CloneableController) SinglePageController(org.olat.core.commons.modules.singlepage.SinglePageController) WindowControl(org.olat.core.gui.control.WindowControl) CloneableController(org.olat.core.gui.control.generic.clone.CloneableController) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) CloneController(org.olat.core.gui.control.generic.clone.CloneController) Controller(org.olat.core.gui.control.Controller) BasicController(org.olat.core.gui.control.controller.BasicController) SinglePageController(org.olat.core.commons.modules.singlepage.SinglePageController) ControllerCreator(org.olat.core.gui.control.creator.ControllerCreator) CloneController(org.olat.core.gui.control.generic.clone.CloneController) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) CloneLayoutControllerCreatorCallback(org.olat.core.gui.control.generic.clone.CloneLayoutControllerCreatorCallback) DeliveryOptions(org.olat.core.gui.control.generic.iframe.DeliveryOptions) UserRequest(org.olat.core.gui.UserRequest)

Example 95 with OLATResourceable

use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.

the class IQRunController method stopAssessment.

private void stopAssessment(UserRequest ureq, Event event) {
    if (displayContainerController != null) {
        displayContainerController.deactivate(ureq);
    } else {
        getWindowControl().pop();
    }
    removeHistory(ureq);
    OLATResourceable ores = OresHelper.createOLATResourceableInstance("test", -1l);
    addToHistory(ureq, ores, null);
    if (type.equals(AssessmentInstance.QMD_ENTRY_TYPE_ASSESS) && !assessmentStopped) {
        assessmentStopped = true;
        AssessmentEvent assessmentStoppedEvent = new AssessmentEvent(AssessmentEvent.TYPE.STOPPED, userSession);
        singleUserEventCenter.deregisterFor(this, assessmentInstanceOres);
        singleUserEventCenter.fireEventToListenersOf(assessmentStoppedEvent, assessmentEventOres);
    }
    fireEvent(ureq, event);
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable)

Aggregations

OLATResourceable (org.olat.core.id.OLATResourceable)924 WindowControl (org.olat.core.gui.control.WindowControl)304 Test (org.junit.Test)158 Identity (org.olat.core.id.Identity)154 RepositoryEntry (org.olat.repository.RepositoryEntry)130 ContextEntry (org.olat.core.id.context.ContextEntry)82 ArrayList (java.util.ArrayList)68 OLATResource (org.olat.resource.OLATResource)60 Controller (org.olat.core.gui.control.Controller)48 Date (java.util.Date)46 AssertException (org.olat.core.logging.AssertException)32 StateSite (org.olat.core.id.context.StateSite)30 SyncerExecutor (org.olat.core.util.coordinate.SyncerExecutor)30 ICourse (org.olat.course.ICourse)30 CourseNode (org.olat.course.nodes.CourseNode)28 DBCheckbox (org.olat.course.nodes.cl.model.DBCheckbox)28 BusinessControl (org.olat.core.id.context.BusinessControl)24 BusinessGroup (org.olat.group.BusinessGroup)24 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)22 BinderSecurityCallback (org.olat.modules.portfolio.BinderSecurityCallback)22