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();
}
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()));
}
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));
}
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);
}
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();
}
Aggregations