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;
}
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();
}
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);
}
}
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;
}
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());
}
Aggregations