Search in sources :

Example 36 with AssessmentMode

use of org.olat.course.assessment.AssessmentMode in project openolat by klemens.

the class AssessmentModeDAO method getCurrentAssessmentMode.

public List<AssessmentMode> getCurrentAssessmentMode(RepositoryEntryRef entry, Date date) {
    Calendar cal = Calendar.getInstance();
    cal.setTime(date);
    cal.set(Calendar.MILLISECOND, 0);
    cal.set(Calendar.SECOND, 0);
    StringBuilder sb = new StringBuilder();
    sb.append("select mode from courseassessmentmode mode where ").append(" mode.repositoryEntry.key=:repoKey and (").append(" (mode.beginWithLeadTime<=:now and mode.endWithFollowupTime>=:now").append("   and (mode.manualBeginEnd=false or (mode.manualBeginEnd=true and mode.leadTime>0)))").append(" or mode.statusString in ('").append(Status.leadtime.name()).append("','").append(Status.assessment.name()).append("','").append(Status.followup.name()).append("'))");
    return dbInstance.getCurrentEntityManager().createQuery(sb.toString(), AssessmentMode.class).setParameter("now", date).setParameter("repoKey", entry.getKey()).getResultList();
}
Also used : AssessmentMode(org.olat.course.assessment.AssessmentMode) Calendar(java.util.Calendar)

Example 37 with AssessmentMode

use of org.olat.course.assessment.AssessmentMode in project openolat by klemens.

the class AssessmentModeManagerImpl method merge.

@Override
public AssessmentMode merge(AssessmentMode assessmentMode, boolean forceStatus) {
    assessmentMode.setLastModified(new Date());
    // update begin with lead time
    Date begin = assessmentMode.getBegin();
    Date beginWithLeadTime = evaluateLeadTime(begin, assessmentMode.getLeadTime());
    ((AssessmentModeImpl) assessmentMode).setBeginWithLeadTime(beginWithLeadTime);
    Date end = assessmentMode.getEnd();
    Date endWithFollowupTime = evaluateFollowupTime(end, assessmentMode.getFollowupTime());
    ((AssessmentModeImpl) assessmentMode).setEndWithFollowupTime(endWithFollowupTime);
    AssessmentMode reloadedMode;
    if (assessmentMode.getKey() == null) {
        dbInstance.getCurrentEntityManager().persist(assessmentMode);
        reloadedMode = assessmentMode;
    } else {
        reloadedMode = dbInstance.getCurrentEntityManager().merge(assessmentMode);
    }
    dbInstance.commit();
    if (reloadedMode.isManualBeginEnd()) {
        reloadedMode = assessmentModeCoordinationService.syncManuallySetStatus(reloadedMode, forceStatus);
    } else {
        reloadedMode = assessmentModeCoordinationService.syncAutomicallySetStatus(reloadedMode);
    }
    return reloadedMode;
}
Also used : AssessmentModeImpl(org.olat.course.assessment.model.AssessmentModeImpl) AssessmentMode(org.olat.course.assessment.AssessmentMode) Date(java.util.Date)

Example 38 with AssessmentMode

use of org.olat.course.assessment.AssessmentMode in project openolat by klemens.

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 39 with AssessmentMode

use of org.olat.course.assessment.AssessmentMode in project openolat by klemens.

the class AssessmentModeListController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (addLink == source) {
        doAdd(ureq);
    } else if (deleteLink == source) {
        Set<Integer> index = tableEl.getMultiSelectedIndex();
        if (index == null || index.isEmpty()) {
            showWarning("error.atleastone");
        } else {
            List<AssessmentMode> rows = new ArrayList<AssessmentMode>(index.size());
            for (Integer i : index) {
                rows.add(model.getObject(i.intValue()));
            }
            doConfirmDelete(ureq, rows);
        }
    } else if (tableEl == source) {
        if (event instanceof SelectionEvent) {
            SelectionEvent se = (SelectionEvent) event;
            String cmd = se.getCommand();
            AssessmentMode row = model.getObject(se.getIndex());
            if ("edit".equals(cmd)) {
                doEdit(ureq, row);
            } else if ("start".equals(cmd)) {
                doConfirmStart(ureq, row);
            } else if ("stop".equals(cmd)) {
                doConfirmStop(ureq, row);
            }
        }
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : Set(java.util.Set) TransientAssessmentMode(org.olat.course.assessment.model.TransientAssessmentMode) AssessmentMode(org.olat.course.assessment.AssessmentMode) SelectionEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent) ArrayList(java.util.ArrayList) List(java.util.List)

Example 40 with AssessmentMode

use of org.olat.course.assessment.AssessmentMode in project openolat by klemens.

the class AssessmentModeListController method doAdd.

private void doAdd(UserRequest ureq) {
    removeAsListenerAndDispose(editCtrl);
    AssessmentMode newMode = assessmentModeMgr.createAssessmentMode(entry);
    editCtrl = new AssessmentModeEditController(ureq, getWindowControl(), entry.getOlatResource(), newMode);
    listenTo(editCtrl);
    toolbarPanel.pushController(translate("new.mode"), editCtrl);
}
Also used : TransientAssessmentMode(org.olat.course.assessment.model.TransientAssessmentMode) AssessmentMode(org.olat.course.assessment.AssessmentMode)

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