use of org.olat.core.gui.components.Component in project openolat by klemens.
the class GenericMainController method event.
@Override
protected void event(UserRequest ureq, Component source, Event event) {
if (source == olatMenuTree) {
if (event instanceof TreeEvent && event.getCommand().equals(MenuTree.COMMAND_TREENODE_CLICKED)) {
TreeEvent te = (TreeEvent) event;
if (te.getSubCommand() != null) {
// filter open/close events
} else {
// process menu commands
TreeNode selTreeNode = olatMenuTree.getSelectedNode();
// cleanup old content controller (never null)
removeAsListenerAndDispose(contentCtr);
// create new content controller
// Following cases:
// 1a) Simple Action Extension using only ureq and windowControl ->
// handled by default implementation of createController
// 1b) Specialised Action Extension which needs some more internals ->
// handled by the class extending GenericMainController, by overwriting
// createController
// 2) uobject is something special which needs evaluation by class
// extending GenericMainController
Object uobject = selTreeNode.getUserObject();
TreeNode delegatee = selTreeNode.getDelegate();
if (delegatee != null) {
olatMenuTree.setSelectedNode(delegatee);
}
contentCtr = getContentCtr(uobject, ureq);
listenTo(contentCtr);
Component resComp = contentCtr.getInitialComponent();
content.setContent(resComp);
addToHistory(ureq, contentCtr);
}
} else {
// the action was not allowed anymore
// display an empty field (empty panel)
content.setContent(null);
}
} else {
logWarn("Unhandled olatMenuTree event: " + event.getCommand(), null);
}
}
use of org.olat.core.gui.components.Component in project openolat by klemens.
the class CheckListBoxListEditController method doOpenEdit.
private void doOpenEdit(UserRequest ureq, Checkbox checkbox, boolean newCheckbox, String title) {
if (editCtrl != null)
return;
Boolean hasScore = (Boolean) config.get(MSCourseNode.CONFIG_KEY_HAS_SCORE_FIELD);
boolean withScore = (hasScore == null || hasScore.booleanValue());
editCtrl = new CheckboxEditController(ureq, getWindowControl(), courseOres, courseNode, checkbox, newCheckbox, withScore);
listenTo(editCtrl);
Component content = editCtrl.getInitialComponent();
cmc = new CloseableModalController(getWindowControl(), translate("close"), content, true, title);
listenTo(cmc);
cmc.activate();
}
use of org.olat.core.gui.components.Component in project openolat by klemens.
the class CheckListRunController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
boolean readOnly = isReadOnly();
if (formLayout instanceof FormLayoutContainer) {
FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
layoutCont.contextPut("readOnly", Boolean.valueOf(readOnly));
if (dueDate != null) {
layoutCont.contextPut("dueDate", dueDate);
layoutCont.contextPut("in-due-date", isPanelOpen(ureq, "due-date", true));
if (dueDate.compareTo(new Date()) < 0) {
layoutCont.contextPut("afterDueDate", Boolean.TRUE);
}
}
layoutCont.contextPut("withScore", new Boolean(withScore));
if (courseNode.getModuleConfiguration().getBooleanSafe(MSCourseNode.CONFIG_KEY_HAS_SCORE_FIELD, false)) {
HighScoreRunController highScoreCtr = new HighScoreRunController(ureq, getWindowControl(), userCourseEnv, courseNode, this.mainForm);
if (highScoreCtr.isViewHighscore()) {
Component highScoreComponent = highScoreCtr.getInitialComponent();
layoutCont.put("highScore", highScoreComponent);
}
}
List<DBCheck> checks = checkboxManager.loadCheck(getIdentity(), courseOres, courseNode.getIdent());
Map<String, DBCheck> uuidToCheckMap = new HashMap<>();
for (DBCheck check : checks) {
uuidToCheckMap.put(check.getCheckbox().getCheckboxId(), check);
}
List<Checkbox> list = checkboxList.getList();
List<CheckboxWrapper> wrappers = new ArrayList<>(list.size());
for (Checkbox checkbox : list) {
DBCheck check = uuidToCheckMap.get(checkbox.getCheckboxId());
CheckboxWrapper wrapper = forgeCheckboxWrapper(checkbox, check, readOnly, formLayout);
layoutCont.add(wrapper.getCheckboxEl());
wrappers.add(wrapper);
}
layoutCont.contextPut("checkboxList", wrappers);
if (withScore || withPassed) {
layoutCont.contextPut("enableScoreInfo", Boolean.TRUE);
exposeConfigToVC(ureq, layoutCont);
exposeUserDataToVC(ureq, layoutCont);
} else {
layoutCont.contextPut("enableScoreInfo", Boolean.FALSE);
}
}
}
use of org.olat.core.gui.components.Component in project openolat by klemens.
the class CheckListRunForCoachController method event.
@Override
protected void event(UserRequest ureq, Component source, Event event) {
if (source == segmentView) {
if (event instanceof SegmentViewEvent) {
SegmentViewEvent sve = (SegmentViewEvent) event;
String segmentCName = sve.getComponentName();
Component clickedLink = mainVC.getComponent(segmentCName);
if (clickedLink == runLink) {
doOpenRun(ureq);
} else if (clickedLink == coachLink) {
doOpenCoach(ureq);
}
}
}
}
use of org.olat.core.gui.components.Component in project openolat by klemens.
the class ScormRunController method doStartPage.
private void doStartPage(UserRequest ureq) {
// push title and learning objectives, only visible on intro page
startPage.contextPut("menuTitle", scormNode.getShortTitle());
startPage.contextPut("displayTitle", scormNode.getLongTitle());
// Adding learning objectives
String learningObj = scormNode.getLearningObjectives();
if (learningObj != null) {
Component learningObjectives = ObjectivesHelper.createLearningObjectivesComponent(learningObj, getLocale());
startPage.put("learningObjectives", learningObjectives);
startPage.contextPut("hasObjectives", Boolean.TRUE);
} else {
startPage.contextPut("hasObjectives", Boolean.FALSE);
}
if (isAssessable) {
ScoreEvaluation scoreEval = scormNode.getUserScoreEvaluation(userCourseEnv);
Float score = scoreEval.getScore();
if (ScormEditController.CONFIG_ASSESSABLE_TYPE_SCORE.equals(assessableType)) {
startPage.contextPut("score", score != null ? AssessmentHelper.getRoundedScore(score) : "0");
}
startPage.contextPut("hasPassedValue", (scoreEval.getPassed() == null ? Boolean.FALSE : Boolean.TRUE));
startPage.contextPut("passed", scoreEval.getPassed());
boolean resultsVisible = scoreEval.getUserVisible() == null || scoreEval.getUserVisible().booleanValue();
startPage.contextPut("resultsVisible", resultsVisible);
if (resultsVisible && scormNode.hasCommentConfigured()) {
StringBuilder comment = Formatter.stripTabsAndReturns(scormNode.getUserUserComment(userCourseEnv));
startPage.contextPut("comment", StringHelper.xssScan(comment));
}
startPage.contextPut("attempts", scormNode.getUserAttempts(userCourseEnv));
if (ureq == null) {
// High score need one
ureq = new SyntheticUserRequest(getIdentity(), getLocale(), userSession);
}
HighScoreRunController highScoreCtr = new HighScoreRunController(ureq, getWindowControl(), userCourseEnv, scormNode);
if (highScoreCtr.isViewHighscore()) {
Component highScoreComponent = highScoreCtr.getInitialComponent();
startPage.put("highScore", highScoreComponent);
}
}
startPage.contextPut("isassessable", Boolean.valueOf(isAssessable));
main.setContent(startPage);
}
Aggregations