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());
}
use of org.olat.repository.RepositoryEntry in project OpenOLAT by OpenOLAT.
the class AssessmentTestSessionDAOTest method getUserTestSessions.
@Test
public void getUserTestSessions() {
// prepare a test and a user
RepositoryEntry testEntry = JunitTestHelper.createAndPersistRepositoryEntry();
RepositoryEntry courseEntry = JunitTestHelper.createAndPersistRepositoryEntry();
String subIdent = UUID.randomUUID().toString();
Identity assessedIdentity = JunitTestHelper.createAndPersistIdentityAsRndUser("session-3");
AssessmentEntry assessmentEntry = assessmentService.getOrCreateAssessmentEntry(assessedIdentity, null, courseEntry, subIdent, testEntry);
dbInstance.commit();
AssessmentTestSession testSession = testSessionDao.createAndPersistTestSession(testEntry, courseEntry, subIdent, assessmentEntry, assessedIdentity, null, true);
Assert.assertNotNull(testSession);
dbInstance.commitAndCloseSession();
List<AssessmentTestSession> sessions = testSessionDao.getUserTestSessions(courseEntry, subIdent, assessedIdentity);
Assert.assertNotNull(sessions);
Assert.assertEquals(1, sessions.size());
Assert.assertEquals(testSession, sessions.get(0));
}
use of org.olat.repository.RepositoryEntry in project OpenOLAT by OpenOLAT.
the class AssessmentTestSessionDAOTest method createTestSession_repo.
@Test
public void createTestSession_repo() {
// prepare a test and a user
RepositoryEntry testEntry = JunitTestHelper.createAndPersistRepositoryEntry();
Identity assessedIdentity = JunitTestHelper.createAndPersistIdentityAsRndUser("session-1");
AssessmentEntry assessmentEntry = assessmentService.getOrCreateAssessmentEntry(assessedIdentity, null, testEntry, "-", testEntry);
dbInstance.commit();
AssessmentTestSession testSession = testSessionDao.createAndPersistTestSession(testEntry, testEntry, "-", assessmentEntry, assessedIdentity, null, true);
Assert.assertNotNull(testSession);
dbInstance.commit();
}
Aggregations