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