Search in sources :

Example 76 with AssessmentMode

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

Example 77 with AssessmentMode

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");
        }
    }
}
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 78 with AssessmentMode

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

Example 79 with AssessmentMode

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

Example 80 with AssessmentMode

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

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