use of org.olat.modules.lecture.LectureBlockRollCall in project OpenOLAT by OpenOLAT.
the class LectureBlockRollCallWebService method updateLectureBlockRollCall.
private Response updateLectureBlockRollCall(LectureBlockRollCallVO rollCallVo, HttpServletRequest httpRequest) {
Roles roles = getRoles(httpRequest);
if (!roles.isOLATAdmin()) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
if (rollCallVo.getKey() == null) {
return Response.serverError().status(Status.BAD_REQUEST).build();
}
LectureService lectureService = CoreSpringFactory.getImpl(LectureService.class);
LectureBlockRollCallSearchParameters searchParams = new LectureBlockRollCallSearchParameters();
searchParams.setRollCallKey(rollCallVo.getKey());
List<LectureBlockRollCall> rollCalls = lectureService.getRollCalls(searchParams);
if (rollCalls.size() == 1) {
LectureBlockRollCall rollCall = rollCalls.get(0);
rollCall.setAbsenceSupervisorNotificationDate(rollCallVo.getAbsenceSupervisorNotificationDate());
if (rollCallVo.getAbsenceReason() != null) {
rollCall.setAbsenceReason(rollCallVo.getAbsenceReason());
}
if (rollCallVo.getComment() != null) {
rollCall.setComment(rollCallVo.getComment());
}
rollCall = lectureService.updateRollCall(rollCall);
LectureBlockRollCallVO vo = new LectureBlockRollCallVO(rollCall);
return Response.ok(vo).build();
}
return Response.serverError().status(Status.NOT_FOUND).build();
}
use of org.olat.modules.lecture.LectureBlockRollCall in project OpenOLAT by OpenOLAT.
the class LectureBlockRollCallWebService method getRollCall.
/**
* Return the lecture block roll call specified by the primary key.
*
* @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
* @response.representation.404.doc The role call was not found
* @param rollCallKey The primary key of the roll call
* @param httpRequest The HTTP request
* @return The roll call
*/
@GET
@Path("{rollCallKey}")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getRollCall(@PathParam("rollCallKey") Long rollCallKey, @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();
searchParams.setRollCallKey(rollCallKey);
List<LectureBlockRollCall> rollCalls = lectureService.getRollCalls(searchParams);
if (rollCalls.size() == 1) {
LectureBlockRollCall rollCall = rollCalls.get(0);
LectureBlockRollCallVO vo = new LectureBlockRollCallVO(rollCall);
return Response.ok(vo).build();
}
return Response.serverError().status(Status.NOT_FOUND).build();
}
use of org.olat.modules.lecture.LectureBlockRollCall in project OpenOLAT by OpenOLAT.
the class TeacherRollCallController method doCheckAllRow.
private void doCheckAllRow(TeacherRollCallRow row) {
List<Integer> allAbsences = new ArrayList<>(numOfLectures);
for (int i = 0; i < numOfLectures; i++) {
allAbsences.add(i);
}
LectureBlockRollCall rollCall = lectureService.addRollCall(row.getIdentity(), lectureBlock, row.getRollCall(), null, allAbsences);
for (MultipleSelectionElement check : row.getChecks()) {
check.select(onKeys[0], true);
}
row.setRollCall(rollCall);
if (authorizedAbsenceEnabled) {
if (rollCall.getAbsenceAuthorized() != null && rollCall.getAbsenceAuthorized().booleanValue()) {
row.getAuthorizedAbsence().select(onKeys[0], true);
} else {
row.getAuthorizedAbsence().uncheckAll();
}
row.getAuthorizedAbsenceCont().setDirty(true);
}
row.getRollCallStatusEl().getComponent().setDirty(true);
tableEl.reloadData();
flc.setDirty(true);
}
use of org.olat.modules.lecture.LectureBlockRollCall in project OpenOLAT by OpenOLAT.
the class TeacherRollCallController method doAuthorizedAbsence.
private void doAuthorizedAbsence(TeacherRollCallRow row, MultipleSelectionElement check) {
LectureBlockRollCall rollCall = row.getRollCall();
boolean authorized = check.isAtLeastSelected(1);
if (rollCall == null) {
rollCall = lectureService.getOrCreateRollCall(row.getIdentity(), lectureBlock, authorized, null);
lectureService.auditLog(LectureBlockAuditLog.Action.createRollCall, null, lectureService.toAuditXml(rollCall), authorized ? "true" : "false", lectureBlock, rollCall, lectureBlock.getEntry(), row.getIdentity(), getIdentity());
} else {
String before = lectureService.toAuditXml(rollCall);
rollCall.setAbsenceAuthorized(authorized);
rollCall = lectureService.updateRollCall(rollCall);
lectureService.auditLog(LectureBlockAuditLog.Action.updateAuthorizedAbsence, before, lectureService.toAuditXml(rollCall), authorized ? "true" : "false", lectureBlock, rollCall, lectureBlock.getEntry(), row.getIdentity(), getIdentity());
}
row.getReasonLink().setVisible(authorized);
row.getAuthorizedAbsenceCont().setDirty(true);
row.getAuthorizedAbsence().clearError();
row.setRollCall(rollCall);
row.getRollCallStatusEl().getComponent().setDirty(true);
}
use of org.olat.modules.lecture.LectureBlockRollCall in project OpenOLAT by OpenOLAT.
the class TeacherRollCallController method saveLectureBlocks.
private void saveLectureBlocks() {
String before = lectureService.toAuditXml(lectureBlock);
for (int i = tableModel.getRowCount(); i-- > 0; ) {
TeacherRollCallRow row = tableModel.getObject(i);
int numOfChecks = row.getChecks().length;
List<Integer> absenceList = new ArrayList<>(numOfChecks);
for (int j = 0; j < numOfChecks; j++) {
if (row.getCheck(j).isAtLeastSelected(1)) {
absenceList.add(j);
}
}
String comment = row.getCommentEl().getValue();
LectureBlockRollCall rollCall = lectureService.addRollCall(row.getIdentity(), lectureBlock, row.getRollCall(), comment, absenceList);
row.setRollCall(rollCall);
}
lectureBlock = lectureService.getLectureBlock(lectureBlock);
if (lectureBlock.getRollCallStatus() == null) {
lectureBlock.setRollCallStatus(LectureRollCallStatus.open);
}
if (lectureBlock.getStatus() == null || lectureBlock.getStatus() == LectureBlockStatus.active) {
lectureBlock.setStatus(LectureBlockStatus.active);
}
lectureBlock = lectureService.save(lectureBlock, null);
lectureService.recalculateSummary(lectureBlock.getEntry());
String after = lectureService.toAuditXml(lectureBlock);
lectureService.auditLog(LectureBlockAuditLog.Action.saveLectureBlock, before, after, null, lectureBlock, null, lectureBlock.getEntry(), null, getIdentity());
}
Aggregations