Search in sources :

Example 11 with LectureBlock

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();
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) Group(org.olat.basesecurity.Group) RepositoryService(org.olat.repository.RepositoryService) Path(javax.ws.rs.Path) PUT(javax.ws.rs.PUT)

Example 12 with LectureBlock

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();
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) RestSecurityHelper.getRoles(org.olat.restapi.security.RestSecurityHelper.getRoles) Roles(org.olat.core.id.Roles) Produces(javax.ws.rs.Produces) Consumes(javax.ws.rs.Consumes) PUT(javax.ws.rs.PUT)

Example 13 with LectureBlock

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;
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock)

Example 14 with LectureBlock

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;
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) Date(java.util.Date)

Example 15 with LectureBlock

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);
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) List(java.util.List) ArrayList(java.util.ArrayList) LectureBlockRow(org.olat.modules.lecture.model.LectureBlockRow)

Aggregations

LectureBlock (org.olat.modules.lecture.LectureBlock)232 Identity (org.olat.core.id.Identity)132 Test (org.junit.Test)116 RepositoryEntry (org.olat.repository.RepositoryEntry)98 Date (java.util.Date)64 LectureBlockRollCall (org.olat.modules.lecture.LectureBlockRollCall)42 URI (java.net.URI)30 ArrayList (java.util.ArrayList)30 HttpResponse (org.apache.http.HttpResponse)30 Group (org.olat.basesecurity.Group)30 Calendar (java.util.Calendar)26 ICourse (org.olat.course.ICourse)24 BusinessGroup (org.olat.group.BusinessGroup)24 CourseConfigVO (org.olat.restapi.support.vo.CourseConfigVO)24 LectureBlockToGroup (org.olat.modules.lecture.LectureBlockToGroup)22 RepositoryEntryLectureConfiguration (org.olat.modules.lecture.RepositoryEntryLectureConfiguration)20 LecturesBlockSearchParameters (org.olat.modules.lecture.model.LecturesBlockSearchParameters)16 List (java.util.List)14 HttpGet (org.apache.http.client.methods.HttpGet)14 LectureBlockToTeacher (org.olat.modules.lecture.model.LectureBlockToTeacher)14