Search in sources :

Example 11 with LectureBlockWithTeachers

use of org.olat.modules.lecture.model.LectureBlockWithTeachers in project openolat by klemens.

the class LectureBlockDAO method getLecturesBlockWithTeachers.

/**
 * @param entry The course (mandatory)
 * @param teacher The teacher (optional)
 * @return
 */
public List<LectureBlockWithTeachers> getLecturesBlockWithTeachers(RepositoryEntryRef entry) {
    List<LectureBlock> blocks = getLectureBlocks(entry);
    Map<Long, LectureBlockWithTeachers> blockMap = new HashMap<>();
    for (LectureBlock block : blocks) {
        blockMap.put(block.getKey(), new LectureBlockWithTeachers(block));
    }
    // 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];
        Identity coach = (Identity) rawCoach[1];
        LectureBlockWithTeachers block = blockMap.get(blockKey);
        if (block != null) {
            block.getTeachers().add(coach);
        }
    }
    return new ArrayList<>(blockMap.values());
}
Also used : LectureBlockWithTeachers(org.olat.modules.lecture.model.LectureBlockWithTeachers) LectureBlock(org.olat.modules.lecture.LectureBlock) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Identity(org.olat.core.id.Identity)

Example 12 with LectureBlockWithTeachers

use of org.olat.modules.lecture.model.LectureBlockWithTeachers in project openolat by klemens.

the class LecturesBlocksEntryExport method addContent.

private void addContent(OpenXMLWorksheet exportSheet) {
    for (LectureBlockWithTeachers block : blocks) {
        Row row = exportSheet.newRow();
        LectureBlock lectureBlock = block.getLectureBlock();
        int pos = 0;
        row.addCell(pos++, lectureBlock.getTitle());
        row.addCell(pos++, lectureBlock.getLocation());
        row.addCell(pos++, formatDate(lectureBlock.getStartDate()));
        row.addCell(pos++, formatTime(lectureBlock.getStartDate()));
        row.addCell(pos++, formatTime(lectureBlock.getEndDate()));
        StringBuilder teachers = new StringBuilder();
        for (Identity teacher : block.getTeachers()) {
            if (teachers.length() > 0)
                teachers.append(", ");
            teachers.append(userManager.getUserDisplayName(teacher));
        }
        row.addCell(pos++, teachers.toString());
        if (lectureBlock.getRollCallStatus() == null) {
            pos++;
        } else {
            String status = LectureBlockStatusCellRenderer.getStatus(lectureBlock, translator);
            if (status != null) {
                row.addCell(pos++, status);
            } else {
                pos++;
            }
        }
        row.addCell(pos++, formatter.formatDate(lectureBlock.getAutoClosedDate()));
        row.addCell(pos++, toInt(lectureBlock.getPlannedLecturesNumber()));
        row.addCell(pos++, toInt(lectureBlock.getEffectiveLecturesNumber()));
        row.addCell(pos++, formatTime(lectureBlock.getEffectiveEndDate()));
        Reason reason = lectureBlock.getReasonEffectiveEnd();
        if (reason == null) {
            pos++;
        } else {
            row.addCell(pos++, reason.getTitle());
        }
        row.addCell(pos++, lectureBlock.getComment());
    }
}
Also used : LectureBlockWithTeachers(org.olat.modules.lecture.model.LectureBlockWithTeachers) LectureBlock(org.olat.modules.lecture.LectureBlock) Row(org.olat.core.util.openxml.OpenXMLWorksheet.Row) Identity(org.olat.core.id.Identity) Reason(org.olat.modules.lecture.Reason)

Aggregations

LectureBlockWithTeachers (org.olat.modules.lecture.model.LectureBlockWithTeachers)12 Identity (org.olat.core.id.Identity)10 LectureBlock (org.olat.modules.lecture.LectureBlock)10 ArrayList (java.util.ArrayList)8 HashMap (java.util.HashMap)4 LectureBlockRow (org.olat.modules.lecture.model.LectureBlockRow)4 IOException (java.io.IOException)2 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)2 OpenXMLWorkbook (org.olat.core.util.openxml.OpenXMLWorkbook)2 OpenXMLWorksheet (org.olat.core.util.openxml.OpenXMLWorksheet)2 Row (org.olat.core.util.openxml.OpenXMLWorksheet.Row)2 Reason (org.olat.modules.lecture.Reason)2