Search in sources :

Example 31 with AssessmentMode

use of org.olat.course.assessment.AssessmentMode in project openolat by klemens.

the class AssessmentModeManagerTest method createAssessmentModeToGroup.

@Test
public void createAssessmentModeToGroup() {
    Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-1");
    RepositoryEntry entry = JunitTestHelper.deployBasicCourse(author);
    BusinessGroup businessGroup = businessGroupService.createBusinessGroup(author, "as_mode_1", "", null, null, null, null, false, false, null);
    AssessmentMode mode = createMinimalAssessmentmode(entry);
    mode = assessmentModeMgr.persist(mode);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(mode);
    AssessmentModeToGroup modeToGroup = assessmentModeMgr.createAssessmentModeToGroup(mode, businessGroup);
    mode.getGroups().add(modeToGroup);
    AssessmentMode savedMode = assessmentModeMgr.merge(mode, true);
    dbInstance.commitAndCloseSession();
    AssessmentMode reloadedMode = assessmentModeMgr.getAssessmentModeById(mode.getKey());
    Assert.assertEquals(mode, reloadedMode);
    Assert.assertEquals(savedMode, reloadedMode);
    Assert.assertNotNull(reloadedMode.getGroups());
    Assert.assertEquals(1, reloadedMode.getGroups().size());
    Assert.assertEquals(modeToGroup, reloadedMode.getGroups().iterator().next());
    dbInstance.commitAndCloseSession();
}
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 32 with AssessmentMode

use of org.olat.course.assessment.AssessmentMode in project openolat by klemens.

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 33 with AssessmentMode

use of org.olat.course.assessment.AssessmentMode in project openolat by klemens.

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 34 with AssessmentMode

use of org.olat.course.assessment.AssessmentMode in project openolat by klemens.

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 35 with AssessmentMode

use of org.olat.course.assessment.AssessmentMode in project openolat by klemens.

the class AssessmentModeDAO method findAssessmentMode.

public List<AssessmentMode> findAssessmentMode(SearchAssessmentModeParams params) {
    StringBuilder sb = new StringBuilder();
    sb.append("select mode from courseassessmentmode mode").append(" inner join fetch mode.repositoryEntry v").append(" inner join fetch v.olatResource res");
    boolean where = false;
    Date date = params.getDate();
    if (date != null) {
        where = appendAnd(sb, where);
        sb.append(":date between mode.beginWithLeadTime and mode.endWithFollowupTime");
    }
    String name = params.getName();
    if (StringHelper.containsNonWhitespace(name)) {
        name = PersistenceHelper.makeFuzzyQueryString(name);
        where = appendAnd(sb, where);
        sb.append("(");
        appendFuzzyLike(sb, "v.displayname", "name", dbInstance.getDbVendor());
        sb.append(" or ");
        appendFuzzyLike(sb, "mode.name", "name", dbInstance.getDbVendor());
        sb.append(")");
    }
    Long id = null;
    String refs = null;
    String fuzzyRefs = null;
    if (StringHelper.containsNonWhitespace(params.getIdAndRefs())) {
        refs = params.getIdAndRefs();
        fuzzyRefs = PersistenceHelper.makeFuzzyQueryString(refs);
        where = appendAnd(sb, where);
        sb.append(" (v.externalId=:ref or ");
        PersistenceHelper.appendFuzzyLike(sb, "v.externalRef", "fuzzyRefs", dbInstance.getDbVendor());
        sb.append(" or v.softkey=:ref");
        if (StringHelper.isLong(refs)) {
            try {
                id = Long.parseLong(refs);
                sb.append(" or v.key=:vKey or res.resId=:vKey");
            } catch (NumberFormatException e) {
            // 
            }
        }
        sb.append(")");
    }
    sb.append(" order by mode.beginWithLeadTime desc ");
    TypedQuery<AssessmentMode> query = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), AssessmentMode.class);
    if (StringHelper.containsNonWhitespace(params.getName())) {
        query.setParameter("name", name);
    }
    if (id != null) {
        query.setParameter("vKey", id);
    }
    if (refs != null) {
        query.setParameter("ref", refs);
    }
    if (fuzzyRefs != null) {
        query.setParameter("fuzzyRefs", fuzzyRefs);
    }
    if (date != null) {
        query.setParameter("date", date, TemporalType.TIMESTAMP);
    }
    return query.getResultList();
}
Also used : AssessmentMode(org.olat.course.assessment.AssessmentMode) Date(java.util.Date)

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