Search in sources :

Example 1 with ViteroBookingsRunController

use of org.olat.modules.vitero.ui.ViteroBookingsRunController in project OpenOLAT by OpenOLAT.

the class ViteroCourseNode method createNodeRunConstructionResult.

@Override
public NodeRunConstructionResult createNodeRunConstructionResult(UserRequest ureq, WindowControl wControl, UserCourseEnvironment userCourseEnv, NodeEvaluation ne, String nodecmd) {
    updateModuleConfigDefaults(false);
    Controller runCtr;
    Roles roles = ureq.getUserSession().getRoles();
    if (roles.isGuestOnly()) {
        Translator trans = Util.createPackageTranslator(ViteroPeekViewController.class, ureq.getLocale());
        String title = trans.translate("guestnoaccess.title");
        String message = trans.translate("guestnoaccess.message");
        runCtr = MessageUIFactory.createInfoMessage(ureq, wControl, title, message);
    } else {
        // check if user is moderator of the virtual classroom
        boolean moderator = roles.isOLATAdmin();
        Long key = userCourseEnv.getCourseEnvironment().getCourseResourceableId();
        if (!moderator) {
            if (roles.isInstitutionalResourceManager() | roles.isAuthor()) {
                RepositoryManager rm = RepositoryManager.getInstance();
                ICourse course = CourseFactory.loadCourse(key);
                RepositoryEntry re = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
                if (re != null) {
                    moderator = rm.isOwnerOfRepositoryEntry(ureq.getIdentity(), re);
                    if (!moderator) {
                        moderator = rm.isInstitutionalRessourceManagerFor(ureq.getIdentity(), ureq.getUserSession().getRoles(), re);
                    }
                }
            }
        }
        // create run controller
        Long resourceId = userCourseEnv.getCourseEnvironment().getCourseResourceableId();
        OLATResourceable ores = OresHelper.createOLATResourceableInstance(CourseModule.class, resourceId);
        String courseTitle = userCourseEnv.getCourseEnvironment().getCourseTitle();
        runCtr = new ViteroBookingsRunController(ureq, wControl, null, ores, getIdent(), courseTitle, moderator, userCourseEnv.isCourseReadOnly());
    }
    Controller controller = TitledWrapperHelper.getWrapper(ureq, wControl, runCtr, this, "o_vitero_icon");
    return new NodeRunConstructionResult(controller);
}
Also used : Translator(org.olat.core.gui.translator.Translator) OLATResourceable(org.olat.core.id.OLATResourceable) Roles(org.olat.core.id.Roles) RepositoryManager(org.olat.repository.RepositoryManager) ICourse(org.olat.course.ICourse) ViteroBookingsRunController(org.olat.modules.vitero.ui.ViteroBookingsRunController) RepositoryEntry(org.olat.repository.RepositoryEntry) TabbableController(org.olat.core.gui.control.generic.tabbable.TabbableController) ViteroBookingsRunController(org.olat.modules.vitero.ui.ViteroBookingsRunController) Controller(org.olat.core.gui.control.Controller) NodeEditController(org.olat.course.editor.NodeEditController) ViteroEditController(org.olat.course.nodes.vitero.ViteroEditController) ViteroPeekViewController(org.olat.course.nodes.vitero.ViteroPeekViewController) ConditionEditController(org.olat.course.condition.ConditionEditController) NodeRunConstructionResult(org.olat.course.run.navigation.NodeRunConstructionResult)

Example 2 with ViteroBookingsRunController

use of org.olat.modules.vitero.ui.ViteroBookingsRunController in project openolat by klemens.

the class ViteroCourseNode method createNodeRunConstructionResult.

@Override
public NodeRunConstructionResult createNodeRunConstructionResult(UserRequest ureq, WindowControl wControl, UserCourseEnvironment userCourseEnv, NodeEvaluation ne, String nodecmd) {
    updateModuleConfigDefaults(false);
    Controller runCtr;
    Roles roles = ureq.getUserSession().getRoles();
    if (roles.isGuestOnly()) {
        Translator trans = Util.createPackageTranslator(ViteroPeekViewController.class, ureq.getLocale());
        String title = trans.translate("guestnoaccess.title");
        String message = trans.translate("guestnoaccess.message");
        runCtr = MessageUIFactory.createInfoMessage(ureq, wControl, title, message);
    } else {
        // check if user is moderator of the virtual classroom
        boolean moderator = roles.isOLATAdmin();
        Long key = userCourseEnv.getCourseEnvironment().getCourseResourceableId();
        if (!moderator) {
            if (roles.isInstitutionalResourceManager() | roles.isAuthor()) {
                RepositoryManager rm = RepositoryManager.getInstance();
                ICourse course = CourseFactory.loadCourse(key);
                RepositoryEntry re = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
                if (re != null) {
                    moderator = rm.isOwnerOfRepositoryEntry(ureq.getIdentity(), re);
                    if (!moderator) {
                        moderator = rm.isInstitutionalRessourceManagerFor(ureq.getIdentity(), ureq.getUserSession().getRoles(), re);
                    }
                }
            }
        }
        // create run controller
        Long resourceId = userCourseEnv.getCourseEnvironment().getCourseResourceableId();
        OLATResourceable ores = OresHelper.createOLATResourceableInstance(CourseModule.class, resourceId);
        String courseTitle = userCourseEnv.getCourseEnvironment().getCourseTitle();
        runCtr = new ViteroBookingsRunController(ureq, wControl, null, ores, getIdent(), courseTitle, moderator, userCourseEnv.isCourseReadOnly());
    }
    Controller controller = TitledWrapperHelper.getWrapper(ureq, wControl, runCtr, this, "o_vitero_icon");
    return new NodeRunConstructionResult(controller);
}
Also used : Translator(org.olat.core.gui.translator.Translator) OLATResourceable(org.olat.core.id.OLATResourceable) Roles(org.olat.core.id.Roles) RepositoryManager(org.olat.repository.RepositoryManager) ICourse(org.olat.course.ICourse) ViteroBookingsRunController(org.olat.modules.vitero.ui.ViteroBookingsRunController) RepositoryEntry(org.olat.repository.RepositoryEntry) TabbableController(org.olat.core.gui.control.generic.tabbable.TabbableController) ViteroBookingsRunController(org.olat.modules.vitero.ui.ViteroBookingsRunController) Controller(org.olat.core.gui.control.Controller) NodeEditController(org.olat.course.editor.NodeEditController) ViteroEditController(org.olat.course.nodes.vitero.ViteroEditController) ViteroPeekViewController(org.olat.course.nodes.vitero.ViteroPeekViewController) ConditionEditController(org.olat.course.condition.ConditionEditController) NodeRunConstructionResult(org.olat.course.run.navigation.NodeRunConstructionResult)

Aggregations

Controller (org.olat.core.gui.control.Controller)2 TabbableController (org.olat.core.gui.control.generic.tabbable.TabbableController)2 Translator (org.olat.core.gui.translator.Translator)2 OLATResourceable (org.olat.core.id.OLATResourceable)2 Roles (org.olat.core.id.Roles)2 ICourse (org.olat.course.ICourse)2 ConditionEditController (org.olat.course.condition.ConditionEditController)2 NodeEditController (org.olat.course.editor.NodeEditController)2 ViteroEditController (org.olat.course.nodes.vitero.ViteroEditController)2 ViteroPeekViewController (org.olat.course.nodes.vitero.ViteroPeekViewController)2 NodeRunConstructionResult (org.olat.course.run.navigation.NodeRunConstructionResult)2 ViteroBookingsRunController (org.olat.modules.vitero.ui.ViteroBookingsRunController)2 RepositoryEntry (org.olat.repository.RepositoryEntry)2 RepositoryManager (org.olat.repository.RepositoryManager)2