use of org.olat.course.nodes.CourseNodeConfiguration in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
the class AdditionalConditionManager method nextUserInputController.
/**
* used to get the gui element for the next condition that a user can influence or sees a more detailed error-message in
* call only if the evaluateCondtions() call answered with false or null
* @param ureq
* @param wControl
* @return null if either nothing is wrong or the user is unable to influence the condition in olat (and won't get a more detailed error-message)
*/
public Controller nextUserInputController(UserRequest ureq, WindowControl wControl, UserCourseEnvironment userCourseEnv) {
for (AdditionalCondition cond : node.getAdditionalConditions()) {
cond.setNode(node);
cond.setCourseId(courseId);
boolean retVal = cond.evaluate(answers);
if (!retVal) {
Controller ctrl = cond.getUserInputController(ureq, wControl, userCourseEnv);
CourseNodeConfiguration config = CourseNodeFactory.getInstance().getCourseNodeConfiguration(node.getType());
return TitledWrapperHelper.getWrapper(ureq, wControl, ctrl, node, config.getIconCSSClass());
}
}
return null;
}
use of org.olat.course.nodes.CourseNodeConfiguration in project openolat by klemens.
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();
}
use of org.olat.course.nodes.CourseNodeConfiguration in project openolat by klemens.
the class NotificationsTest method testGetCourseForumNotifications.
@Test
public void testGetCourseForumNotifications() throws IOException, URISyntaxException {
// create a course with a forum
Identity id = JunitTestHelper.createAndPersistIdentityAsAuthor("rest-not-6-" + UUID.randomUUID().toString());
ICourse course = CoursesWebService.createEmptyCourse(id, "Course forum not", "Course forum with notification", null);
dbInstance.intermediateCommit();
// create the forum
CourseNodeConfiguration newNodeConfig = CourseNodeFactory.getInstance().getCourseNodeConfiguration("fo");
FOCourseNode forumNode = (FOCourseNode) newNodeConfig.getInstance();
forumNode.setShortTitle("Forum");
forumNode.setLearningObjectives("forum objectives");
forumNode.setNoAccessExplanation("You don't have access");
Forum courseForum = forumNode.loadOrCreateForum(course.getCourseEnvironment());
course.getEditorTreeModel().addCourseNode(forumNode, course.getRunStructure().getRootNode());
CourseFactory.publishCourse(course, RepositoryEntry.ACC_USERS, false, id, Locale.ENGLISH);
dbInstance.intermediateCommit();
// add message and publisher
RepositoryEntry re = repositoryManager.lookupRepositoryEntry(course.getCourseEnvironment().getCourseGroupManager().getCourseResource(), true);
String businessPath = "[RepositoryEntry:" + re.getKey() + "][CourseNode:" + forumNode.getIdent() + "]";
SubscriptionContext forumSubContext = new SubscriptionContext("CourseModule", course.getResourceableId(), forumNode.getIdent());
PublisherData forumPdata = new PublisherData(OresHelper.calculateTypeName(Forum.class), courseForum.getKey().toString(), businessPath);
notificationManager.subscribe(id, forumSubContext, forumPdata);
Message message = createMessage(id, courseForum);
notificationManager.markPublisherNews(forumSubContext, null, true);
dbInstance.commitAndCloseSession();
// get the notification
RestConnection conn = new RestConnection();
assertTrue(conn.login(id.getName(), "A6B7C8"));
UriBuilder request = UriBuilder.fromUri(getContextURI()).path("notifications");
HttpGet method = conn.createGet(request.build(), MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(method);
assertEquals(200, response.getStatusLine().getStatusCode());
List<SubscriptionInfoVO> infos = parseUserArray(response.getEntity().getContent());
Assert.assertNotNull(infos);
Assert.assertEquals(1, infos.size());
SubscriptionInfoVO infoVO = infos.get(0);
Assert.assertNotNull(infoVO.getItems());
Assert.assertEquals(1, infoVO.getItems().size());
SubscriptionListItemVO itemVO = infoVO.getItems().get(0);
Assert.assertNotNull(itemVO);
Assert.assertEquals(course.getResourceableId(), itemVO.getCourseKey());
Assert.assertEquals(forumNode.getIdent(), itemVO.getCourseNodeId());
Assert.assertEquals(message.getKey(), itemVO.getMessageKey());
}
use of org.olat.course.nodes.CourseNodeConfiguration in project openolat by klemens.
the class NotificationsTest method testGetCourseFolderNotifications.
@Test
public void testGetCourseFolderNotifications() throws IOException, URISyntaxException {
// create a course with a forum
Identity id = JunitTestHelper.createAndPersistIdentityAsAuthor("rest-not-7-" + UUID.randomUUID().toString());
ICourse course = CoursesWebService.createEmptyCourse(id, "Course folder not", "Course with folder and notification", null);
dbInstance.intermediateCommit();
// create the folder
CourseNodeConfiguration newNodeConfig = CourseNodeFactory.getInstance().getCourseNodeConfiguration("bc");
BCCourseNode folderNode = (BCCourseNode) newNodeConfig.getInstance();
folderNode.setShortTitle("Folder");
folderNode.setLearningObjectives("folder objectives");
folderNode.setNoAccessExplanation("You don't have access");
String relPath = BCCourseNode.getFoldernodePathRelToFolderBase(course.getCourseEnvironment(), folderNode);
VFSContainer folder = BCCourseNode.getNodeFolderContainer(folderNode, course.getCourseEnvironment());
course.getEditorTreeModel().addCourseNode(folderNode, course.getRunStructure().getRootNode());
CourseFactory.publishCourse(course, RepositoryEntry.ACC_USERS, false, id, Locale.ENGLISH);
dbInstance.intermediateCommit();
// add message and publisher
RepositoryEntry re = repositoryManager.lookupRepositoryEntry(course.getCourseEnvironment().getCourseGroupManager().getCourseResource(), true);
String businessPath = "[RepositoryEntry:" + re.getKey() + "][CourseNode:" + folderNode.getIdent() + "]";
SubscriptionContext folderSubContext = new SubscriptionContext("CourseModule", course.getResourceableId(), folderNode.getIdent());
PublisherData folderPdata = new PublisherData("FolderModule", relPath, businessPath);
notificationManager.subscribe(id, folderSubContext, folderPdata);
String filename = addFile(folder);
notificationManager.markPublisherNews(folderSubContext, null, true);
dbInstance.commitAndCloseSession();
// get the notification
RestConnection conn = new RestConnection();
assertTrue(conn.login(id.getName(), "A6B7C8"));
UriBuilder request = UriBuilder.fromUri(getContextURI()).path("notifications");
HttpGet method = conn.createGet(request.build(), MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(method);
assertEquals(200, response.getStatusLine().getStatusCode());
List<SubscriptionInfoVO> infos = parseUserArray(response.getEntity().getContent());
Assert.assertNotNull(infos);
Assert.assertEquals(1, infos.size());
SubscriptionInfoVO infoVO = infos.get(0);
Assert.assertNotNull(infoVO.getItems());
Assert.assertEquals(1, infoVO.getItems().size());
SubscriptionListItemVO itemVO = infoVO.getItems().get(0);
Assert.assertNotNull(itemVO);
Assert.assertEquals(course.getResourceableId(), itemVO.getCourseKey());
Assert.assertEquals(folderNode.getIdent(), itemVO.getCourseNodeId());
Assert.assertEquals("/" + filename, itemVO.getPath());
}
Aggregations