use of org.olat.course.assessment.AssessmentMode in project OpenOLAT by OpenOLAT.
the class AssessmentModeListController method doDelete.
private void doDelete(List<AssessmentMode> modesToDelete) {
for (AssessmentMode modeToDelete : modesToDelete) {
assessmentModeMgr.delete(modeToDelete);
}
loadModel();
tableEl.deselectAll();
}
use of org.olat.course.assessment.AssessmentMode in project OpenOLAT by OpenOLAT.
the class AssessmentModeCoordinationServiceImpl method beat.
protected synchronized void beat() {
if (assessmentModule.isAssessmentModeEnabled()) {
Date now = now();
List<Long> currentModeKeys = new ArrayList<>();
List<AssessmentMode> currentModes = assessmentModeManager.getAssessmentModes(now);
for (AssessmentMode currentMode : currentModes) {
try {
sendEvent(currentMode, now, false);
currentModeKeys.add(currentMode.getKey());
} catch (Exception e) {
log.error("", e);
}
}
// remove coordinated mode
List<Long> coordinatedModeKeys = new ArrayList<>(coordinatedModes.keySet());
for (Long coordinatedModeKey : coordinatedModeKeys) {
if (!currentModeKeys.contains(coordinatedModeKey)) {
CoordinatedAssessmentMode decoordinatedMode = coordinatedModes.remove(coordinatedModeKey);
if (decoordinatedMode != null) {
coordinatorManager.getCoordinator().getEventBus().deregisterFor(this, decoordinatedMode.getListenerRes());
}
}
}
if (coordinatedModes.size() > 250) {
log.error("Seem to be a leak of coordinated modes");
}
}
}
use of org.olat.course.assessment.AssessmentMode in project OpenOLAT by OpenOLAT.
the class AssessmentModeManagerImpl method getAssessmentModeFor.
@Override
public List<AssessmentMode> getAssessmentModeFor(IdentityRef identity) {
List<AssessmentMode> currentModes = getAssessmentModes(new Date());
List<AssessmentMode> myModes = null;
if (currentModes.size() > 0) {
// check permissions, groups, areas, course
myModes = assessmentModeDao.loadAssessmentModeFor(identity, currentModes);
}
return myModes == null ? Collections.<AssessmentMode>emptyList() : myModes;
}
use of org.olat.course.assessment.AssessmentMode in project OpenOLAT by OpenOLAT.
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();
}
use of org.olat.course.assessment.AssessmentMode in project openolat by klemens.
the class AssessmentModeManagerTest method loadAssessmentMode_identityInBusinessGroup.
/**
* Check an assessment linked to a group with one participant
*/
@Test
public void loadAssessmentMode_identityInBusinessGroup() {
Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-2");
RepositoryEntry entry = JunitTestHelper.deployBasicCourse(author);
Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-3");
Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("as-mode-3");
BusinessGroup businessGroup = businessGroupService.createBusinessGroup(author, "as-mode-2", "", null, null, null, null, false, false, entry);
businessGroupRelationDao.addRole(participant, businessGroup, GroupRoles.participant.name());
businessGroupRelationDao.addRole(coach, businessGroup, GroupRoles.coach.name());
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());
}
Aggregations