Search in sources :

Example 31 with RepositoryEntry

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);
}
Also used : UserEfficiencyStatement(org.olat.course.assessment.UserEfficiencyStatement) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Date(java.util.Date) Test(org.junit.Test) CoachingLargeTest(org.olat.modules.coach.CoachingLargeTest)

Example 32 with RepositoryEntry

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;
}
Also used : ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) File(java.io.File) URL(java.net.URL)

Example 33 with RepositoryEntry

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());
}
Also used : ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 34 with RepositoryEntry

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));
}
Also used : AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) Test(org.junit.Test)

Example 35 with RepositoryEntry

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();
}
Also used : AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) Test(org.junit.Test)

Aggregations

RepositoryEntry (org.olat.repository.RepositoryEntry)2108 Test (org.junit.Test)922 Identity (org.olat.core.id.Identity)888 BusinessGroup (org.olat.group.BusinessGroup)344 ArrayList (java.util.ArrayList)258 File (java.io.File)246 ICourse (org.olat.course.ICourse)246 Date (java.util.Date)234 OLATResource (org.olat.resource.OLATResource)200 URI (java.net.URI)176 HttpResponse (org.apache.http.HttpResponse)172 OLATResourceable (org.olat.core.id.OLATResourceable)132 RepositoryManager (org.olat.repository.RepositoryManager)122 Roles (org.olat.core.id.Roles)104 RepositoryService (org.olat.repository.RepositoryService)104 LectureBlock (org.olat.modules.lecture.LectureBlock)94 Path (javax.ws.rs.Path)90 URL (java.net.URL)84 VFSContainer (org.olat.core.util.vfs.VFSContainer)76 WindowControl (org.olat.core.gui.control.WindowControl)74