Search in sources :

Example 61 with RepositoryEntry

use of org.olat.repository.RepositoryEntry in project OpenOLAT by OpenOLAT.

the class AssessmentModeManagerTest method createAssessmentMode.

@Test
public void createAssessmentMode() {
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    AssessmentMode mode = assessmentModeMgr.createAssessmentMode(entry);
    mode.setName("Assessment in sight");
    mode.setDescription("Assessment description");
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MILLISECOND, 0);
    cal.add(Calendar.DATE, 2);
    Date begin = cal.getTime();
    cal.add(Calendar.HOUR_OF_DAY, 2);
    Date end = cal.getTime();
    mode.setBegin(begin);
    mode.setEnd(end);
    mode.setLeadTime(15);
    mode.setTargetAudience(Target.course);
    mode.setRestrictAccessElements(true);
    mode.setElementList("173819739,239472389");
    mode.setRestrictAccessIps(true);
    mode.setIpList("192.168.1.123");
    mode.setSafeExamBrowser(true);
    mode.setSafeExamBrowserKey("785rhqg47368ahfahl");
    mode.setSafeExamBrowserHint("Use the SafeExamBrowser");
    mode.setApplySettingsForCoach(true);
    AssessmentMode savedMode = assessmentModeMgr.persist(mode);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(savedMode);
    Assert.assertNotNull(savedMode.getKey());
    Assert.assertNotNull(savedMode.getCreationDate());
    Assert.assertNotNull(savedMode.getLastModified());
    // reload and check
    AssessmentMode reloadedMode = assessmentModeMgr.getAssessmentModeById(savedMode.getKey());
    Assert.assertNotNull(reloadedMode);
    Assert.assertEquals(savedMode.getKey(), reloadedMode.getKey());
    Assert.assertNotNull(reloadedMode.getCreationDate());
    Assert.assertNotNull(reloadedMode.getLastModified());
    Assert.assertEquals(savedMode, reloadedMode);
    Assert.assertEquals("Assessment in sight", reloadedMode.getName());
    Assert.assertEquals("Assessment description", reloadedMode.getDescription());
    Assert.assertEquals(begin, reloadedMode.getBegin());
    Assert.assertEquals(end, reloadedMode.getEnd());
    Assert.assertEquals(15, reloadedMode.getLeadTime());
    Assert.assertEquals(Target.course, reloadedMode.getTargetAudience());
    Assert.assertTrue(reloadedMode.isRestrictAccessElements());
    Assert.assertEquals("173819739,239472389", reloadedMode.getElementList());
    Assert.assertTrue(reloadedMode.isRestrictAccessIps());
    Assert.assertEquals("192.168.1.123", reloadedMode.getIpList());
    Assert.assertTrue(reloadedMode.isApplySettingsForCoach());
    Assert.assertTrue(reloadedMode.isSafeExamBrowser());
    Assert.assertEquals("785rhqg47368ahfahl", reloadedMode.getSafeExamBrowserKey());
    Assert.assertEquals("Use the SafeExamBrowser", reloadedMode.getSafeExamBrowserHint());
}
Also used : AssessmentMode(org.olat.course.assessment.AssessmentMode) Calendar(java.util.Calendar) RepositoryEntry(org.olat.repository.RepositoryEntry) Date(java.util.Date) Test(org.junit.Test)

Example 62 with RepositoryEntry

use of org.olat.repository.RepositoryEntry in project OpenOLAT by OpenOLAT.

the class AssessmentModeManagerTest method getAssessedIdentities_course_groups.

@Test
public void getAssessedIdentities_course_groups() {
    Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-15");
    RepositoryEntry entry = JunitTestHelper.deployBasicCourse(author);
    Identity participant1 = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-16");
    Identity coach1 = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-17");
    BusinessGroup businessGroup = businessGroupService.createBusinessGroup(null, "as-mode-4", "", null, null, null, null, false, false, entry);
    businessGroupRelationDao.addRole(participant1, businessGroup, GroupRoles.participant.name());
    businessGroupRelationDao.addRole(coach1, businessGroup, GroupRoles.coach.name());
    Identity participant2 = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-18");
    Identity coach2 = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-19");
    repositoryEntryRelationDao.addRole(participant2, entry, GroupRoles.participant.name());
    repositoryEntryRelationDao.addRole(coach2, entry, GroupRoles.coach.name());
    repositoryEntryRelationDao.addRole(author, entry, GroupRoles.owner.name());
    AssessmentMode mode = createMinimalAssessmentmode(entry);
    mode.setTargetAudience(AssessmentMode.Target.courseAndGroups);
    mode.setApplySettingsForCoach(true);
    mode = assessmentModeMgr.persist(mode);
    AssessmentModeToGroup modeToGroup = assessmentModeMgr.createAssessmentModeToGroup(mode, businessGroup);
    mode.getGroups().add(modeToGroup);
    mode = assessmentModeMgr.merge(mode, true);
    dbInstance.commitAndCloseSession();
    Set<Long> assessedIdentityKeys = assessmentModeMgr.getAssessedIdentityKeys(mode);
    Assert.assertNotNull(assessedIdentityKeys);
    Assert.assertEquals(4, assessedIdentityKeys.size());
    Assert.assertFalse(assessedIdentityKeys.contains(author.getKey()));
    Assert.assertTrue(assessedIdentityKeys.contains(coach1.getKey()));
    Assert.assertTrue(assessedIdentityKeys.contains(participant1.getKey()));
    Assert.assertTrue(assessedIdentityKeys.contains(coach2.getKey()));
    Assert.assertTrue(assessedIdentityKeys.contains(participant2.getKey()));
}
Also used : AssessmentMode(org.olat.course.assessment.AssessmentMode) BusinessGroup(org.olat.group.BusinessGroup) AssessmentModeToGroup(org.olat.course.assessment.AssessmentModeToGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 63 with RepositoryEntry

use of org.olat.repository.RepositoryEntry in project OpenOLAT by OpenOLAT.

the class AssessmentModeManagerTest method loadAssessmentMode_repositoryEntry.

@Test
public void loadAssessmentMode_repositoryEntry() {
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    AssessmentMode mode = createMinimalAssessmentmode(entry);
    mode = assessmentModeMgr.persist(mode);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(mode);
    // check
    List<AssessmentMode> currentModes = assessmentModeMgr.getAssessmentModeFor(entry);
    Assert.assertNotNull(currentModes);
    Assert.assertEquals(1, currentModes.size());
    Assert.assertTrue(currentModes.contains(mode));
}
Also used : AssessmentMode(org.olat.course.assessment.AssessmentMode) RepositoryEntry(org.olat.repository.RepositoryEntry) Test(org.junit.Test)

Example 64 with RepositoryEntry

use of org.olat.repository.RepositoryEntry in project OpenOLAT by OpenOLAT.

the class AssessmentModeManagerTest method loadCurrentAssessmentModes_manualNow.

/**
 * Manual without lead time -> not in the current list
 */
@Test
public void loadCurrentAssessmentModes_manualNow() {
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    // manual now
    AssessmentMode mode = assessmentModeMgr.createAssessmentMode(entry);
    mode.setName("Assessment to load");
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MILLISECOND, 0);
    cal.add(Calendar.HOUR_OF_DAY, -1);
    mode.setBegin(cal.getTime());
    cal.add(Calendar.HOUR_OF_DAY, 2);
    mode.setEnd(cal.getTime());
    mode.setTargetAudience(Target.course);
    mode.setManualBeginEnd(true);
    mode = assessmentModeMgr.persist(mode);
    dbInstance.commitAndCloseSession();
    // check
    Date now = new Date();
    List<AssessmentMode> currentModes = assessmentModeMgr.getAssessmentModes(now);
    Assert.assertNotNull(currentModes);
    Assert.assertFalse(currentModes.contains(mode));
}
Also used : AssessmentMode(org.olat.course.assessment.AssessmentMode) Calendar(java.util.Calendar) RepositoryEntry(org.olat.repository.RepositoryEntry) Date(java.util.Date) Test(org.junit.Test)

Example 65 with RepositoryEntry

use of org.olat.repository.RepositoryEntry in project OpenOLAT by OpenOLAT.

the class AssessmentModeManagerTest method deleteAreaFromRepositoryEntry.

@Test
public void deleteAreaFromRepositoryEntry() {
    // prepare the setup
    Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-14");
    Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-15");
    RepositoryEntry entry = JunitTestHelper.deployBasicCourse(author);
    AssessmentMode mode = createMinimalAssessmentmode(entry);
    mode.setTargetAudience(AssessmentMode.Target.groups);
    mode = assessmentModeMgr.persist(mode);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(mode);
    BusinessGroup businessGroupForArea = businessGroupService.createBusinessGroup(author, "as_mode_1", "", null, null, null, null, false, false, null);
    businessGroupRelationDao.addRole(participant, businessGroupForArea, GroupRoles.participant.name());
    BGArea area = areaMgr.createAndPersistBGArea("little area", "My little secret area", entry.getOlatResource());
    areaMgr.addBGToBGArea(businessGroupForArea, area);
    dbInstance.commitAndCloseSession();
    AssessmentModeToArea modeToArea = assessmentModeMgr.createAssessmentModeToArea(mode, area);
    mode.getAreas().add(modeToArea);
    mode = assessmentModeMgr.merge(mode, true);
    dbInstance.commitAndCloseSession();
    // check the participant modes
    List<AssessmentMode> currentModes = assessmentModeMgr.getAssessmentModeFor(participant);
    Assert.assertNotNull(currentModes);
    Assert.assertEquals(1, currentModes.size());
    Assert.assertTrue(currentModes.contains(mode));
    // delete
    areaMgr.deleteBGArea(area);
    dbInstance.commitAndCloseSession();
    // check the participant modes after deleting the area
    List<AssessmentMode> afterDeleteModes = assessmentModeMgr.getAssessmentModeFor(participant);
    Assert.assertNotNull(afterDeleteModes);
    Assert.assertEquals(0, afterDeleteModes.size());
}
Also used : AssessmentModeToArea(org.olat.course.assessment.AssessmentModeToArea) AssessmentMode(org.olat.course.assessment.AssessmentMode) BusinessGroup(org.olat.group.BusinessGroup) BGArea(org.olat.group.area.BGArea) 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