use of org.olat.modules.lecture.model.LectureBlockWithTeachers in project OpenOLAT by OpenOLAT.
the class TeacherOverviewController method getRows.
@Override
protected List<LectureBlockRow> getRows(LecturesBlockSearchParameters searchParams) {
Identity filterByTeacher = ((Boolean) allTeachersSwitch.getUserObject()).booleanValue() ? null : getIdentity();
List<LectureBlockWithTeachers> blocksWithTeachers = lectureService.getLectureBlocksWithTeachers(entry, filterByTeacher, searchParams);
// only show the start button if
List<LectureBlockRow> rows = new ArrayList<>(blocksWithTeachers.size());
if (ConfigurationHelper.isRollCallEnabled(entryConfig, lectureModule)) {
for (LectureBlockWithTeachers blockWithTeachers : blocksWithTeachers) {
LectureBlock block = blockWithTeachers.getLectureBlock();
StringBuilder teachers = new StringBuilder(32);
List<Identity> teacherList = blockWithTeachers.getTeachers();
String separator = translate("user.fullname.separator");
for (Identity teacher : blockWithTeachers.getTeachers()) {
if (teachers.length() > 0)
teachers.append(" ").append(separator).append(" ");
teachers.append(userManager.getUserDisplayName(teacher));
}
rows.add(new LectureBlockRow(block, entry.getDisplayname(), entry.getExternalRef(), teachers.toString(), teacherList.contains(getIdentity())));
}
}
return rows;
}
use of org.olat.modules.lecture.model.LectureBlockWithTeachers in project OpenOLAT by OpenOLAT.
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());
}
use of org.olat.modules.lecture.model.LectureBlockWithTeachers in project OpenOLAT by OpenOLAT.
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());
}
}
use of org.olat.modules.lecture.model.LectureBlockWithTeachers in project OpenOLAT by OpenOLAT.
the class LecturesBlocksEntryExport method generate.
@Override
protected void generate(OutputStream out) {
blocks = lectureService.getLectureBlocksWithTeachers(entry);
Collections.sort(blocks, new LectureBlockWithTeachersComparator());
try (OpenXMLWorkbook workbook = new OpenXMLWorkbook(out, 1 + blocks.size())) {
// overview of all lecture blocks
OpenXMLWorksheet exportSheet = workbook.nextWorksheet();
exportSheet.setHeaderRows(1);
addHeaders(exportSheet);
addContent(exportSheet);
for (LectureBlockWithTeachers block : blocks) {
OpenXMLWorksheet exportBlockSheet = workbook.nextWorksheet();
LectureBlockExport lectureBlockExport = new LectureBlockExport(block.getLectureBlock(), block.getTeachers(), isAdministrativeUser, authorizedAbsenceEnabled, translator);
lectureBlockExport.generate(exportBlockSheet);
}
} catch (IOException e) {
log.error("", e);
}
}
use of org.olat.modules.lecture.model.LectureBlockWithTeachers in project openolat by klemens.
the class LectureListRepositoryController method loadModel.
private void loadModel() {
List<LectureBlockWithTeachers> blocks = lectureService.getLectureBlocksWithTeachers(entry);
List<LectureBlockRow> rows = new ArrayList<>(blocks.size());
for (LectureBlockWithTeachers block : blocks) {
LectureBlock b = block.getLectureBlock();
StringBuilder teachers = new StringBuilder();
String separator = translate("user.fullname.separator");
for (Identity teacher : block.getTeachers()) {
if (teachers.length() > 0)
teachers.append(" ").append(separator).append(" ");
teachers.append(userManager.getUserDisplayName(teacher));
}
LectureBlockRow row = new LectureBlockRow(b, entry.getDisplayname(), entry.getExternalRef(), teachers.toString(), false);
rows.add(row);
String linkName = "tools-" + counter++;
FormLink toolsLink = uifactory.addFormLink(linkName, "", null, flc, Link.LINK | Link.NONTRANSLATED);
toolsLink.setIconRightCSS("o_icon o_icon_actions o_icon-lg");
toolsLink.setUserObject(row);
flc.add(linkName, toolsLink);
row.setToolsLink(toolsLink);
}
tableModel.setObjects(rows);
tableEl.reset(true, true, true);
deleteLecturesButton.setVisible(!rows.isEmpty());
}
Aggregations