Search in sources :

Example 66 with RepositoryEntry

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());
}
Also used : AssessmentMode(org.olat.course.assessment.AssessmentMode) BusinessGroup(org.olat.group.BusinessGroup) BGArea(org.olat.group.area.BGArea) AssessmentModeToGroup(org.olat.course.assessment.AssessmentModeToGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 67 with RepositoryEntry

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));
}
Also used : AssessmentMode(org.olat.course.assessment.AssessmentMode) RepositoryEntry(org.olat.repository.RepositoryEntry) Date(java.util.Date) Test(org.junit.Test)

Example 68 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 69 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 70 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)

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