use of org.olat.course.nodes.CourseNode in project OpenOLAT by OpenOLAT.
the class RunMainController method event.
/**
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
* org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
*/
@Override
public void event(UserRequest ureq, Controller source, Event event) {
if (needsRebuildAfter) {
currentCourseNode = updateAfterChanges(currentCourseNode);
needsRebuildAfter = false;
}
if (source == currentNodeController) {
if (event instanceof OlatCmdEvent) {
OlatCmdEvent oe = (OlatCmdEvent) event;
String cmd = oe.getCommand();
if (OlatCmdEvent.GOTONODE_CMD.equals(cmd)) {
// "69680861018558/node-specific-data";
String subcmd = oe.getSubcommand();
CourseNode identNode;
String nodecmd = null;
int slPos = subcmd.indexOf('/');
if (slPos != -1) {
nodecmd = subcmd.substring(slPos + 1);
identNode = course.getRunStructure().getNode(subcmd.substring(0, slPos));
} else {
identNode = course.getRunStructure().getNode(subcmd);
}
if (identNode == null) {
showWarning("msg.nodenotavailableanymore");
} else {
addLoggingResourceable(LoggingResourceable.wrap(identNode));
currentCourseNode = identNode;
updateTreeAndContent(ureq, identNode, nodecmd);
oe.accept();
}
}
} else if (event == Event.DONE_EVENT) {
// preconditions may have changed
if (needsRebuildAfterRunDone) {
needsRebuildAfterRunDone = false;
updateTreeAndContent(ureq, currentCourseNode, null);
}
} else if (REBUILD.equals(event.getCommand())) {
needsRebuildAfterRunDone = false;
updateTreeAndContent(ureq, currentCourseNode, null);
} else if (event instanceof TreeNodeEvent) {
TreeNodeEvent tne = (TreeNodeEvent) event;
TreeNode newCpTreeNode = tne.getChosenTreeNode();
luTree.setSelectedNodeId(newCpTreeNode.getIdent());
} else if (event == Event.CHANGED_EVENT) {
updateTreeAndContent(ureq, currentCourseNode, null);
} else if (event instanceof BusinessGroupModifiedEvent) {
fireEvent(ureq, event);
updateTreeAndContent(ureq, currentCourseNode, null);
}
}
}
use of org.olat.course.nodes.CourseNode in project OpenOLAT by OpenOLAT.
the class RunMainController method event.
/**
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
* org.olat.core.gui.components.Component,
* org.olat.core.gui.control.Event)
*/
@Override
public void event(UserRequest ureq, Component source, Event event) {
if (needsRebuildAfter) {
currentCourseNode = updateAfterChanges(currentCourseNode);
needsRebuildAfter = false;
}
// Links in editTools dropdown
if (nextLink == source) {
doNext(ureq);
} else if (previousLink == source) {
doPrevious(ureq);
} else if (source == luTree) {
if (event.getCommand().equals(MenuTree.COMMAND_TREENODE_CLICKED) || event.getCommand().equals(MenuTree.COMMAND_TREENODE_EXPANDED)) {
TreeEvent tev = (TreeEvent) event;
doNodeClick(ureq, tev);
}
} else if (source == coursemain) {
if ("activateCourseNode".equals(event.getCommand())) {
// Events from the JS function o_activateCourseNode() - activate the given node id
String nodeid = ureq.getParameter("nodeid");
if (nodeid != null) {
CourseNode identNode = course.getRunStructure().getNode(nodeid);
CourseNode node = updateTreeAndContent(ureq, identNode, null);
if (node != null) {
currentCourseNode = node;
} else {
getWindowControl().setWarning(translate("msg.nodenotavailableanymore"));
}
}
}
}
}
use of org.olat.course.nodes.CourseNode 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.course.nodes.CourseNode in project OpenOLAT by OpenOLAT.
the class PreviewRunController method event.
/**
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
* org.olat.core.gui.components.Component, org.olat.core.gui.control.Event)
*/
@Override
public void event(UserRequest ureq, Component source, Event event) {
if (source == luTree) {
if (event.getCommand().equals(MenuTree.COMMAND_TREENODE_CLICKED)) {
TreeEvent tev = (TreeEvent) event;
// goto node:
// after a click in the tree, evaluate the model anew, set the tree
// model anew, and set the selection of the tree again
NodeClickedRef nclr = navHandler.evaluateJumpToTreeNode(ureq, getWindowControl(), treeModel, tev, this, null, currentNodeController);
if (!nclr.isVisible()) {
getWindowControl().setWarning(translate("warn.notvisible"));
return;
}
if (nclr.isHandledBySubTreeModelListener()) {
// not used:
return;
}
// set the new treemodel
treeModel = nclr.getTreeModel();
luTree.setTreeModel(treeModel);
// set the new tree selection
luTree.setSelectedNodeId(nclr.getSelectedNodeId());
luTree.setOpenNodeIds(nclr.getOpenNodeIds());
// get the controller (in this case it is a preview controller). Dispose only if not already disposed in navHandler.evaluateJumpToTreeNode()
if (nclr.getRunController() != null) {
if (currentNodeController != null && !currentNodeController.isDisposed() && !navHandler.isListening(currentNodeController)) {
currentNodeController.dispose();
}
currentNodeController = nclr.getRunController();
}
CourseNode cn = nclr.getCalledCourseNode();
if (cn != null) {
Condition c = cn.getPreConditionVisibility();
String visibilityExpr = (c.getConditionExpression() == null ? translate("details.visibility.none") : c.getConditionExpression());
detail.contextPut("visibilityExpr", visibilityExpr);
detail.contextPut("coursenode", cn);
currentCourseNode = cn;
}
Component nodeComp = currentNodeController.getInitialComponent();
content.setContent(nodeComp);
}
} else if (source == configButton) {
fireEvent(ureq, new Event("command.config"));
}
}
use of org.olat.course.nodes.CourseNode in project OpenOLAT by OpenOLAT.
the class AttemptsRuleEditor method searchAttemptableNodes.
private void searchAttemptableNodes(CourseNode courseNode, List<CourseNode> nodes) {
if (courseNode instanceof AssessableCourseNode) {
AssessableCourseNode assessableCourseNode = (AssessableCourseNode) courseNode;
if (assessableCourseNode.hasAttemptsConfigured()) {
nodes.add(courseNode);
}
} else if (courseNode instanceof QTICourseNode) {
QTICourseNode assessableCourseNode = (QTICourseNode) courseNode;
if (assessableCourseNode.hasAttemptsConfigured()) {
nodes.add(courseNode);
}
}
for (int i = 0; i < courseNode.getChildCount(); i++) {
CourseNode child = (CourseNode) courseNode.getChildAt(i);
searchAttemptableNodes(child, nodes);
}
}
Aggregations