use of org.olat.modules.lecture.model.LectureBlockAndRollCall in project openolat by klemens.
the class LectureBlockRollCallDAO method getParticipantLectureBlockAndRollCalls.
public List<LectureBlockAndRollCall> getParticipantLectureBlockAndRollCalls(RepositoryEntryRef entry, IdentityRef identity, String teacherSeaparator) {
StringBuilder sb = new StringBuilder();
sb.append("select block, call, re.displayname").append(" from lectureblock block").append(" inner join block.entry re").append(" inner join block.groups blockToGroup").append(" inner join blockToGroup.group bGroup").append(" inner join bGroup.members membership").append(" inner join lectureparticipantsummary as summary on (summary.identity.key=membership.identity.key and summary.entry.key=block.entry.key)").append(" left join lectureblockrollcall as call on (call.identity.key=membership.identity.key and call.lectureBlock.key=block.key)").append(" where membership.identity.key=:identityKey and membership.role='").append(GroupRoles.participant.name()).append("'").append(" and block.entry.key=:repoEntryKey and block.endDate>=summary.firstAdmissionDate");
List<Object[]> rawObjects = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class).setParameter("identityKey", identity.getKey()).setParameter("repoEntryKey", entry.getKey()).getResultList();
Map<Long, LectureBlockAndRollCall> blockToRollCallMap = new HashMap<>();
for (Object[] objects : rawObjects) {
int pos = 0;
LectureBlock block = (LectureBlock) objects[pos++];
LectureBlockRollCall rollCall = (LectureBlockRollCall) objects[pos++];
String displayname = (String) objects[pos++];
blockToRollCallMap.put(block.getKey(), new LectureBlockAndRollCall(displayname, block, rollCall));
}
appendCoaches(entry, blockToRollCallMap, teacherSeaparator);
return new ArrayList<>(blockToRollCallMap.values());
}
use of org.olat.modules.lecture.model.LectureBlockAndRollCall in project openolat by klemens.
the class ParticipantLectureBlocksController method event.
@Override
protected void event(UserRequest ureq, Controller source, Event event) {
if (appealCtrl == source) {
if (event == Event.DONE_EVENT) {
LectureBlockAndRollCall row = (LectureBlockAndRollCall) appealCtrl.getUserObject();
String body = appealCtrl.getBody();
doAppealAudit(row, body);
}
cmc.deactivate();
cleanUp();
} else if (cmc == source) {
cleanUp();
}
super.event(ureq, source, event);
}
use of org.olat.modules.lecture.model.LectureBlockAndRollCall in project openolat by klemens.
the class LectureBlockRollCallStatusCellRenderer method render.
@Override
public void render(Renderer renderer, StringOutput target, Object cellValue, int row, FlexiTableComponent source, URLBuilder ubu, Translator trans) {
if (cellValue instanceof LectureBlockAndRollCallRow) {
LectureBlockAndRollCallRow rollCallRow = (LectureBlockAndRollCallRow) cellValue;
render(target, rollCallRow.getRow());
} else if (cellValue instanceof LectureBlockAndRollCall) {
render(target, (LectureBlockAndRollCall) cellValue);
}
}
use of org.olat.modules.lecture.model.LectureBlockAndRollCall in project OpenOLAT by OpenOLAT.
the class LectureBlockRollCallDAO method appendCoaches.
private void appendCoaches(RepositoryEntryRef entry, Map<Long, LectureBlockAndRollCall> blockToRollCallMap, String teacherSeaparator) {
// append the coaches
StringBuilder sc = new StringBuilder();
sc.append("select block.key, coach").append(" from lectureblock block").append(" inner join block.teacherGroup tGroup").append(" inner join tGroup.members membership").append(" inner join membership.identity coach").append(" inner join fetch coach.user usercoach").append(" where membership.role='").append("teacher").append("' and block.entry.key=:repoEntryKey");
// get all, it's quick
List<Object[]> rawCoachs = dbInstance.getCurrentEntityManager().createQuery(sc.toString(), Object[].class).setParameter("repoEntryKey", entry.getKey()).getResultList();
for (Object[] rawCoach : rawCoachs) {
Long blockKey = (Long) rawCoach[0];
LectureBlockAndRollCall rollCall = blockToRollCallMap.get(blockKey);
if (rollCall != null) {
Identity coach = (Identity) rawCoach[1];
String fullname = userManager.getUserDisplayName(coach);
if (rollCall.getCoach() == null) {
rollCall.setCoach(fullname);
} else {
rollCall.setCoach(rollCall.getCoach() + " " + teacherSeaparator + " " + fullname);
}
}
}
}
use of org.olat.modules.lecture.model.LectureBlockAndRollCall in project openolat by klemens.
the class ParticipantLectureBlocksController method loadModel.
private void loadModel() {
Date now = new Date();
Formatter formatter = Formatter.getInstance(getLocale());
String separator = translate("user.fullname.separator");
List<LectureBlockAndRollCall> rollCalls = lectureService.getParticipantLectureBlocks(entry, assessedIdentity, separator);
List<LectureBlockAuditLog> sendAppealLogs = lectureService.getAuditLog(entry, assessedIdentity, LectureBlockAuditLog.Action.sendAppeal);
Map<Long, Date> appealDates = new HashMap<>();
for (LectureBlockAuditLog sendAppealLog : sendAppealLogs) {
if (sendAppealLog.getRollCallKey() != null) {
appealDates.put(sendAppealLog.getRollCallKey(), sendAppealLog.getCreationDate());
}
}
List<LectureBlockAndRollCallRow> rows = new ArrayList<>(rollCalls.size());
for (LectureBlockAndRollCall rollCall : rollCalls) {
LectureBlockAndRollCallRow row = new LectureBlockAndRollCallRow(rollCall);
if (appealEnabled && !LectureBlockStatus.cancelled.equals(row.getRow().getStatus()) && rollCall.isCompulsory()) {
int lectures = row.getRow().getEffectiveLecturesNumber();
if (lectures <= 0) {
lectures = row.getRow().getPlannedLecturesNumber();
}
int attended = row.getRow().getLecturesAttendedNumber();
if (attended < lectures) {
Date date = row.getRow().getDate();
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal = CalendarUtils.getEndOfDay(cal);
cal.add(Calendar.DATE, appealOffset);
Date beginAppeal = CalendarUtils.removeTime(cal.getTime());
cal.add(Calendar.DATE, appealPeriod);
Date endAppeal = CalendarUtils.getEndOfDay(cal).getTime();
Date sendAppealDate = null;
if (row.getRow().getRollCallRef() != null) {
sendAppealDate = appealDates.get(row.getRow().getRollCallRef().getKey());
}
FormLink appealLink = null;
if (sendAppealDate != null) {
String appealFrom = translate("appeal.sent", new String[] { formatter.formatDate(sendAppealDate) });
appealLink = uifactory.addFormLink("appeal_" + count++, "appealsend", appealFrom, null, flc, Link.LINK | Link.NONTRANSLATED);
appealLink.setTitle(translate("appeal.sent.tooltip", new String[] { formatter.formatDate(sendAppealDate), formatter.formatDate(beginAppeal), formatter.formatDate(endAppeal) }));
appealLink.setEnabled(false);
appealLink.setDomReplacementWrapperRequired(false);
} else if (now.compareTo(beginAppeal) >= 0 && now.compareTo(endAppeal) <= 0) {
appealLink = uifactory.addFormLink("appeal_" + count++, "appeal", translate("appeal"), null, flc, Link.LINK | Link.NONTRANSLATED);
appealLink.setTitle(translate("appeal.tooltip", new String[] { formatter.formatDate(beginAppeal), formatter.formatDate(endAppeal) }));
appealLink.setUserObject(row);
// appeal
} else if (now.compareTo(endAppeal) > 0) {
// appeal closed
appealLink = uifactory.addFormLink("appeal_" + count++, "aclosed", "appeal.closed", null, flc, Link.LINK);
appealLink.setEnabled(false);
appealLink.setDomReplacementWrapperRequired(false);
} else if (now.compareTo(date) >= 0) {
// appeal at
String appealFrom = translate("appeal.from", new String[] { formatter.formatDate(beginAppeal) });
appealLink = uifactory.addFormLink("appeal_" + count++, "appealat", appealFrom, null, flc, Link.LINK | Link.NONTRANSLATED);
appealLink.setEnabled(false);
appealLink.setDomReplacementWrapperRequired(false);
}
row.setAppealButton(appealLink);
}
}
rows.add(row);
}
tableModel.setObjects(rows);
tableEl.reset(true, true, true);
}
Aggregations