use of org.olat.core.gui.control.Controller in project OpenOLAT by OpenOLAT.
the class CourseSite method createController.
@Override
protected MainLayoutController createController(UserRequest ureq, WindowControl wControl, SiteConfiguration config) {
RepositoryManager rm = RepositoryManager.getInstance();
RepositoryService rs = CoreSpringFactory.getImpl(RepositoryService.class);
RepositoryEntry entry = rm.lookupRepositoryEntryBySoftkey(repositorySoftKey, false);
if (entry == null) {
return getAlternativeController(ureq, wControl, config);
}
MainLayoutController c;
ICourse course = CourseFactory.loadCourse(entry);
UserSession usess = ureq.getUserSession();
// course-launch-state depending course-settings
RepositoryEntrySecurity reSecurity = rm.isAllowed(ureq, entry);
boolean isAllowedToLaunch = reSecurity.canLaunch();
boolean hasAccess = false;
if (isAllowedToLaunch) {
// either check with securityCallback or use access-settings from course-nodes
if (siteSecCallback != null) {
hasAccess = siteSecCallback.isAllowedToLaunchSite(ureq);
} else if (usess.isInAssessmentModeProcess() && !usess.matchLockResource(course)) {
hasAccess = false;
} else {
// check within course: accessibility of course root node
CourseNode rootNode = course.getRunStructure().getRootNode();
UserCourseEnvironmentImpl uce = new UserCourseEnvironmentImpl(ureq.getUserSession().getIdentityEnvironment(), course.getCourseEnvironment());
NodeEvaluation nodeEval = rootNode.eval(uce.getConditionInterpreter(), new TreeEvaluation(), new VisibleTreeFilter());
boolean mayAccessWholeTreeUp = NavigationHandler.mayAccessWholeTreeUp(nodeEval);
hasAccess = mayAccessWholeTreeUp && nodeEval.isVisible();
}
}
// load course (admins always see content) or alternative controller if course is not launchable
if (hasAccess || usess.getRoles().isOLATAdmin()) {
rs.incrementLaunchCounter(entry);
// build up the context path for linked course
WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ureq, entry, new StateSite(this), wControl, true);
CourseRuntimeController runCtr = new CourseRuntimeController(ureq, bwControl, entry, reSecurity, new RuntimeControllerCreator() {
@Override
public Controller create(UserRequest uureq, WindowControl wwControl, TooledStackedPanel toolbarPanel, RepositoryEntry re, RepositoryEntrySecurity security, AssessmentMode assessmentMode) {
return new RunMainController(uureq, wwControl, toolbarPanel, CourseFactory.loadCourse(re), re, security, assessmentMode);
}
}, false, true);
// Configure run controller
// a: don't show close link, is opened as site not tab
runCtr.setCourseCloseEnabled(false);
// b: don't show toolbar
if (!showToolController) {
runCtr.setToolControllerEnabled(false);
}
c = runCtr;
} else {
// access restricted (not in group / author) -> show controller
// defined in olat_extensions (type autoCreator)
c = getAlternativeController(ureq, wControl, config);
}
return c;
}
use of org.olat.core.gui.control.Controller in project OpenOLAT by OpenOLAT.
the class CourseSiteContextEntryControllerCreator method messageController.
private Controller messageController(UserRequest ureq, WindowControl wControl, String i18nMesageKey) {
Translator trans = Util.createPackageTranslator(RepositoryService.class, ureq.getLocale());
String text = trans.translate(i18nMesageKey);
Controller c = MessageUIFactory.createInfoMessage(ureq, wControl, null, text);
// use on column layout
LayoutMain3ColsController layoutCtr = new LayoutMain3ColsController(ureq, wControl, c);
// dispose content on layout dispose
layoutCtr.addDisposableChildController(c);
return layoutCtr;
}
use of org.olat.core.gui.control.Controller in project OpenOLAT by OpenOLAT.
the class StatisticAutoCreator method createController.
public Controller createController(UserRequest lureq, WindowControl lwControl, ICourse course) {
Exception re = null;
try {
Class<?> cclazz = Thread.currentThread().getContextClassLoader().loadClass(className);
Constructor<?> con = cclazz.getConstructor(ARGCLASSES);
Object o = con.newInstance(new Object[] { lureq, lwControl, course, statisticManager_ });
Controller c = (Controller) o;
return c;
} catch (ClassNotFoundException e) {
re = e;
} catch (SecurityException e) {
re = e;
} catch (NoSuchMethodException e) {
re = e;
} catch (IllegalArgumentException e) {
re = e;
} catch (InstantiationException e) {
re = e;
} catch (IllegalAccessException e) {
re = e;
} catch (InvocationTargetException e) {
re = e;
} finally {
if (re != null) {
throw new AssertException("could not create controller via reflection. classname:" + className, re);
}
}
return null;
}
use of org.olat.core.gui.control.Controller in project OpenOLAT by OpenOLAT.
the class MultiEvaluationFormController method initOnePageView.
private void initOnePageView(UserRequest ureq, List<Identity> otherEvaluators, boolean anonym) {
mainVC = createVelocityContainer("multi_evaluation_one_page");
List<EvaluatorPanel> panels = new ArrayList<>();
mainVC.contextPut("panels", panels);
boolean viewOthers = isViewOthers();
if (owner != null) {
String ownerFullname = userManager.getUserDisplayName(owner);
Evaluator evaluator = new Evaluator(owner, ownerFullname);
evaluators.add(evaluator);
boolean me = owner.equals(getIdentity());
if (me || viewOthers) {
Controller ctrl = createEvalutationForm(ureq, owner);
String componentName = "panel_" + (++count);
panels.add(new EvaluatorPanel(evaluator, componentName, ctrl.getInitialComponent()));
mainVC.put(componentName, ctrl.getInitialComponent());
}
}
if (otherEvaluators != null && otherEvaluators.size() > 0) {
int countEva = 1;
for (Identity evaluator : otherEvaluators) {
boolean me = evaluator.equals(ureq.getIdentity());
String evaluatorFullname;
if (!me && anonym) {
evaluatorFullname = translate("anonym.evaluator", new String[] { Integer.toString(countEva++) });
} else {
evaluatorFullname = userManager.getUserDisplayName(evaluator);
}
Evaluator eval = new Evaluator(evaluator, evaluatorFullname);
evaluators.add(eval);
if (me || viewOthers) {
Controller ctrl = createEvalutationForm(ureq, evaluator);
String componentName = "panel_" + (++count);
panels.add(new EvaluatorPanel(eval, componentName, ctrl.getInitialComponent()));
mainVC.put(componentName, ctrl.getInitialComponent());
}
}
}
if (viewOthers && (owner != null && otherEvaluators != null && otherEvaluators.size() > 0) || (otherEvaluators != null && otherEvaluators.size() > 1)) {
removeAsListenerAndDispose(compareEvaluationCtrl);
CompareEvaluationsFormController ctrl = new CompareEvaluationsFormController(ureq, getWindowControl(), evaluators, anchor, formEntry);
listenTo(ctrl);
Evaluator eval = new Evaluator(null, translate("compare.evaluations"));
String componentName = "panel_" + (++count);
panels.add(new EvaluatorPanel(eval, componentName, ctrl.getInitialComponent()));
mainVC.put(componentName, ctrl.getInitialComponent());
}
}
use of org.olat.core.gui.control.Controller in project OpenOLAT by OpenOLAT.
the class MembersManagementMainController method activate.
@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
if (entries == null || entries.isEmpty())
return;
ContextEntry currentEntry = entries.get(0);
String cmd = currentEntry.getOLATResourceable().getResourceableTypeName();
Controller selectedCtrl = selectMenuItem(ureq, cmd);
if (selectedCtrl instanceof Activateable2) {
List<ContextEntry> subEntries = entries.subList(1, entries.size());
((Activateable2) selectedCtrl).activate(ureq, subEntries, currentEntry.getTransientState());
}
}
Aggregations