use of org.olat.course.tree.CourseEditorTreeNode in project OpenOLAT by OpenOLAT.
the class PublishProcessTest method testPublishANotReallyNewNode.
/**
* Publish a course with a node marked as new but the node
* exists already in the run structure.
*
* @throws URISyntaxException
*/
@Test
public void testPublishANotReallyNewNode() throws URISyntaxException {
Identity author = JunitTestHelper.createAndPersistIdentityAsAdmin("publisher-" + UUID.randomUUID().toString());
RepositoryEntry re = deployTestCourse("simple_course_err1_new.zip");
// change node 1
ICourse course = CourseFactory.loadCourse(re.getOlatResource().getResourceableId());
CourseEditorTreeModel cetm = course.getEditorTreeModel();
CourseEditorTreeNode node1 = (CourseEditorTreeNode) cetm.getRootNode().getChildAt(0);
// publish the course and must survive this without exception
// as the course has no changes but we try to publish it
List<String> nodeIds = Collections.singletonList(node1.getIdent());
publishCourse(nodeIds, re, author);
// check the change
ICourse reloadedCourse = CourseFactory.loadCourse(re.getOlatResource().getResourceableId());
Assert.assertEquals(3, reloadedCourse.getRunStructure().getRootNode().getChildCount());
INode runNode1 = reloadedCourse.getRunStructure().getRootNode().getChildAt(0);
Assert.assertNotNull(runNode1);
CourseNode runNode1Impl = (CourseNode) runNode1;
Assert.assertEquals("Node 1 not really new", runNode1Impl.getShortTitle());
}
use of org.olat.course.tree.CourseEditorTreeNode in project OpenOLAT by OpenOLAT.
the class CheckListStepRunnerCallback method execute.
@Override
public Step execute(UserRequest ureq, WindowControl wControl, StepsRunContext runContext) {
GeneratorData data = (GeneratorData) runContext.get("data");
List<Checkbox> templateCheckbox = data.getCheckboxList();
ModuleConfiguration templateConfig = data.getModuleConfiguration();
ICourse course = CourseFactory.getCourseEditSession(courseOres.getResourceableId());
CourseEnvironment courseEnv = course.getCourseEnvironment();
CheckboxManager checkboxManager = CoreSpringFactory.getImpl(CheckboxManager.class);
CourseNode structureNode = createCourseNode(data.getStructureShortTitle(), data.getStructureTitle(), data.getStructureObjectives(), "st");
CourseEditorTreeNode parentNode = (CourseEditorTreeNode) course.getEditorTreeModel().getRootNode();
course.getEditorTreeModel().addCourseNode(structureNode, parentNode.getCourseNode());
List<CheckListNode> nodes = data.getNodes();
List<String> nodesIdent = new ArrayList<>();
for (CheckListNode node : nodes) {
String title = node.getTitle();
CheckListCourseNode checkNode = (CheckListCourseNode) createCourseNode(title, title, null, "checklist");
nodesIdent.add(checkNode.getIdent());
ModuleConfiguration config = checkNode.getModuleConfiguration();
config.putAll(templateConfig);
CheckboxList checkboxList = new CheckboxList();
List<Checkbox> boxes = new ArrayList<>();
for (Checkbox templateBox : templateCheckbox) {
Checkbox checkbox = templateBox.clone();
boxes.add(checkbox);
if (StringHelper.containsNonWhitespace(templateBox.getFilename())) {
File path = new File(FolderConfig.getCanonicalTmpDir(), templateBox.getCheckboxId());
VFSContainer tmpContainer = new LocalFolderImpl(path);
VFSItem item = tmpContainer.resolve(templateBox.getFilename());
if (item instanceof VFSLeaf) {
VFSContainer container = checkboxManager.getFileContainer(courseEnv, checkNode);
VFSManager.copyContent(tmpContainer, container);
tmpContainer.deleteSilently();
}
}
}
checkboxList.setList(boxes);
config.set(CheckListCourseNode.CONFIG_KEY_CHECKBOX, checkboxList);
boolean dueDate = node.getDueDate() != null;
if (dueDate) {
config.set(CheckListCourseNode.CONFIG_KEY_DUE_DATE, node.getDueDate());
}
config.set(CheckListCourseNode.CONFIG_KEY_CLOSE_AFTER_DUE_DATE, new Boolean(dueDate));
course.getEditorTreeModel().addCourseNode(checkNode, structureNode);
}
setScoreCalculation(data, (STCourseNode) structureNode, nodesIdent);
return StepsMainRunController.DONE_MODIFIED;
}
use of org.olat.course.tree.CourseEditorTreeNode in project OpenOLAT by OpenOLAT.
the class CoursesContactElementTest method testFullConfig.
@Test
public void testFullConfig() throws IOException, URISyntaxException {
assertTrue(conn.login("administrator", "openolat"));
// create an contact node
URI newContactUri = getElementsUri(course1).path("contact").queryParam("parentNodeId", rootNodeId).queryParam("position", "0").queryParam("shortTitle", "Contact-1").queryParam("longTitle", "Contact-long-1").queryParam("objectives", "Contact-objectives-1").queryParam("coaches", "true").queryParam("participants", "true").queryParam("groups", "").queryParam("areas", "").queryParam("to", "test@frentix.com;test2@frentix.com").queryParam("defaultSubject", "Hello by contact 1").queryParam("defaultBody", "Hello by contact 1 body").build();
HttpPut method = conn.createPut(newContactUri, MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(method);
// check the return values
assertEquals(200, response.getStatusLine().getStatusCode());
CourseNodeVO contactNode = conn.parse(response, CourseNodeVO.class);
assertNotNull(contactNode);
assertNotNull(contactNode.getId());
// check the persisted value
ICourse course = CourseFactory.loadCourse(course1.getResourceableId());
TreeNode node = course.getEditorTreeModel().getNodeById(contactNode.getId());
assertNotNull(node);
CourseEditorTreeNode editorCourseNode = (CourseEditorTreeNode) node;
CourseNode courseNode = editorCourseNode.getCourseNode();
ModuleConfiguration config = courseNode.getModuleConfiguration();
assertNotNull(config);
assertEquals(config.getBooleanEntry(CONFIG_KEY_EMAILTOCOACHES), true);
assertEquals(config.getBooleanEntry(CONFIG_KEY_EMAILTOPARTICIPANTS), true);
@SuppressWarnings("unchecked") List<String> tos = (List<String>) config.get(CONFIG_KEY_EMAILTOADRESSES);
assertNotNull(tos);
assertEquals(2, tos.size());
assertEquals(config.get(CONFIG_KEY_MSUBJECT_DEFAULT), "Hello by contact 1");
assertEquals(config.get(CONFIG_KEY_MBODY_DEFAULT), "Hello by contact 1 body");
}
use of org.olat.course.tree.CourseEditorTreeNode in project OpenOLAT by OpenOLAT.
the class PublishProcess method checkUpdates.
private List<StatusDescription> checkUpdates(List<CourseEditorTreeNode> courseEditorTreeNodes, CourseEditorEnv cev) {
List<StatusDescription> notifications = new ArrayList<StatusDescription>();
for (Iterator<CourseEditorTreeNode> iter = courseEditorTreeNodes.iterator(); iter.hasNext(); ) {
CourseEditorTreeNode cetn = iter.next();
CourseNode cn = cetn.getCourseNode();
List<StatusDescription> nodeNotes = cn.publishUpdatesExplanations(cev);
if (nodeNotes != null && nodeNotes.size() > 0) {
notifications.addAll(nodeNotes);
}
}
return notifications;
}
use of org.olat.course.tree.CourseEditorTreeNode in project OpenOLAT by OpenOLAT.
the class PublishProcess method assemblePublishConfirmation.
String assemblePublishConfirmation() {
List<String> nodeIdsToPublish = originalNodeIdsToPublish;
StringBuilder msg = new StringBuilder();
OLATResourceable courseRunOres = OresHelper.createOLATResourceableInstance(RunMainController.ORES_TYPE_COURSE_RUN, repositoryEntry.getOlatResource().getResourceableId());
// -1: Remove myself from list
int cnt = CoordinatorManager.getInstance().getCoordinator().getEventBus().getListeningIdentityCntFor(courseRunOres) - 1;
if (cnt > 0) {
msg.append(translate("pbl.confirm.users", String.valueOf(cnt)));
} else {
msg.append(translator.translate("pbl.confirm"));
}
if (nodeIdsToPublish != null && nodeIdsToPublish.size() > 0) {
msg.append("<ul class='list-unstyled'>");
CourseEditorTreeModel cetm = course.getEditorTreeModel();
for (int i = 0; i < nodeIdsToPublish.size(); i++) {
msg.append("<li>");
String nodeId = nodeIdsToPublish.get(i);
CourseEditorTreeNode cetn = (CourseEditorTreeNode) cetm.getNodeById(nodeId);
CourseNode cn = cetm.getCourseNode(nodeId);
if (cetn.isDeleted() && !cetn.isNewnode()) {
msg.append("<i class='o_icon o_icon_delete_item'> </i> ");
} else {
CourseNodeConfiguration nodeConfig = CourseNodeFactory.getInstance().getCourseNodeConfigurationEvenForDisabledBB(cn.getType());
if (nodeConfig != null) {
msg.append("<i class='o_icon ").append(nodeConfig.getIconCSSClass()).append("'> </i> ");
}
}
msg.append(cn.getShortTitle()).append("</li>");
}
msg.append("</ul>");
}
return msg.toString();
}
Aggregations