use of org.olat.modules.lecture.LectureBlockRollCall in project OpenOLAT by OpenOLAT.
the class LectureServiceImpl method adaptRollCalls.
@Override
public void adaptRollCalls(LectureBlock lectureBlock) {
LectureBlockStatus status = lectureBlock.getStatus();
LectureRollCallStatus rollCallStatus = lectureBlock.getRollCallStatus();
if (status == LectureBlockStatus.done || rollCallStatus == LectureRollCallStatus.closed || rollCallStatus == LectureRollCallStatus.autoclosed) {
log.warn("Try to adapt roll call of a closed lecture block: " + lectureBlock.getKey());
return;
}
List<LectureBlockRollCall> rollCallList = lectureBlockRollCallDao.getRollCalls(lectureBlock);
for (LectureBlockRollCall rollCall : rollCallList) {
int numOfLectures = lectureBlock.getEffectiveLecturesNumber();
if (numOfLectures <= 0 && lectureBlock.getStatus() != LectureBlockStatus.cancelled) {
numOfLectures = lectureBlock.getPlannedLecturesNumber();
}
lectureBlockRollCallDao.adaptLecture(lectureBlock, rollCall, numOfLectures, null);
}
}
use of org.olat.modules.lecture.LectureBlockRollCall in project OpenOLAT by OpenOLAT.
the class LectureServiceImpl method close.
@Override
public LectureBlock close(LectureBlock lectureBlock, Identity author) {
lectureBlock.setStatus(LectureBlockStatus.done);
lectureBlock.setRollCallStatus(LectureRollCallStatus.closed);
LectureBlockImpl block = (LectureBlockImpl) lectureBlockDao.update(lectureBlock);
int numOfLectures = block.getEffectiveLecturesNumber();
if (numOfLectures <= 0 && block.getStatus() != LectureBlockStatus.cancelled) {
numOfLectures = block.getPlannedLecturesNumber();
}
List<LectureBlockRollCall> rollCallList = lectureBlockRollCallDao.getRollCalls(lectureBlock);
for (LectureBlockRollCall rollCall : rollCallList) {
lectureBlockRollCallDao.adaptLecture(block, rollCall, numOfLectures, author);
}
dbInstance.commit();
recalculateSummary(block.getEntry());
return block;
}
use of org.olat.modules.lecture.LectureBlockRollCall in project OpenOLAT by OpenOLAT.
the class LectureServiceImpl method autoClose.
private void autoClose(LectureBlockImpl lectureBlock) {
String blockBefore = auditLogDao.toXml(lectureBlock);
lectureBlock.setStatus(LectureBlockStatus.done);
lectureBlock.setRollCallStatus(LectureRollCallStatus.autoclosed);
if (lectureBlock.getEffectiveLecturesNumber() <= 0 && lectureBlock.getStatus() != LectureBlockStatus.cancelled) {
lectureBlock.setEffectiveLecturesNumber(lectureBlock.getPlannedLecturesNumber());
}
lectureBlock.setAutoClosedDate(new Date());
lectureBlock = (LectureBlockImpl) lectureBlockDao.update(lectureBlock);
dbInstance.commit();
List<LectureBlockRollCall> rollCalls = lectureBlockRollCallDao.getRollCalls(lectureBlock);
Map<Identity, LectureBlockRollCall> rollCallMap = rollCalls.stream().collect(Collectors.toMap(r -> r.getIdentity(), r -> r));
List<ParticipantAndLectureSummary> participantsAndSummaries = lectureParticipantSummaryDao.getLectureParticipantSummaries(lectureBlock);
Set<Identity> participants = new HashSet<>();
for (ParticipantAndLectureSummary participantAndSummary : participantsAndSummaries) {
if (participants.contains(participantAndSummary.getIdentity())) {
continue;
}
if (participantAndSummary.getSummary() != null) {
LectureBlockRollCall rollCall = rollCallMap.get(participantAndSummary.getIdentity());
String before = auditLogDao.toXml(rollCall);
if (rollCall == null) {
rollCall = lectureBlockRollCallDao.createAndPersistRollCall(lectureBlock, participantAndSummary.getIdentity(), null, null, null, new ArrayList<>());
} else if (rollCall.getLecturesAbsentList().isEmpty() && rollCall.getLecturesAttendedList().isEmpty()) {
rollCall = lectureBlockRollCallDao.addLecture(lectureBlock, rollCall, new ArrayList<>());
}
String after = auditLogDao.toXml(rollCall);
auditLogDao.auditLog(LectureBlockAuditLog.Action.autoclose, before, after, null, lectureBlock, rollCall, lectureBlock.getEntry(), participantAndSummary.getIdentity(), null);
}
}
String blockAfter = auditLogDao.toXml(lectureBlock);
auditLogDao.auditLog(LectureBlockAuditLog.Action.autoclose, blockBefore, blockAfter, null, lectureBlock, null, lectureBlock.getEntry(), null, null);
dbInstance.commit();
recalculateSummary(lectureBlock.getEntry());
}
use of org.olat.modules.lecture.LectureBlockRollCall in project OpenOLAT by OpenOLAT.
the class TeacherLecturesTableController method doExportAttendanceList.
private void doExportAttendanceList(UserRequest ureq, LectureBlock row) {
LectureBlock lectureBlock = lectureService.getLectureBlock(row);
List<Identity> participants = lectureService.getParticipants(lectureBlock);
List<LectureBlockRollCall> rollCalls = lectureService.getRollCalls(row);
try {
LecturesBlockPDFExport export = new LecturesBlockPDFExport(lectureBlock, authorizedAbsenceEnabled, getTranslator());
export.setTeacher(userManager.getUserDisplayName(getIdentity()));
export.create(participants, rollCalls);
ureq.getDispatchResult().setResultingMediaResource(export);
} catch (IOException | TransformerException e) {
logError("", e);
}
}
use of org.olat.modules.lecture.LectureBlockRollCall in project OpenOLAT by OpenOLAT.
the class LectureBlockRollCallWebService method getRollCalls.
/**
* Return a list lecture block roll call.
*
* @response.representation.200.qname {http://www.example.com}lectureBlockRollCallVO
* @response.representation.200.mediaType application/xml, application/json
* @response.representation.200.doc A lecture block roll call
* @response.representation.200.example {@link org.olat.modules.lecture.restapi.Examples#SAMPLE_LECTUREBLOCKROLLCALLVO}
* @response.representation.401.doc The roles of the authenticated user are not sufficient
* @param closed If true, the status of the block is done or the status of the roll call is closed or auto closed
* @param hasAbsence If true, the roll call has an absence
* @param hasSupervisorNotificationDate If true, the roll call has a supervisor notification date set
* @param httpRequest The HTTP request
* @return The roll calls
*/
@GET
@Path("/")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getRollCalls(@QueryParam("closed") Boolean closed, @QueryParam("hasAbsence") Boolean hasAbsence, @QueryParam("hasSupervisorNotificationDate") Boolean hasSupervisorNotificationDate, @QueryParam("lectureBlockKey") Long lectureBlockKey, @Context HttpServletRequest httpRequest) {
Roles roles = getRoles(httpRequest);
if (!roles.isOLATAdmin()) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
LectureService lectureService = CoreSpringFactory.getImpl(LectureService.class);
LectureBlockRollCallSearchParameters searchParams = new LectureBlockRollCallSearchParameters();
if (hasAbsence != null) {
searchParams.setHasAbsence(hasAbsence);
}
if (hasSupervisorNotificationDate != null) {
searchParams.setHasSupervisorNotificationDate(hasSupervisorNotificationDate);
}
if (closed != null) {
searchParams.setClosed(closed);
}
if (lectureBlockKey != null) {
searchParams.setLectureBlockKey(lectureBlockKey);
}
List<LectureBlockRollCall> rollCalls = lectureService.getRollCalls(searchParams);
List<LectureBlockRollCallVO> voList = new ArrayList<>(rollCalls.size());
for (LectureBlockRollCall rollCall : rollCalls) {
voList.add(new LectureBlockRollCallVO(rollCall));
}
LectureBlockRollCallVO[] voes = voList.toArray(new LectureBlockRollCallVO[voList.size()]);
return Response.ok(voes).build();
}
Aggregations