Search in sources :

Example 91 with AssessmentMode

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();
}
Also used : TransientAssessmentMode(org.olat.course.assessment.model.TransientAssessmentMode) AssessmentMode(org.olat.course.assessment.AssessmentMode)

Example 92 with AssessmentMode

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");
    }
}
Also used : Status(org.olat.course.assessment.AssessmentMode.Status) TransientAssessmentMode(org.olat.course.assessment.model.TransientAssessmentMode) AssessmentMode(org.olat.course.assessment.AssessmentMode)

Example 93 with AssessmentMode

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");
        }
    }
}
Also used : TransientAssessmentMode(org.olat.course.assessment.model.TransientAssessmentMode) CoordinatedAssessmentMode(org.olat.course.assessment.model.CoordinatedAssessmentMode) AssessmentMode(org.olat.course.assessment.AssessmentMode) ArrayList(java.util.ArrayList) CoordinatedAssessmentMode(org.olat.course.assessment.model.CoordinatedAssessmentMode) Date(java.util.Date)

Example 94 with AssessmentMode

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));
}
Also used : AssessmentMode(org.olat.course.assessment.AssessmentMode) ArrayList(java.util.ArrayList)

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