Search in sources :

Example 6 with LectureBlockAndRollCall

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());
}
Also used : LectureBlockAndRollCall(org.olat.modules.lecture.model.LectureBlockAndRollCall) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) LectureBlock(org.olat.modules.lecture.LectureBlock) LectureBlockRollCall(org.olat.modules.lecture.LectureBlockRollCall)

Example 7 with LectureBlockAndRollCall

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);
}
Also used : LectureBlockAndRollCall(org.olat.modules.lecture.model.LectureBlockAndRollCall)

Example 8 with LectureBlockAndRollCall

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);
    }
}
Also used : LectureBlockAndRollCall(org.olat.modules.lecture.model.LectureBlockAndRollCall) LectureBlockAndRollCallRow(org.olat.modules.lecture.ui.LectureBlockAndRollCallRow)

Example 9 with LectureBlockAndRollCall

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);
            }
        }
    }
}
Also used : LectureBlockAndRollCall(org.olat.modules.lecture.model.LectureBlockAndRollCall) Identity(org.olat.core.id.Identity)

Example 10 with LectureBlockAndRollCall

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);
}
Also used : LectureBlockAndRollCall(org.olat.modules.lecture.model.LectureBlockAndRollCall) HashMap(java.util.HashMap) Formatter(org.olat.core.util.Formatter) Calendar(java.util.Calendar) ArrayList(java.util.ArrayList) LectureBlockAuditLog(org.olat.modules.lecture.LectureBlockAuditLog) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) Date(java.util.Date)

Aggregations

LectureBlockAndRollCall (org.olat.modules.lecture.model.LectureBlockAndRollCall)10 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 Calendar (java.util.Calendar)2 Date (java.util.Date)2 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)2 Identity (org.olat.core.id.Identity)2 Formatter (org.olat.core.util.Formatter)2 LectureBlock (org.olat.modules.lecture.LectureBlock)2 LectureBlockAuditLog (org.olat.modules.lecture.LectureBlockAuditLog)2 LectureBlockRollCall (org.olat.modules.lecture.LectureBlockRollCall)2 LectureBlockAndRollCallRow (org.olat.modules.lecture.ui.LectureBlockAndRollCallRow)2