// log shows who entered which course, this can then be further used to jump
// to the courselog
Tracing.logAudit("Entering course: [[["+courseTitle+"]]]", course.getResourceableId().toString(), RunMainController.class);
// set up the components
all = new Panel("allofcourse");
luTree = new MenuTree("luTreeRun", this);
contentP = new Panel("building_block_content");
// get all group memberships for this course
initGroupMemberships(identity);
// Initialize the the users roles and right for this course
// 1) is guest flag
isGuest = ureq.getUserSession().getRoles().isGuestOnly();
// 2) all course internal rights
initUserRolesAndRights(identity);
// preload user assessment data in assessmnt properties cache to speed up
// course loading
course.getCourseEnvironment().getAssessmentManager().preloadCache(identity);
// build up the running structure for this user;
uce = new UserCourseEnvironmentImpl(ureq.getUserSession().getIdentityEnvironment(), course.getCourseEnvironment());
// build score now
uce.getScoreAccounting().evaluateAll();
navHandler = new NavigationHandler(uce, false);
// jump to either the forum or the folder if the business-launch-path says
// so.
boolean showAssessmentTool = false;
BusinessControl bc = getWindowControl().getBusinessControl();
ContextEntry ce = bc.popLauncherContextEntry();
if (ce != null) {
logDebug("businesscontrol (for further jumps) would be:" + bc, null);
OLATResourceable ores = ce.getOLATResourceable();
logDebug("OLATResourceable=" + ores, null);
if (OresHelper.isOfType(ores, CourseNode.class)) {
// TODO, don't use CourseNode.class, but a lookup using the ClassToId
// class
// jump to the coursenode with id
Long nodeId = ores.getResourceableId();
String nodeIdS = nodeId.toString();
currentCourseNode = course.getRunStructure().getNode(nodeIdS);
if (currentCourseNode == null) {
// (e.g. a coursenode that no longer is accessible or existing)
// -> fallback to root node (automatically done later), and drop wrong
// remaining contexts
logDebug("currentCourseNode=null => dropLauncherEntries for nodeIdS=" + nodeIdS, null);
bc.dropLauncherEntries();
}
} else if ("assessmentTool".equals(ores.getResourceableTypeName())) {
showAssessmentTool = true;
}
}
/*
* ContextEntry curCe = bc.getCurrentEntryAndAdvance(); if (curCe != null) { //
* e.g something like FOCourseNode:3243 or AssementTool:0 or AssmentTool:1
* (0,1 must be dokumented) OLATResourceable ores =
* curCe.getOLATResourceable(); if (OresHelper.isOfType(ores,
* CourseNode.class)) { // TODO, don't use CourseNode.class, but a lookup
* using the ClassToId class // jump to the coursenode with id Long nodeId =
* ores.getResourceableId(); String nodeIdS = nodeId.toString();
* currentCourseNode = course.getRunStructure().getNode(nodeIdS); } else {
* //TODO assessment tool } }
*/
String subsubId = null;
String assessmentViewIdentifier = null;
// activate assessent tool or node as the first screen
if (initialViewIdentifier != null) {
if (initialViewIdentifier.equals("assessmentTool")) {
showAssessmentTool = true;
// assessmentViewIdentifier must be null
} else if (initialViewIdentifier.equals("assessmentTool:nodeChoose")) {
showAssessmentTool = true;
assessmentViewIdentifier = "node-choose";
} else {
// check for subsubIdent
if (initialViewIdentifier.indexOf(":") != -1) {
String[] viewIdentifier = initialViewIdentifier.split(":");
currentCourseNode = course.getRunStructure().getNode(viewIdentifier[0]);
subsubId = viewIdentifier[1];
} else {
currentCourseNode = course.getRunStructure().getNode(initialViewIdentifier);
}
}
}
updateTreeAndContent(ureq, currentCourseNode, subsubId);
if (courseRepositoryEntry != null && RepositoryManager.getInstance().createRepositoryEntryStatus(courseRepositoryEntry.getStatusCode()).isClosed()) {
wControl.setWarning(translate("course.closed"));
}
// instant messaging: send presence like "reading course: Biology I" as
// awareness info. Important: do this before initializing the toolbox
// controller!
if (InstantMessagingModule.isEnabled() && CourseModule.isCourseChatEnabled() && !isGuest) {
String intro = translate("course.presence.message.enter") + " " + getExtendedCourseTitle(ureq.getLocale());
InstantMessagingModule.getAdapter().sendStatus(identity.getName(), intro);
if (course.getCourseEnvironment().getCourseConfig().isChatEnabled()) {
// create groupchat room link only if course chat is enabled
createCourseGroupChatLink(ureq);
}
}
// add text marker wrapper controller to implement course glossary
// textMarkerCtr must be created before the toolC!
CourseConfig cc = uce.getCourseEnvironment().getCourseConfig();
glossaryMarkerCtr = CourseGlossaryFactory.createGlossaryMarkupWrapper(ureq, wControl, contentP, cc);
boolean hasGlossaryRights = hasCourseRight(CourseRights.RIGHT_GLOSSARY) || isCourseAdmin;
glossaryToolCtr = new CourseGlossaryToolLinkController(getWindowControl(), ureq, course, getTranslator(), hasGlossaryRights,
uce.getCourseEnvironment(), glossaryMarkerCtr);
listenTo(glossaryToolCtr);
// init the menu and tool controller
toolC = initToolController(identity, ureq);
Component toolComp = (toolC == null ? null : toolC.getInitialComponent());
if (glossaryMarkerCtr != null) {
listenTo(glossaryMarkerCtr);
// enable / disable glossary highlighting according to user prefs
Preferences prefs = ureq.getUserSession().getGuiPreferences();
Boolean state = (Boolean) prefs.get(CourseGlossaryToolLinkController.class, CourseGlossaryFactory.createGuiPrefsKey(course));
//Glossary always on for guests. OLAT-4241
if(ureq.getUserSession().getRoles().isGuestOnly()){
state = Boolean.TRUE;
}
if (state == null) {
glossaryMarkerCtr.setTextMarkingEnabled(false);
} else {
glossaryMarkerCtr.setTextMarkingEnabled(state.booleanValue());
}
columnLayoutCtr = new LayoutMain3ColsController(ureq, getWindowControl(), luTree, toolComp, glossaryMarkerCtr.getInitialComponent(), "course" + this.course.getResourceableId());
} else {
columnLayoutCtr = new LayoutMain3ColsController(ureq, getWindowControl(), luTree, toolComp, contentP, "courseRun" + this.course.getResourceableId());
}
listenTo(columnLayoutCtr);
// activate the custom course css if any
setCustomCSS(CourseFactory.getCustomCourseCss(ureq.getUserSession(), uce.getCourseEnvironment()));
// decide what is show fist - a tool since activaded this way or the regular
// course view
if (showAssessmentTool) {
launchAssessmentTool(ureq, assessmentViewIdentifier);
coursemain = createVelocityContainer("index");
coursemain.put("coursemain", all);
} else {
all.setContent(columnLayoutCtr.getInitialComponent());
coursemain = createVelocityContainer("index");
// see function gotonode in functions.js to see why we need the
// repositoryentry-key here:
// it is to correctly apply external links using course-internal links via
// javascript
coursemain.contextPut("courserepokey", courseRepositoryEntry.getKey());
coursemain.put("coursemain", all);
}
putInitialPanel(coursemain);
//disposed message controller
//must be created beforehand
Panel empty = new Panel("empty");//empty panel set as "menu" and "tool"
Controller courseCloser = CourseFactory.createDisposedCourseRestartController(ureq, wControl, courseRepositoryEntry.getResourceableId());
Controller disposedRestartController = new LayoutMain3ColsController(ureq, wControl, empty, empty, courseCloser.getInitialComponent(), "disposed course" + this.course.getResourceableId());
setDisposedMsgController(disposedRestartController);
// add as listener to course so we are being notified about course events: