use of org.olat.modules.lecture.LectureBlock in project OpenOLAT by OpenOLAT.
the class LectureBlockWebService method addRepositoryEntryParticipantGroup.
/**
* Add the group of the course to the lecture block participants list.
* @response.representation.200.doc Successfully added
* @return 200 if all ok
*/
@PUT
@Path("participants/repositoryentry")
public Response addRepositoryEntryParticipantGroup() {
LectureBlock reloadedBlock = lectureService.getLectureBlock(lectureBlock);
Group defGroup = CoreSpringFactory.getImpl(RepositoryService.class).getDefaultGroup(entry);
List<Group> currentGroups = lectureService.getLectureBlockToGroups(reloadedBlock);
if (!currentGroups.contains(defGroup)) {
currentGroups.add(defGroup);
reloadedBlock = lectureService.save(reloadedBlock, currentGroups);
}
lectureService.syncParticipantSummaries(reloadedBlock);
return Response.ok().build();
}
use of org.olat.modules.lecture.LectureBlock in project OpenOLAT by OpenOLAT.
the class LectureBlocksWebService method putLectureBlocks.
/**
* Create or update a lecture block.
* @response.representation.200.qname {http://www.example.com}lectureBlocksVO
* @response.representation.200.mediaType application/xml, application/json
* @response.representation.200.doc The updated configuration
* @response.representation.200.example {@link org.olat.modules.lecture.restapi.Examples#SAMPLE_LECTUREBLOCKVO}
* @response.representation.401.doc The roles of the authenticated user are not sufficient
* @response.representation.404.doc The course not found
* @param block The lecture block
* @param request The HTTP request
* @return It returns the updated / created lecture block.
*/
@PUT
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response putLectureBlocks(LectureBlockVO block, @Context HttpServletRequest httpRequest) {
Roles roles = getRoles(httpRequest);
if (!roles.isOLATAdmin()) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
LectureBlock updatedBlock = saveLectureBlock(block);
return Response.ok(new LectureBlockVO(updatedBlock, entry.getKey())).build();
}
use of org.olat.modules.lecture.LectureBlock in project OpenOLAT by OpenOLAT.
the class LectureBlocksWebService method saveLectureBlock.
private LectureBlock saveLectureBlock(LectureBlockVO blockVo) {
LectureBlock block;
int currentPlannedLectures;
boolean syncParticipants = false;
if (blockVo.getKey() != null && blockVo.getKey() > 0) {
block = lectureService.getLectureBlock(blockVo);
currentPlannedLectures = block.getPlannedLecturesNumber();
} else {
block = lectureService.createLectureBlock(entry);
currentPlannedLectures = -1;
if ("autoclosed".equals(blockVo.getRollCallStatus())) {
block.setStatus(LectureBlockStatus.done);
block.setRollCallStatus(LectureRollCallStatus.autoclosed);
syncParticipants = true;
}
}
if (blockVo.getExternalId() != null) {
block.setExternalId(blockVo.getExternalId());
}
if (blockVo.getTitle() != null) {
block.setTitle(blockVo.getTitle());
}
if (blockVo.getDescription() != null) {
block.setDescription(blockVo.getDescription());
}
if (blockVo.getPreparation() != null) {
block.setPreparation(blockVo.getPreparation());
}
if (blockVo.getLocation() != null) {
block.setLocation(blockVo.getLocation());
}
if (blockVo.getComment() != null) {
block.setComment(blockVo.getComment());
}
if (blockVo.getStartDate() != null) {
block.setStartDate(blockVo.getStartDate());
}
if (blockVo.getEndDate() != null) {
block.setEndDate(blockVo.getEndDate());
}
if (blockVo.getCompulsory() != null) {
block.setCompulsory(blockVo.getCompulsory().booleanValue());
}
if (blockVo.getManagedFlagsString() != null) {
block.setManagedFlagsString(blockVo.getManagedFlagsString());
}
block.setPlannedLecturesNumber(blockVo.getPlannedLectures());
LectureBlock savedLectureBlock = lectureService.save(block, null);
if (currentPlannedLectures > 0 && currentPlannedLectures != savedLectureBlock.getPlannedLecturesNumber()) {
lectureService.adaptRollCalls(savedLectureBlock);
}
if (syncParticipants) {
lectureService.syncParticipantSummaries(savedLectureBlock);
}
return savedLectureBlock;
}
use of org.olat.modules.lecture.LectureBlock in project OpenOLAT by OpenOLAT.
the class AbstractTeacherOverviewController method canStartRollCall.
private boolean canStartRollCall(LectureBlockRow blockWithTeachers) {
LectureBlock lectureBlock = blockWithTeachers.getLectureBlock();
if (blockWithTeachers.isIamTeacher() && lectureBlock.getStatus() != LectureBlockStatus.done && lectureBlock.getStatus() != LectureBlockStatus.cancelled) {
Date start = lectureBlock.getStartDate();
Date end = lectureBlock.getEndDate();
Date now = new Date();
if (start.compareTo(now) <= 0 && end.compareTo(now) >= 0) {
return true;
}
}
return false;
}
use of org.olat.modules.lecture.LectureBlock in project OpenOLAT by OpenOLAT.
the class LectureListRepositoryController method event.
@Override
protected void event(UserRequest ureq, Controller source, Event event) {
if (editLectureCtrl == source) {
if (event == Event.DONE_EVENT) {
loadModel();
}
cmc.deactivate();
cleanUp();
} else if (cmc == source) {
cleanUp();
} else if (toolsCalloutCtrl == source) {
cleanUp();
} else if (toolsCtrl == source) {
if (event == Event.DONE_EVENT) {
if (toolsCalloutCtrl != null) {
toolsCalloutCtrl.deactivate();
cleanUp();
}
}
} else if (deleteDialogCtrl == source) {
if (DialogBoxUIFactory.isYesEvent(event) || DialogBoxUIFactory.isOkEvent(event)) {
LectureBlockRow row = (LectureBlockRow) deleteDialogCtrl.getUserObject();
doDelete(row);
loadModel();
cleanUp();
}
} else if (bulkDeleteDialogCtrl == source) {
if (DialogBoxUIFactory.isYesEvent(event) || DialogBoxUIFactory.isOkEvent(event)) {
@SuppressWarnings("unchecked") List<LectureBlock> blocks = (List<LectureBlock>) bulkDeleteDialogCtrl.getUserObject();
doDelete(blocks);
loadModel();
cleanUp();
}
}
super.event(ureq, source, event);
}
Aggregations