use of org.olat.repository.RepositoryEntry in project OpenOLAT by OpenOLAT.
the class AssessmentModeManagerTest method loadAssessmentMode_identityInArea.
/**
* Check an assessment linked to an area with one participant
*/
@Test
public void loadAssessmentMode_identityInArea() {
Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-12");
RepositoryEntry entry = JunitTestHelper.deployBasicCourse(author);
Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-13");
Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-14");
BusinessGroup businessGroup = businessGroupService.createBusinessGroup(author, "as-mode-3", "", null, null, null, null, false, false, entry);
businessGroupRelationDao.addRole(participant, businessGroup, GroupRoles.participant.name());
businessGroupRelationDao.addRole(coach, businessGroup, GroupRoles.coach.name());
BGArea area = areaMgr.createAndPersistBGArea("area for people", "", entry.getOlatResource());
areaMgr.addBGToBGArea(businessGroup, area);
AssessmentMode mode = createMinimalAssessmentmode(entry);
mode.setTargetAudience(AssessmentMode.Target.courseAndGroups);
mode.setApplySettingsForCoach(false);
mode = assessmentModeMgr.persist(mode);
AssessmentModeToGroup modeToGroup = assessmentModeMgr.createAssessmentModeToGroup(mode, businessGroup);
mode.getGroups().add(modeToGroup);
mode = assessmentModeMgr.merge(mode, true);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(mode);
// check participant
List<AssessmentMode> currentModes = assessmentModeMgr.getAssessmentModeFor(participant);
Assert.assertNotNull(currentModes);
Assert.assertEquals(1, currentModes.size());
Assert.assertTrue(currentModes.contains(mode));
// check coach
List<AssessmentMode> currentCoachModes = assessmentModeMgr.getAssessmentModeFor(coach);
Assert.assertNotNull(currentCoachModes);
Assert.assertTrue(currentCoachModes.isEmpty());
// check author
List<AssessmentMode> currentAuthorModes = assessmentModeMgr.getAssessmentModeFor(author);
Assert.assertNotNull(currentAuthorModes);
Assert.assertTrue(currentAuthorModes.isEmpty());
}
use of org.olat.repository.RepositoryEntry in project OpenOLAT by OpenOLAT.
the class AssessmentModeManagerTest method loadCurrentAssessmentModes.
@Test
public void loadCurrentAssessmentModes() {
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
AssessmentMode mode = createMinimalAssessmentmode(entry);
mode = assessmentModeMgr.persist(mode);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(mode);
// check
Date now = new Date();
List<AssessmentMode> currentModes = assessmentModeMgr.getAssessmentModes(now);
Assert.assertNotNull(currentModes);
Assert.assertFalse(currentModes.isEmpty());
Assert.assertTrue(currentModes.contains(mode));
}
use of org.olat.repository.RepositoryEntry in project OpenOLAT by OpenOLAT.
the class EfficiencyStatementManagerTest method hasUserEfficiencyStatement.
@Test
public void hasUserEfficiencyStatement() throws URISyntaxException {
RepositoryEntry re = deployTestcourse();
// add some members
Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("Eff-Del-Part-3");
Identity notParticipant = JunitTestHelper.createAndPersistIdentityAsRndUser("Eff-Del-Part-4");
repositoryService.addRole(participant, re, GroupRoles.participant.name());
dbInstance.commit();
// make statements
UserEfficiencyStatement statement = effManager.createUserEfficiencyStatement(new Date(), 6.0f, true, participant, re.getOlatResource());
dbInstance.commitAndCloseSession();
Assert.assertNotNull(statement);
// has participant an efficiency statement
boolean hasOne = effManager.hasUserEfficiencyStatement(re.getKey(), participant);
Assert.assertTrue(hasOne);
boolean hasNot = effManager.hasUserEfficiencyStatement(re.getKey(), notParticipant);
Assert.assertFalse(hasNot);
}
use of org.olat.repository.RepositoryEntry 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.repository.RepositoryEntry 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());
}
Aggregations