use of org.olat.course.assessment.AssessmentMode in project openolat by klemens.
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 klemens.
the class AssessmentModeListController method doConfirmDelete.
private void doConfirmDelete(UserRequest ureq, List<AssessmentMode> modeToDelete) {
StringBuilder sb = new StringBuilder();
boolean canDelete = true;
for (AssessmentMode mode : modeToDelete) {
if (sb.length() > 0)
sb.append(", ");
sb.append(mode.getName());
Status status = mode.getStatus();
if (status == Status.leadtime || status == Status.assessment || status == Status.followup) {
canDelete = false;
}
}
if (canDelete) {
String names = StringHelper.escapeHtml(sb.toString());
String title = translate("confirm.delete.title");
String text = translate("confirm.delete.text", names);
deleteDialogBox = activateYesNoDialog(ureq, title, text, deleteDialogBox);
deleteDialogBox.setUserObject(modeToDelete);
} else {
showWarning("error.in.assessment");
}
}
use of org.olat.course.assessment.AssessmentMode in project openolat by klemens.
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 klemens.
the class AssessmentModeDAO method loadAssessmentModeFor.
protected List<AssessmentMode> loadAssessmentModeFor(IdentityRef identity, List<AssessmentMode> currentModes) {
StringBuilder sb = new StringBuilder(1500);
sb.append("select mode from courseassessmentmode mode ").append(" inner join fetch mode.repositoryEntry entry").append(" left join mode.groups as modeToGroup").append(" left join mode.areas as modeToArea").append(" where mode.key in (:modeKeys)").append(" and ((mode.targetAudienceString in ('").append(AssessmentMode.Target.courseAndGroups.name()).append("','").append(AssessmentMode.Target.groups.name()).append("')").append(" and (exists (select businessGroup from businessgroup as businessGroup, bgroupmember as membership").append(" where modeToGroup.businessGroup.key=businessGroup.key and membership.group.key=businessGroup.baseGroup.key and membership.identity.key=:identityKey").append(" and (membership.role='").append(GroupRoles.participant.name()).append("' or ").append(" (mode.applySettingsForCoach=true and membership.role='").append(GroupRoles.coach.name()).append("'))").append(" ) or exists (select areaToGroup from ").append(BGtoAreaRelationImpl.class.getName()).append(" as areaToGroup,businessgroup as businessGroupArea, bgroupmember as membership").append(" where modeToArea.area=areaToGroup.groupArea and areaToGroup.businessGroup=businessGroupArea and membership.group=businessGroupArea.baseGroup and membership.identity.key=:identityKey").append(" and (membership.role='").append(GroupRoles.participant.name()).append("' or ").append(" (mode.applySettingsForCoach=true and membership.role='").append(GroupRoles.coach.name()).append("'))").append(" ))) or (mode.targetAudienceString in ('").append(AssessmentMode.Target.courseAndGroups.name()).append("','").append(AssessmentMode.Target.course.name()).append("')").append(" and exists (select rel from repoentrytogroup as rel, bgroupmember as membership ").append(" where mode.repositoryEntry.key=rel.entry.key and membership.group.key=rel.group.key and rel.defaultGroup=true and membership.identity.key=:identityKey").append(" and (membership.role='").append(GroupRoles.participant.name()).append("' or ").append(" (mode.applySettingsForCoach=true and membership.role='").append(GroupRoles.coach.name()).append("'))").append(" ))").append(" )");
List<Long> modeKeys = new ArrayList<>(currentModes.size());
for (AssessmentMode mode : currentModes) {
modeKeys.add(mode.getKey());
}
List<AssessmentMode> modeList = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), AssessmentMode.class).setParameter("identityKey", identity.getKey()).setParameter("modeKeys", modeKeys).getResultList();
// quicker than distinct
return new ArrayList<AssessmentMode>(new HashSet<AssessmentMode>(modeList));
}
Aggregations