Search in sources :

Example 71 with AssessmentMode

use of org.olat.course.assessment.AssessmentMode in project OpenOLAT by OpenOLAT.

the class AssessmentModeManagerTest method getCurrentAssessmentMode_manualNow.

/**
 * Manual without lead time -> not in the current list
 */
@Test
public void getCurrentAssessmentMode_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.getCurrentAssessmentMode(entry, now);
    Assert.assertNotNull(currentModes);
    Assert.assertTrue(currentModes.isEmpty());
}
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 72 with AssessmentMode

use of org.olat.course.assessment.AssessmentMode in project OpenOLAT by OpenOLAT.

the class AssessmentModeManagerTest method getAssessedIdentities_course_areas.

@Test
public void getAssessedIdentities_course_areas() {
    Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-20");
    RepositoryEntry entry = JunitTestHelper.deployBasicCourse(author);
    Identity participant1 = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-21");
    Identity coach1 = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-22");
    BusinessGroup businessGroup = businessGroupService.createBusinessGroup(null, "as-mode-5", "", 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-23");
    Identity coach2 = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-24");
    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);
    BGArea area = areaMgr.createAndPersistBGArea("area for people", "", entry.getOlatResource());
    areaMgr.addBGToBGArea(businessGroup, area);
    AssessmentModeToArea modeToArea = assessmentModeMgr.createAssessmentModeToArea(mode, area);
    mode.getAreas().add(modeToArea);
    mode = assessmentModeMgr.merge(mode, true);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(mode);
    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 : 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)

Example 73 with AssessmentMode

use of org.olat.course.assessment.AssessmentMode in project OpenOLAT by OpenOLAT.

the class AssessmentModeManagerTest method isInAssessmentMode_manual.

/**
 * Manual without leading time -> not in assessment mode
 */
@Test
public void isInAssessmentMode_manual() {
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    AssessmentMode mode = createMinimalAssessmentmode(entry);
    mode.setManualBeginEnd(true);
    mode = assessmentModeMgr.persist(mode);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(mode);
    // check
    Date now = new Date();
    boolean entryNow = assessmentModeMgr.isInAssessmentMode(entry, now);
    Assert.assertFalse(entryNow);
}
Also used : AssessmentMode(org.olat.course.assessment.AssessmentMode) RepositoryEntry(org.olat.repository.RepositoryEntry) Date(java.util.Date) Test(org.junit.Test)

Example 74 with AssessmentMode

use of org.olat.course.assessment.AssessmentMode in project OpenOLAT by OpenOLAT.

the class AssessmentModeListModel method updateModeStatus.

public boolean updateModeStatus(TransientAssessmentMode modeToUpdate) {
    boolean updated = false;
    List<AssessmentMode> modes = getObjects();
    for (AssessmentMode mode : modes) {
        if (mode.getKey().equals(modeToUpdate.getModeKey())) {
            if (mode.getStatus() != modeToUpdate.getStatus()) {
                mode.setStatus(modeToUpdate.getStatus());
                updated = true;
            }
        }
    }
    return updated;
}
Also used : AssessmentMode(org.olat.course.assessment.AssessmentMode) TransientAssessmentMode(org.olat.course.assessment.model.TransientAssessmentMode)

Example 75 with AssessmentMode

use of org.olat.course.assessment.AssessmentMode in project OpenOLAT by OpenOLAT.

the class AssessmentModeListController method event.

@Override
public void event(UserRequest ureq, Controller source, Event event) {
    if (editCtrl == source) {
        loadModel();
        toolbarPanel.popUpToController(this);
        removeAsListenerAndDispose(editCtrl);
        editCtrl = null;
    } else if (deleteDialogBox == source) {
        if (DialogBoxUIFactory.isYesEvent(event) || DialogBoxUIFactory.isOkEvent(event)) {
            @SuppressWarnings("unchecked") List<AssessmentMode> rows = (List<AssessmentMode>) deleteDialogBox.getUserObject();
            doDelete(rows);
        }
    } else if (startDialogBox == source) {
        if (DialogBoxUIFactory.isYesEvent(event) || DialogBoxUIFactory.isOkEvent(event)) {
            AssessmentMode row = (AssessmentMode) startDialogBox.getUserObject();
            doStart(row);
        }
    } else if (stopDialogBox == source) {
        if (DialogBoxUIFactory.isYesEvent(event) || DialogBoxUIFactory.isOkEvent(event)) {
            AssessmentMode row = (AssessmentMode) stopDialogBox.getUserObject();
            doStop(row);
        }
    }
    super.event(ureq, source, event);
}
Also used : TransientAssessmentMode(org.olat.course.assessment.model.TransientAssessmentMode) AssessmentMode(org.olat.course.assessment.AssessmentMode) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

AssessmentMode (org.olat.course.assessment.AssessmentMode)94 RepositoryEntry (org.olat.repository.RepositoryEntry)62 Test (org.junit.Test)52 Date (java.util.Date)32 Identity (org.olat.core.id.Identity)28 BusinessGroup (org.olat.group.BusinessGroup)24 Calendar (java.util.Calendar)20 AssessmentModeToGroup (org.olat.course.assessment.AssessmentModeToGroup)16 TransientAssessmentMode (org.olat.course.assessment.model.TransientAssessmentMode)16 ArrayList (java.util.ArrayList)12 BGArea (org.olat.group.area.BGArea)12 UserRequest (org.olat.core.gui.UserRequest)10 TooledStackedPanel (org.olat.core.gui.components.stack.TooledStackedPanel)10 Controller (org.olat.core.gui.control.Controller)10 WindowControl (org.olat.core.gui.control.WindowControl)10 MainLayoutController (org.olat.core.gui.control.generic.layout.MainLayoutController)10 AssessmentModeToArea (org.olat.course.assessment.AssessmentModeToArea)10 RepositoryEntrySecurity (org.olat.repository.model.RepositoryEntrySecurity)10 RuntimeControllerCreator (org.olat.repository.ui.RepositoryEntryRuntimeController.RuntimeControllerCreator)10 StepsMainRunController (org.olat.core.gui.control.generic.wizard.StepsMainRunController)8