Search in sources :

Example 6 with CourseNodeConfiguration

use of org.olat.course.nodes.CourseNodeConfiguration in project OpenOLAT by OpenOLAT.

the class QTI21StatisticResourceResult method createAssessmentController.

private Controller createAssessmentController(UserRequest ureq, WindowControl wControl, TooledStackedPanel stackPanel, boolean printMode) {
    Controller ctrl = new QTI21AssessmentTestStatisticsController(ureq, wControl, stackPanel, this, withFilter, printMode);
    if (courseNode != null) {
        CourseNodeConfiguration cnConfig = CourseNodeFactory.getInstance().getCourseNodeConfigurationEvenForDisabledBB(courseNode.getType());
        String iconCssClass = cnConfig.getIconCSSClass();
        ctrl = TitledWrapperHelper.getWrapper(ureq, wControl, ctrl, courseNode, iconCssClass);
    }
    return ctrl;
}
Also used : CourseNodeConfiguration(org.olat.course.nodes.CourseNodeConfiguration) Controller(org.olat.core.gui.control.Controller)

Example 7 with CourseNodeConfiguration

use of org.olat.course.nodes.CourseNodeConfiguration in project OpenOLAT by OpenOLAT.

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();
}
Also used : CourseNodeConfiguration(org.olat.course.nodes.CourseNodeConfiguration) Before(org.junit.Before)

Example 8 with CourseNodeConfiguration

use of org.olat.course.nodes.CourseNodeConfiguration in project OpenOLAT by OpenOLAT.

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());
}
Also used : Message(org.olat.modules.fo.Message) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) ICourse(org.olat.course.ICourse) FOCourseNode(org.olat.course.nodes.FOCourseNode) CourseNodeConfiguration(org.olat.course.nodes.CourseNodeConfiguration) RepositoryEntry(org.olat.repository.RepositoryEntry) PublisherData(org.olat.core.commons.services.notifications.PublisherData) SubscriptionListItemVO(org.olat.core.commons.services.notifications.restapi.vo.SubscriptionListItemVO) Forum(org.olat.modules.fo.Forum) SubscriptionInfoVO(org.olat.core.commons.services.notifications.restapi.vo.SubscriptionInfoVO) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) Identity(org.olat.core.id.Identity) UriBuilder(javax.ws.rs.core.UriBuilder) Test(org.junit.Test)

Example 9 with CourseNodeConfiguration

use of org.olat.course.nodes.CourseNodeConfiguration in project OpenOLAT by OpenOLAT.

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());
}
Also used : VFSContainer(org.olat.core.util.vfs.VFSContainer) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) ICourse(org.olat.course.ICourse) CourseNodeConfiguration(org.olat.course.nodes.CourseNodeConfiguration) RepositoryEntry(org.olat.repository.RepositoryEntry) PublisherData(org.olat.core.commons.services.notifications.PublisherData) SubscriptionListItemVO(org.olat.core.commons.services.notifications.restapi.vo.SubscriptionListItemVO) BCCourseNode(org.olat.course.nodes.BCCourseNode) SubscriptionInfoVO(org.olat.core.commons.services.notifications.restapi.vo.SubscriptionInfoVO) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) Identity(org.olat.core.id.Identity) UriBuilder(javax.ws.rs.core.UriBuilder) Test(org.junit.Test)

Example 10 with CourseNodeConfiguration

use of org.olat.course.nodes.CourseNodeConfiguration in project OpenOLAT by OpenOLAT.

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;
}
Also used : Condition(org.olat.course.condition.Condition) ModuleConfiguration(org.olat.modules.ModuleConfiguration) CourseNodeVO(org.olat.restapi.support.vo.CourseNodeVO) CourseEditorTreeNode(org.olat.course.tree.CourseEditorTreeNode) AbstractAccessableCourseNode(org.olat.course.nodes.AbstractAccessableCourseNode) ICourse(org.olat.course.ICourse) CourseNodeConfiguration(org.olat.course.nodes.CourseNodeConfiguration) CourseNode(org.olat.course.nodes.CourseNode) AbstractAccessableCourseNode(org.olat.course.nodes.AbstractAccessableCourseNode)

Aggregations

CourseNodeConfiguration (org.olat.course.nodes.CourseNodeConfiguration)38 CourseNode (org.olat.course.nodes.CourseNode)16 ICourse (org.olat.course.ICourse)10 CourseEditorTreeNode (org.olat.course.tree.CourseEditorTreeNode)8 Controller (org.olat.core.gui.control.Controller)6 CourseEditorTreeModel (org.olat.course.tree.CourseEditorTreeModel)6 ArrayList (java.util.ArrayList)4 UriBuilder (javax.ws.rs.core.UriBuilder)4 HttpResponse (org.apache.http.HttpResponse)4 HttpGet (org.apache.http.client.methods.HttpGet)4 Before (org.junit.Before)4 Test (org.junit.Test)4 PublisherData (org.olat.core.commons.services.notifications.PublisherData)4 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)4 SubscriptionInfoVO (org.olat.core.commons.services.notifications.restapi.vo.SubscriptionInfoVO)4 SubscriptionListItemVO (org.olat.core.commons.services.notifications.restapi.vo.SubscriptionListItemVO)4 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)4 Identity (org.olat.core.id.Identity)4 STCourseNode (org.olat.course.nodes.STCourseNode)4 RepositoryEntry (org.olat.repository.RepositoryEntry)4