Search in sources :

Example 61 with CourseNode

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

the class AbstractDueDateTaskRuleSPI method evaluate.

@Override
public List<Identity> evaluate(RepositoryEntry entry, ReminderRule rule) {
    List<Identity> identities = null;
    if (rule instanceof ReminderRuleImpl) {
        ReminderRuleImpl r = (ReminderRuleImpl) rule;
        String nodeIdent = r.getLeftOperand();
        ICourse course = CourseFactory.loadCourse(entry);
        CourseNode courseNode = course.getRunStructure().getNode(nodeIdent);
        if (courseNode instanceof GTACourseNode) {
            identities = evaluateRule(entry, (GTACourseNode) courseNode, r);
        }
    }
    return identities == null ? Collections.<Identity>emptyList() : identities;
}
Also used : ReminderRuleImpl(org.olat.modules.reminder.model.ReminderRuleImpl) GTACourseNode(org.olat.course.nodes.GTACourseNode) ICourse(org.olat.course.ICourse) CourseNode(org.olat.course.nodes.CourseNode) GTACourseNode(org.olat.course.nodes.GTACourseNode) Identity(org.olat.core.id.Identity)

Example 62 with CourseNode

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

the class HomeCalendarManager method isCourseCalendarEnabled.

private boolean isCourseCalendarEnabled(ICourse course) {
    if (course.getCourseConfig().isCalendarEnabled()) {
        return true;
    }
    CourseNode rootNode = course.getRunStructure().getRootNode();
    CalCourseNodeVisitor v = new CalCourseNodeVisitor();
    new TreeVisitor(v, rootNode, true).visitAll();
    return v.isFound();
}
Also used : TreeVisitor(org.olat.core.util.tree.TreeVisitor) CourseNode(org.olat.course.nodes.CourseNode) CalCourseNode(org.olat.course.nodes.CalCourseNode)

Example 63 with CourseNode

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

the class CourseIndexer method doIndexCourse.

/**
 * @param repositoryResourceContext
 * @param course
 * @param courseNode
 * @param indexWriter
 * @throws IOException
 * @throws InterruptedException
 */
private void doIndexCourse(SearchResourceContext repositoryResourceContext, ICourse course, INode node, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
    // try to index the course node
    if (node instanceof CourseNode) {
        if (isLogDebugEnabled())
            logDebug("Analyse CourseNode child ... childCourseNode=" + node);
        // go further with resource
        CourseNode childCourseNode = (CourseNode) node;
        CourseNodeIndexer courseNodeIndexer = getCourseNodeIndexer(childCourseNode);
        if (courseNodeIndexer != null) {
            if (isLogDebugEnabled())
                logDebug("courseNodeIndexer=" + courseNodeIndexer);
            try {
                courseNodeIndexer.doIndex(repositoryResourceContext, course, childCourseNode, indexWriter);
            } catch (Exception e) {
                logWarn("Can not index course node=" + childCourseNode.getIdent(), e);
            }
        }
    }
    // loop over all child nodes
    int childCount = node.getChildCount();
    for (int i = 0; i < childCount; i++) {
        INode childNode = node.getChildAt(i);
        doIndexCourse(repositoryResourceContext, course, childNode, indexWriter);
    }
}
Also used : INode(org.olat.core.util.nodes.INode) CourseNodeIndexer(org.olat.search.service.indexer.repository.course.CourseNodeIndexer) CourseNode(org.olat.course.nodes.CourseNode) AssertException(org.olat.core.logging.AssertException) CorruptedCourseException(org.olat.course.CorruptedCourseException) StartupException(org.olat.core.logging.StartupException) IOException(java.io.IOException)

Example 64 with CourseNode

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

the class PFNotifications method getItems.

public List<SubscriptionListItem> getItems() throws Exception {
    Publisher p = subscriber.getPublisher();
    Identity identity = subscriber.getIdentity();
    ICourse course = CourseFactory.loadCourse(p.getResId());
    CourseEnvironment courseEnv = course.getCourseEnvironment();
    CourseGroupManager groupManager = courseEnv.getCourseGroupManager();
    CourseNode node = course.getRunStructure().getNode(p.getSubidentifier());
    RepositoryEntry entry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
    Date latestNews = p.getLatestNewsDate();
    if (notificationsManager.isPublisherValid(p) && compareDate.before(latestNews)) {
        this.displayname = entry.getDisplayname();
        if (groupManager.isIdentityCourseCoach(identity) || groupManager.isIdentityCourseAdministrator(identity)) {
            List<Identity> participants = pfManager.getParticipants(identity, courseEnv, groupManager.isIdentityCourseAdministrator(identity));
            for (Identity participant : participants) {
                gatherItems(participant, p, courseEnv, node);
            }
        } else {
            gatherItems(identity, p, courseEnv, node);
        }
    }
    return items;
}
Also used : CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) ICourse(org.olat.course.ICourse) Publisher(org.olat.core.commons.services.notifications.Publisher) CourseNode(org.olat.course.nodes.CourseNode) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Date(java.util.Date)

Example 65 with CourseNode

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

the class CoursePublishTest method testGetCourse.

@Test
public void testGetCourse() throws IOException, URISyntaxException {
    RestConnection conn = new RestConnection();
    assertTrue(conn.login("administrator", "openolat"));
    // deploy a test course
    URL courseWithForumsUrl = CoursePublishTest.class.getResource("myCourseWS.zip");
    Assert.assertNotNull(courseWithForumsUrl);
    File courseWithForums = new File(courseWithForumsUrl.toURI());
    String softKey = UUID.randomUUID().toString().replace("-", "").substring(0, 30);
    RepositoryEntry re = CourseFactory.deployCourseFromZIP(courseWithForums, softKey, 4);
    Assert.assertNotNull(re);
    ICourse course = CourseFactory.loadCourse(re.getOlatResource().getResourceableId());
    CourseNode rootNode = course.getRunStructure().getRootNode();
    Assert.assertEquals(2, rootNode.getChildCount());
    dbInstance.commitAndCloseSession();
    // get the course
    URI uri = conn.getContextURI().path("repo").path("courses").path(course.getResourceableId().toString()).build();
    HttpGet method = conn.createGet(uri, MediaType.APPLICATION_JSON, true);
    HttpResponse response = conn.execute(method);
    assertEquals(200, response.getStatusLine().getStatusCode());
    CourseVO courseVo = conn.parse(response, CourseVO.class);
    Assert.assertNotNull(courseVo);
    // update the root node
    URI rootUri = getElementsUri(courseVo).path("structure").path(courseVo.getEditorRootNodeId()).build();
    HttpPost updateMethod = conn.createPost(rootUri, MediaType.APPLICATION_JSON);
    HttpEntity entity = MultipartEntityBuilder.create().setMode(HttpMultipartMode.BROWSER_COMPATIBLE).addTextBody("shortTitle", "Change it short").addTextBody("longTitle", "Change it long").build();
    updateMethod.setEntity(entity);
    HttpResponse updateRootResponse = conn.execute(updateMethod);
    int updateRootCode = updateRootResponse.getStatusLine().getStatusCode();
    assertTrue(updateRootCode == 200 || updateRootCode == 201);
    EntityUtils.consume(updateRootResponse.getEntity());
    // publish
    URI publishUri = getCoursesUri().path(courseVo.getKey().toString()).path("publish").build();
    HttpPost publishMethod = conn.createPost(publishUri, MediaType.APPLICATION_JSON);
    HttpResponse publishResponse = conn.execute(publishMethod);
    int publishCode = publishResponse.getStatusLine().getStatusCode();
    assertTrue(publishCode == 200 || publishCode == 201);
    EntityUtils.consume(publishResponse.getEntity());
    // reload the course
    ICourse reloadedCourse = CourseFactory.loadCourse(re.getOlatResource().getResourceableId());
    CourseNode reloadRootNode = reloadedCourse.getRunStructure().getRootNode();
    Assert.assertEquals(2, reloadRootNode.getChildCount());
}
Also used : HttpPost(org.apache.http.client.methods.HttpPost) HttpEntity(org.apache.http.HttpEntity) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) URI(java.net.URI) URL(java.net.URL) CourseVO(org.olat.restapi.support.vo.CourseVO) CourseNode(org.olat.course.nodes.CourseNode) File(java.io.File) Test(org.junit.Test)

Aggregations

CourseNode (org.olat.course.nodes.CourseNode)402 ICourse (org.olat.course.ICourse)182 AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)98 Identity (org.olat.core.id.Identity)74 STCourseNode (org.olat.course.nodes.STCourseNode)72 ArrayList (java.util.ArrayList)68 RepositoryEntry (org.olat.repository.RepositoryEntry)64 CourseEditorTreeNode (org.olat.course.tree.CourseEditorTreeNode)54 INode (org.olat.core.util.nodes.INode)44 GTACourseNode (org.olat.course.nodes.GTACourseNode)44 UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)42 TACourseNode (org.olat.course.nodes.TACourseNode)40 TreeNode (org.olat.core.gui.components.tree.TreeNode)38 IQTESTCourseNode (org.olat.course.nodes.IQTESTCourseNode)36 MSCourseNode (org.olat.course.nodes.MSCourseNode)36 ScormCourseNode (org.olat.course.nodes.ScormCourseNode)30 Test (org.junit.Test)28 AbstractAccessableCourseNode (org.olat.course.nodes.AbstractAccessableCourseNode)28 ScoreEvaluation (org.olat.course.run.scoring.ScoreEvaluation)28 CourseEditorTreeModel (org.olat.course.tree.CourseEditorTreeModel)26