use of org.olat.course.nodes.CourseNodeConfiguration in project OpenOLAT by OpenOLAT.
the class AssessmentHelper method addAssessableNodesToList.
private static List<GenericTreeNode> addAssessableNodesToList(CourseNode parentCourseNode) {
List<GenericTreeNode> result = new ArrayList<>();
for (int i = 0; i < parentCourseNode.getChildCount(); i++) {
CourseNode courseNode = (CourseNode) parentCourseNode.getChildAt(i);
List<GenericTreeNode> assessableChildren = addAssessableNodesToList(courseNode);
if (assessableChildren.size() > 0 || isAssessable(courseNode)) {
GenericTreeNode node = new GenericTreeNode();
node.setTitle(courseNode.getShortTitle());
node.setUserObject(courseNode);
CourseNodeConfiguration nodeconfig = CourseNodeFactory.getInstance().getCourseNodeConfigurationEvenForDisabledBB(courseNode.getType());
node.setIconCssClass(nodeconfig.getIconCSSClass());
result.add(node);
assessableChildren.forEach((child) -> node.addChild(child));
}
}
return result;
}
use of org.olat.course.nodes.CourseNodeConfiguration in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
the class CourseNodeDocument method createDocument.
public static Document createDocument(SearchResourceContext searchResourceContext, CourseNode courseNode) {
CourseNodeDocument courseNodeDocument = new CourseNodeDocument();
// Set all know attributes
courseNodeDocument.setResourceUrl(searchResourceContext.getResourceUrl());
if (StringHelper.containsNonWhitespace(searchResourceContext.getDocumentType())) {
courseNodeDocument.setDocumentType(searchResourceContext.getDocumentType());
} else {
courseNodeDocument.setDocumentType(TYPE);
}
CourseNodeConfiguration nodeConfig = CourseNodeFactory.getInstance().getCourseNodeConfigurationEvenForDisabledBB(courseNode.getType());
if (nodeConfig != null && StringHelper.containsNonWhitespace(nodeConfig.getIconCSSClass())) {
courseNodeDocument.setCssIcon(nodeConfig.getIconCSSClass());
} else {
courseNodeDocument.setCssIcon("o_course_icon");
}
if (StringHelper.containsNonWhitespace(courseNode.getShortTitle())) {
courseNodeDocument.setTitle(courseNode.getShortTitle());
} else if (StringHelper.containsNonWhitespace(courseNode.getLongTitle())) {
courseNodeDocument.setTitle(courseNode.getLongTitle());
courseNodeDocument.setDescription(courseNode.getLongTitle());
}
if (StringHelper.containsNonWhitespace(courseNode.getLongTitle())) {
courseNodeDocument.setDescription(courseNode.getLongTitle());
}
if (StringHelper.containsNonWhitespace(courseNode.getLearningObjectives())) {
String objectives = courseNode.getLearningObjectives();
objectives = FilterFactory.getHtmlTagsFilter().filter(objectives);
courseNodeDocument.setContent(objectives);
}
// Get dates from parent object via context because course node has no dates
courseNodeDocument.setCreatedDate(searchResourceContext.getCreatedDate());
courseNodeDocument.setLastChange(searchResourceContext.getLastModified());
courseNodeDocument.setParentContextType(searchResourceContext.getParentContextType());
courseNodeDocument.setParentContextName(searchResourceContext.getParentContextName());
return courseNodeDocument.getLuceneDocument();
}
use of org.olat.course.nodes.CourseNodeConfiguration in project OpenOLAT by OpenOLAT.
the class EditorMainController method doCreateAlternateBuildingBlock.
/**
* The following operation are done:
* <ul>
* <li>create a new instance of the replacement type
* <li>add the new element below the original element
* <li>copy the element title, description and the generic configuration options
* <li>copy the access, visibility and scoring rules (easy and expert)
* <li>optionally copy some other configuration if this is possible at all
* <li>move all child elements from the original to the replacement element
* <li>mark the original element as deleted
* </ul>
*
* @param chosenNode
* @param selectAlternative
*/
private void doCreateAlternateBuildingBlock(UserRequest ureq, ICourse course, CourseNode chosenNode, String selectAlternative) {
if (!StringHelper.containsNonWhitespace(selectAlternative))
return;
// create the alternative node
CourseNodeConfiguration newConfig = CourseNodeFactory.getInstance().getCourseNodeConfiguration(selectAlternative);
CourseNode newNode = newConfig.getInstance();
// copy configurations
chosenNode.copyConfigurationTo(newNode, course);
// insert the node
CourseEditorTreeNode cetn = (CourseEditorTreeNode) cetm.getNodeById(chosenNode.getIdent());
CourseEditorTreeNode parentNode = (CourseEditorTreeNode) cetn.getParent();
int position = cetn.getPosition() + 1;
CourseEditorTreeNode newCetn = course.getEditorTreeModel().insertCourseNodeAt(newNode, parentNode.getCourseNode(), position);
doInsert(ureq, newNode);
// copy the children
while (cetn.getChildCount() > 0) {
CourseEditorTreeNode childNode = (CourseEditorTreeNode) cetn.getChildAt(0);
newCetn.addChild(childNode);
}
// set all dirty
TreeVisitor tv = new TreeVisitor(new Visitor() {
public void visit(INode node) {
((CourseEditorTreeNode) node).setDirty(true);
}
}, newCetn, true);
tv.visitAll();
// mark as deleted
doDelete(course, chosenNode.getIdent());
// save
CourseFactory.saveCourseEditorTreeModel(course.getResourceableId());
}
use of org.olat.course.nodes.CourseNodeConfiguration in project OpenOLAT by OpenOLAT.
the class CoursesFoldersTest method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
conn = new RestConnection();
admin = BaseSecurityManager.getInstance().findIdentityByName("administrator");
user = JunitTestHelper.createAndPersistIdentityAsUser("rest-cf-one");
course1 = CoursesWebService.createEmptyCourse(admin, "course1", "course1 long name", null);
DBFactory.getInstance().intermediateCommit();
// create a folder
CourseNodeConfiguration newNodeConfig = CourseNodeFactory.getInstance().getCourseNodeConfiguration("bc");
bcNode = newNodeConfig.getInstance();
bcNode.setShortTitle("Folder");
bcNode.setLearningObjectives("Folder objectives");
bcNode.setNoAccessExplanation("You don't have access");
course1.getEditorTreeModel().addCourseNode(bcNode, course1.getRunStructure().getRootNode());
CourseFactory.publishCourse(course1, RepositoryEntry.ACC_USERS, false, admin, Locale.ENGLISH);
DBFactory.getInstance().intermediateCommit();
}
Aggregations