use of org.olat.course.nodes.CourseNodeConfiguration in project OpenOLAT by OpenOLAT.
the class NodeEvaluation method build.
/**
* 1. Calculate if the node should be accessible at all. <br/>
* 2. If the coursenode is visible, build a treenode.
*/
public void build() {
// if at least one access capability is true
for (Iterator<Boolean> iter = accesses.values().iterator(); iter.hasNext(); ) {
Boolean entry = iter.next();
atLeastOneAccessible = atLeastOneAccessible || entry.booleanValue();
}
// if the coursenode is visible, build a treenode
if (isVisible()) {
gtn = new GenericTreeNode(courseNode.getIdent());
gtn.setTitle(courseNode.getShortTitle());
gtn.setAltText(courseNode.getLongTitle());
String type = courseNode.getType();
CourseNodeConfiguration cnConfig = CourseNodeFactory.getInstance().getCourseNodeConfigurationEvenForDisabledBB(type);
if (cnConfig != null) {
String nodeCssClass = null;
if (courseNode.getParent() == null) {
// Spacial case for root node
nodeCssClass = "o_CourseModule_icon";
} else {
nodeCssClass = cnConfig.getIconCSSClass();
}
gtn.setIconCssClass(nodeCssClass);
}
// the current NodeEval is set into the treenode
gtn.setUserObject(this);
// as the userobject
// all treenodes added here are set to be visible/accessible, since the
// invisible are not pushed by convention
gtn.setAccessible(true);
}
// else treenode is null
}
use of org.olat.course.nodes.CourseNodeConfiguration in project openolat by klemens.
the class CoursesForumsTest method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
conn = new RestConnection();
admin = BaseSecurityManager.getInstance().findIdentityByName("administrator");
course1 = CoursesWebService.createEmptyCourse(admin, "Course forum 1", "Course forum 1 long name", null);
DBFactory.getInstance().intermediateCommit();
// create a folder
CourseNodeConfiguration newNodeConfig = CourseNodeFactory.getInstance().getCourseNodeConfiguration("fo");
forumNode = newNodeConfig.getInstance();
forumNode.setShortTitle("Forum");
forumNode.setLearningObjectives("forum objectives");
forumNode.setNoAccessExplanation("You don't have access");
course1.getEditorTreeModel().addCourseNode(forumNode, course1.getRunStructure().getRootNode());
CourseFactory.publishCourse(course1, RepositoryEntry.ACC_USERS, false, admin, Locale.ENGLISH);
DBFactory.getInstance().intermediateCommit();
}
use of org.olat.course.nodes.CourseNodeConfiguration in project openolat by klemens.
the class CourseExtensionHelper method createNode.
/**
* Creates a course node and appends it to the course. (not persisted yet)
*
* @param c course object
* @param shortTitle short title for node
* @param longTitle long title for node
* @return created course node
*/
public static final CourseNode createNode(ICourse course, final String shortTitle, final String longTitle, final String type) {
// create a node with default data
CourseNodeConfiguration nodeConfig = CourseNodeFactory.getInstance().getCourseNodeConfiguration(type);
CourseNode node = nodeConfig.getInstance();
node.setShortTitle(shortTitle);
node.setLongTitle(longTitle);
// append node to course
course = CourseFactory.openCourseEditSession(course.getResourceableId());
final CourseEditorTreeModel cetm = course.getEditorTreeModel();
final CourseNode rootNode = cetm.getCourseNode(course.getRunStructure().getRootNode().getIdent());
course.getEditorTreeModel().addCourseNode(node, rootNode);
CourseFactory.saveCourseEditorTreeModel(course.getResourceableId());
CourseFactory.closeCourseEditSession(course.getResourceableId(), true);
OLog log = Tracing.createLoggerFor(CourseExtensionHelper.class);
if (log.isDebug())
log.debug("Created new course node: " + nodeConfig.getAlias());
return node;
}
use of org.olat.course.nodes.CourseNodeConfiguration in project openolat by klemens.
the class AlternativeCourseNodeController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
setFormDescription("alternative.choose.description");
CourseNodeConfiguration config = CourseNodeFactory.getInstance().getCourseNodeConfigurationEvenForDisabledBB(courseNode.getType());
List<String> alternativeKeyList = new ArrayList<String>(4);
List<String> alternativeValueList = new ArrayList<String>(4);
for (String alt : config.getAlternativeCourseNodes()) {
CourseNodeConfiguration altConfig = CourseNodeFactory.getInstance().getCourseNodeConfigurationEvenForDisabledBB(alt);
if (altConfig.isEnabled()) {
alternativeKeyList.add(alt);
alternativeValueList.add(altConfig.getLinkText(getLocale()));
}
}
String[] alternativeKeys = alternativeKeyList.toArray(new String[alternativeKeyList.size()]);
String[] alternativeValues = alternativeValueList.toArray(new String[alternativeValueList.size()]);
alternativesEl = uifactory.addRadiosVertical("alternative.bbs", formLayout, alternativeKeys, alternativeValues);
if (alternativeKeys.length == 1) {
alternativesEl.select(alternativeKeys[0], true);
}
FormLayoutContainer buttonsLayout = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
formLayout.add(buttonsLayout);
uifactory.addFormSubmitButton("ok", buttonsLayout);
uifactory.addFormCancelButton("cancel", buttonsLayout, ureq, getWindowControl());
}
use of org.olat.course.nodes.CourseNodeConfiguration in project openolat by klemens.
the class ChooseNodeController method doCreateNode.
private void doCreateNode(String type) {
ICourse course = CourseFactory.getCourseEditSession(courseOres.getResourceableId());
// user chose a position to insert a new node
CourseNodeConfiguration newNodeConfig = CourseNodeFactory.getInstance().getCourseNodeConfiguration(type);
createdNode = newNodeConfig.getInstance();
// Set some default values
String title = new String(newNodeConfig.getLinkText(getLocale()));
createdNode.setShortTitle(title);
createdNode.setNoAccessExplanation(translate("form.noAccessExplanation.default"));
// Insert it now
CourseEditorTreeModel editorTreeModel = course.getEditorTreeModel();
if (editorTreeModel.getRootNode().equals(currentNode)) {
// root, add as last child
int pos = currentNode.getChildCount();
CourseNode selectedNode = currentNode.getCourseNode();
editorTreeModel.insertCourseNodeAt(createdNode, selectedNode, pos);
} else {
CourseEditorTreeNode parentNode = (CourseEditorTreeNode) currentNode.getParent();
CourseNode selectedNode = parentNode.getCourseNode();
int pos = currentNode.getPosition();
editorTreeModel.insertCourseNodeAt(createdNode, selectedNode, pos + 1);
}
CourseFactory.saveCourseEditorTreeModel(course.getResourceableId());
}
Aggregations