use of org.olat.course.condition.Condition in project openolat by klemens.
the class AbstractCourseNodeWebService method createCourseNode.
private CourseNodeVO createCourseNode(String type, String shortTitle, String longTitle, String learningObjectives, String visibilityExpertRules, String accessExpertRules, CustomConfigDelegate delegateConfig, CourseEditSession editSession, CourseNode parentNode, Integer position) {
CourseNodeConfiguration newNodeConfig = CourseNodeFactory.getInstance().getCourseNodeConfiguration(type);
CourseNode insertedNode = newNodeConfig.getInstance();
insertedNode.setShortTitle(shortTitle);
insertedNode.setLongTitle(longTitle);
insertedNode.setLearningObjectives(learningObjectives);
insertedNode.setNoAccessExplanation("You don't have access");
if (StringHelper.containsNonWhitespace(visibilityExpertRules)) {
Condition cond = this.createExpertCondition(CONDITION_ID_VISIBILITY, visibilityExpertRules);
insertedNode.setPreConditionVisibility(cond);
}
if (StringHelper.containsNonWhitespace(accessExpertRules) && insertedNode instanceof AbstractAccessableCourseNode) {
Condition cond = createExpertCondition(CONDITION_ID_ACCESS, accessExpertRules);
((AbstractAccessableCourseNode) insertedNode).setPreConditionAccess(cond);
}
ICourse course = editSession.getCourse();
if (delegateConfig != null) {
ModuleConfiguration moduleConfig = insertedNode.getModuleConfiguration();
delegateConfig.configure(course, insertedNode, moduleConfig);
}
if (position == null || position.intValue() < 0) {
course.getEditorTreeModel().addCourseNode(insertedNode, parentNode);
} else {
course.getEditorTreeModel().insertCourseNodeAt(insertedNode, parentNode, position);
}
CourseEditorTreeNode editorNode = course.getEditorTreeModel().getCourseEditorNodeContaining(insertedNode);
CourseNodeVO vo = get(insertedNode);
vo.setParentId(editorNode.getParent() == null ? null : editorNode.getParent().getIdent());
return vo;
}
use of org.olat.course.condition.Condition in project openolat by klemens.
the class FeedNodeEditController method event.
@Override
public void event(UserRequest urequest, Controller source, Event event) {
if (source == moderatroCtr) {
if (event == Event.CHANGED_EVENT) {
Condition cond = moderatroCtr.getCondition();
node.setPreConditionModerator(cond);
fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
}
} else if (source == posterCtr) {
if (event == Event.CHANGED_EVENT) {
Condition cond = posterCtr.getCondition();
node.setPreConditionPoster(cond);
fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
}
} else if (source == readerCtr) {
if (event == Event.CHANGED_EVENT) {
Condition cond = readerCtr.getCondition();
node.setPreConditionReader(cond);
fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
}
} else if (source == searchController) {
cmc.deactivate();
// repository search controller done
if (event == ReferencableEntriesSearchController.EVENT_REPOSITORY_ENTRY_SELECTED) {
RepositoryEntry re = searchController.getSelectedEntry();
if (re != null) {
config.set(AbstractFeedCourseNode.CONFIG_KEY_REPOSITORY_SOFTKEY, re.getSoftkey());
contentVC.contextPut("showPreviewLink", Boolean.TRUE);
String displayname = StringHelper.escapeHtml(re.getDisplayname());
previewLink = LinkFactory.createCustomLink("command.preview", "command.preview", displayname, Link.NONTRANSLATED, contentVC, this);
previewLink.setIconLeftCSS("o_icon o_icon-fw o_icon_preview");
previewLink.setCustomEnabledLinkCSS("o_preview");
previewLink.setTitle(getTranslator().translate("command.preview"));
// no securitycheck on feeds, editable by everybody
editLink = LinkFactory.createButtonSmall("edit", contentVC, this);
// fire event so the updated config is saved by the
// editormaincontroller
fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
}
}
// else cancelled repo search
} else if (source == cmcFeedCtr) {
if (event == CloseableModalController.CLOSE_MODAL_EVENT) {
cmcFeedCtr.dispose();
feedController.dispose();
}
}
}
use of org.olat.course.condition.Condition in project openolat by klemens.
the class GoToMeetingEditController method event.
@Override
protected void event(UserRequest ureq, Controller source, Event event) {
if (source == accessibilityCondContr) {
if (event == Event.CHANGED_EVENT) {
Condition cond = accessibilityCondContr.getCondition();
courseNode.setPreConditionAccess(cond);
fireEvent(ureq, NodeEditController.NODECONFIG_CHANGED_EVENT);
}
}
}
use of org.olat.course.condition.Condition in project openolat by klemens.
the class InfoCourseNode method getConditionExpressions.
@Override
public List<ConditionExpression> getConditionExpressions() {
List<ConditionExpression> parentConditions = super.getConditionExpressions();
List<ConditionExpression> conditions = new ArrayList<>();
if (parentConditions != null && parentConditions.size() > 0) {
conditions.addAll(parentConditions);
}
Condition editCondition = getPreConditionEdit();
if (editCondition != null && StringHelper.containsNonWhitespace(editCondition.getConditionExpression())) {
ConditionExpression ce = new ConditionExpression(editCondition.getConditionId());
ce.setExpressionString(editCondition.getConditionExpression());
conditions.add(ce);
}
Condition adminCondition = getPreConditionAdmin();
if (adminCondition != null && StringHelper.containsNonWhitespace(adminCondition.getConditionExpression())) {
ConditionExpression ce = new ConditionExpression(adminCondition.getConditionId());
ce.setExpressionString(adminCondition.getConditionExpression());
conditions.add(ce);
}
return conditions;
}
use of org.olat.course.condition.Condition in project openolat by klemens.
the class InfoCourseNode method getPreConditionAdmin.
/**
* Default set the write privileges to coaches and admin only
* @return
*/
public Condition getPreConditionAdmin() {
if (preConditionAdmin == null) {
preConditionAdmin = new Condition();
preConditionAdmin.setEasyModeCoachesAndAdmins(true);
preConditionAdmin.setConditionExpression(preConditionAdmin.getConditionFromEasyModeConfiguration());
preConditionAdmin.setExpertMode(false);
}
preConditionAdmin.setConditionId(ADMIN_CONDITION_ID);
return preConditionAdmin;
}
Aggregations