use of org.olat.course.ICourse in project OpenOLAT by OpenOLAT.
the class EfficiencyStatementManagerTest method deployTestcourse.
private RepositoryEntry deployTestcourse() throws URISyntaxException {
// deploy a course
URL courseWithForumsUrl = CoachingLargeTest.class.getResource("CoachingCourse.zip");
File courseWithForums = new File(courseWithForumsUrl.toURI());
String softKey = UUID.randomUUID().toString();
RepositoryEntry re = CourseFactory.deployCourseFromZIP(courseWithForums, softKey, 4);
Assert.assertNotNull(re);
dbInstance.commitAndCloseSession();
ICourse course = CourseFactory.loadCourse(re);
Assert.assertTrue(course.getCourseEnvironment().getCourseConfig().isEfficencyStatementEnabled());
return re;
}
use of org.olat.course.ICourse in project OpenOLAT by OpenOLAT.
the class UserNodeAuditManagerTest method testCreateLimitedLogContent.
@Test
public void testCreateLimitedLogContent() {
// import a course
Identity author = JunitTestHelper.createAndPersistIdentityAsUser("Auth-" + UUID.randomUUID());
RepositoryEntry repositoryEntry = JunitTestHelper.deployDemoCourse(author);
Long resourceableId = repositoryEntry.getOlatResource().getResourceableId();
log.info("Demo course imported - resourceableId: " + resourceableId);
ICourse course = CourseFactory.loadCourse(resourceableId);
DBFactory.getInstance().commitAndCloseSession();
log.info("Start testCreateLimitedLogContent");
assertNotNull(course);
UserNodeAuditManagerImpl userNodeAuditManagerImpl = new UserNodeAuditManagerImpl(course);
StringBuilder logContent = new StringBuilder();
logContent.append(createTestLogContent(1));
String limitedLogContent = userNodeAuditManagerImpl.createLimitedLogContent(logContent.toString(), 400);
assertEquals("logContent should not be limited", logContent.toString(), limitedLogContent);
log.info("limitedLogContent:\n" + limitedLogContent);
log.info("limitedLogContent.length=" + limitedLogContent.length());
logContent.append(createTestLogContent(2));
limitedLogContent = userNodeAuditManagerImpl.createLimitedLogContent(logContent.toString(), 400);
assertEquals("logContent should not be limited", logContent.toString(), limitedLogContent);
log.info("limitedLogContent:\n" + limitedLogContent);
log.info("limitedLogContent.length=" + limitedLogContent.length());
logContent.append(createTestLogContent(3));
limitedLogContent = userNodeAuditManagerImpl.createLimitedLogContent(logContent.toString(), 400);
assertEquals("logContent should not be limited", logContent.toString(), limitedLogContent);
log.info("limitedLogContent:\n" + limitedLogContent);
log.info("limitedLogContent.length=" + limitedLogContent.length());
logContent.append(createTestLogContent(4));
log.info("logContent.length()=" + logContent.length());
limitedLogContent = userNodeAuditManagerImpl.createLimitedLogContent(logContent.toString(), 400);
assertTrue("limitedLogContent same size like input, probably not limited", logContent.length() != limitedLogContent.length());
assertTrue("logContent should not be limited", limitedLogContent.startsWith(UserNodeAuditManagerImpl.LOG_PREFIX_REMOVED_OLD_LOG_ENTRIES));
assertTrue("Missing Log entry2", limitedLogContent.contains("LogEntry #2"));
assertTrue("Missing Log entry3", limitedLogContent.contains("LogEntry #3"));
assertTrue("Missing Log entry4", limitedLogContent.contains("LogEntry #4"));
log.info("limitedLogContent:\n" + limitedLogContent);
log.info("limitedLogContent.length=" + limitedLogContent.length());
logContent.append(createTestLogContent(5));
limitedLogContent = userNodeAuditManagerImpl.createLimitedLogContent(logContent.toString(), 400);
assertTrue("limitedLogContent same size like input, probably not limited", logContent.length() != limitedLogContent.length());
assertTrue("logContent should not be limited", limitedLogContent.startsWith(UserNodeAuditManagerImpl.LOG_PREFIX_REMOVED_OLD_LOG_ENTRIES));
assertTrue("Missing Log entry3", limitedLogContent.contains("LogEntry #3"));
assertTrue("Missing Log entry4", limitedLogContent.contains("LogEntry #4"));
assertTrue("Missing Log entry5", limitedLogContent.contains("LogEntry #5"));
log.info("limitedLogContent:\n" + limitedLogContent);
log.info("limitedLogContent.length=" + limitedLogContent.length());
}
use of org.olat.course.ICourse in project OpenOLAT by OpenOLAT.
the class GTAReminderRuleTest method getGTACourseNode.
private GTACourseNode getGTACourseNode(RepositoryEntry courseEntry) {
ICourse course = CourseFactory.loadCourse(courseEntry);
CourseNode rootNode = course.getRunStructure().getRootNode();
for (int i = rootNode.getChildCount(); i-- > 0; ) {
INode child = rootNode.getChildAt(i);
if (child instanceof GTACourseNode) {
return ((GTACourseNode) child);
}
}
return null;
}
use of org.olat.course.ICourse in project OpenOLAT by OpenOLAT.
the class HourOfDayStatisticUpdateManagerTest method statistics_hourOfDay.
@Test
public void statistics_hourOfDay() {
Assert.assertNotNull(statisticUpdateManager);
statisticUpdateManager.setEnabled(true);
Assert.assertTrue(statisticUpdateManager.isEnabled());
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("log-3");
RepositoryEntry re1 = JunitTestHelper.deployBasicCourse(id);
ICourse course1 = CourseFactory.loadCourse(re1);
CourseNode rootNode1 = course1.getRunStructure().getRootNode();
CourseNode firstNode1 = (CourseNode) course1.getRunStructure().getRootNode().getChildAt(0);
RepositoryEntry re2 = JunitTestHelper.deployBasicCourse(id);
ICourse course2 = CourseFactory.loadCourse(re2);
CourseNode rootNode2 = course2.getRunStructure().getRootNode();
CourseNode firstNode2 = (CourseNode) course2.getRunStructure().getRootNode().getChildAt(0);
Calendar ref = Calendar.getInstance();
String date1 = null;
String date2 = null;
cleanUpLog();
for (int i = 0; i < 12; i++) {
addLogEntry(re1, rootNode1, ref, 0, getSecuredNowRef(ref, 1, i + 1), 1, i + 1);
addLogEntry(re2, firstNode2, ref, 0, getSecuredNowRef(ref, 1, i + 1), 1, i + 1);
}
for (int i = 0; i < 7; i++) {
addLogEntry(re1, rootNode1, ref, 1, 3 + i, 1, 1);
date2 = addLogEntry(re2, rootNode2, ref, 1, 3 + i, 1, 1);
}
for (int i = 0; i < 9; i++) {
date1 = addLogEntry(re1, firstNode1, ref, 2, 3 + i, 13, 1);
}
setLastUpdate(ref, 12);
dbInstance.commitAndCloseSession();
updateStatistics();
// first log analyze
String date = getHourOfDay(ref);
checkStatistics(course1, rootNode1, date);
checkStatistics(course1, firstNode1, date1);
checkStatistics(course2, rootNode2, date2);
// add log the same day
Calendar now = Calendar.getInstance();
addLogEntry(re1, rootNode1, ref, 0, now.get(Calendar.HOUR_OF_DAY), now.get(Calendar.MINUTE), now.get(Calendar.SECOND) + 1);
addLogEntry(re1, rootNode1, ref, 0, now.get(Calendar.HOUR_OF_DAY), now.get(Calendar.MINUTE), now.get(Calendar.SECOND) + 2);
addLogEntry(re2, firstNode2, ref, 0, now.get(Calendar.HOUR_OF_DAY), now.get(Calendar.MINUTE), now.get(Calendar.SECOND) + 2);
dbInstance.commitAndCloseSession();
sleep(5000);
// update stats incremental
updateStatistics();
checkStatistics(course1, rootNode1, date);
checkStatistics(course1, firstNode1, date1);
checkStatistics(course2, rootNode2, date2);
checkStatistics(course2, firstNode2, date);
// update all stats, must be the same results
updateAllStatistics();
checkStatistics(course1, rootNode1, date);
checkStatistics(course1, firstNode1, date1);
checkStatistics(course2, rootNode2, date2);
checkStatistics(course2, firstNode2, date);
}
use of org.olat.course.ICourse in project OpenOLAT by OpenOLAT.
the class UserCourseInformationsManagerTest method createUpdateCourseInfos_create.
@Test
public void createUpdateCourseInfos_create() {
Identity user = JunitTestHelper.createAndPersistIdentityAsUser("user-launch-1-" + UUID.randomUUID().toString());
ICourse course = CoursesWebService.createEmptyCourse(user, "course-launch-dates", "course long name", null);
dbInstance.commitAndCloseSession();
OLATResource courseResource = course.getCourseEnvironment().getCourseGroupManager().getCourseResource();
userCourseInformationsManager.updateUserCourseInformations(courseResource, user);
dbInstance.commitAndCloseSession();
UserCourseInformations infos = userCourseInformationsManager.getUserCourseInformations(courseResource, user);
Assert.assertNotNull(infos);
Assert.assertNotNull(infos.getIdentity());
Assert.assertNotNull(infos.getResource());
Assert.assertNotNull(infos.getInitialLaunch());
Assert.assertNotNull(infos.getRecentLaunch());
Assert.assertEquals(1, infos.getVisit());
Assert.assertEquals(infos.getIdentity(), user);
Assert.assertEquals(course.getResourceableId(), infos.getResource().getResourceableId());
Assert.assertEquals(course.getResourceableTypeName(), infos.getResource().getResourceableTypeName());
}
Aggregations