Search in sources :

Example 96 with LectureBlock

use of org.olat.modules.lecture.LectureBlock in project openolat by klemens.

the class LectureServiceImpl method copyLectureBlock.

@Override
public LectureBlock copyLectureBlock(String newTitle, LectureBlock block) {
    LectureBlock copy = lectureBlockDao.createLectureBlock(block.getEntry());
    copy.setTitle(newTitle);
    copy.setDescription(block.getDescription());
    copy.setPreparation(block.getPreparation());
    copy.setLocation(block.getLocation());
    copy.setRollCallStatus(LectureRollCallStatus.open);
    copy.setEffectiveLecturesNumber(block.getEffectiveLecturesNumber());
    copy.setPlannedLecturesNumber(block.getPlannedLecturesNumber());
    copy.setStartDate(block.getStartDate());
    copy.setEndDate(block.getEndDate());
    copy = lectureBlockDao.update(copy);
    return copy;
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock)

Example 97 with LectureBlock

use of org.olat.modules.lecture.LectureBlock in project openolat by klemens.

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());
}
Also used : Util(org.olat.core.util.Util) LectureParticipantSummary(org.olat.modules.lecture.LectureParticipantSummary) LectureBlockRollCallSearchParameters(org.olat.modules.lecture.LectureBlockRollCallSearchParameters) Date(java.util.Date) I18nManager(org.olat.core.util.i18n.I18nManager) RepositoryEntryRef(org.olat.repository.RepositoryEntryRef) LectureBlockAuditLog(org.olat.modules.lecture.LectureBlockAuditLog) Autowired(org.springframework.beans.factory.annotation.Autowired) IdentityRef(org.olat.basesecurity.IdentityRef) MailContextImpl(org.olat.core.util.mail.MailContextImpl) RepositoryEntryLectureConfiguration(org.olat.modules.lecture.RepositoryEntryLectureConfiguration) Locale(java.util.Locale) GroupDAO(org.olat.basesecurity.manager.GroupDAO) Map(java.util.Map) Group(org.olat.basesecurity.Group) LectureBlockToGroup(org.olat.modules.lecture.LectureBlockToGroup) LectureBlockStatistics(org.olat.modules.lecture.model.LectureBlockStatistics) MailTemplate(org.olat.core.util.mail.MailTemplate) KalendarEvent(org.olat.commons.calendar.model.KalendarEvent) OLog(org.olat.core.logging.OLog) Translator(org.olat.core.gui.translator.Translator) LectureBlock(org.olat.modules.lecture.LectureBlock) LectureBlockWithTeachers(org.olat.modules.lecture.model.LectureBlockWithTeachers) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler) Set(java.util.Set) LectureBlockImpl(org.olat.modules.lecture.model.LectureBlockImpl) UUID(java.util.UUID) AggregatedLectureBlocksStatistics(org.olat.modules.lecture.model.AggregatedLectureBlocksStatistics) Collectors(java.util.stream.Collectors) VelocityContext(org.apache.velocity.VelocityContext) MailManager(org.olat.core.util.mail.MailManager) LectureService(org.olat.modules.lecture.LectureService) List(java.util.List) Identity(org.olat.core.id.Identity) ParticipantAndLectureSummary(org.olat.modules.lecture.model.ParticipantAndLectureSummary) IdentityImpl(org.olat.basesecurity.IdentityImpl) MailContext(org.olat.core.util.mail.MailContext) LectureBlockIdentityStatistics(org.olat.modules.lecture.model.LectureBlockIdentityStatistics) Settings(org.olat.core.helpers.Settings) MailBundle(org.olat.core.util.mail.MailBundle) LectureBlockAndRollCall(org.olat.modules.lecture.model.LectureBlockAndRollCall) Action(org.olat.modules.lecture.LectureBlockAuditLog.Action) HashMap(java.util.HashMap) CalendarManagedFlag(org.olat.commons.calendar.CalendarManagedFlag) Reason(org.olat.modules.lecture.Reason) RepositoryEntry(org.olat.repository.RepositoryEntry) LecturesBlockSearchParameters(org.olat.modules.lecture.model.LecturesBlockSearchParameters) ArrayList(java.util.ArrayList) Kalendar(org.olat.commons.calendar.model.Kalendar) HashSet(java.util.HashSet) Calendar(java.util.Calendar) Service(org.springframework.stereotype.Service) StringHelper(org.olat.core.util.StringHelper) LectureBlockRollCall(org.olat.modules.lecture.LectureBlockRollCall) RepositoryEntryDAO(org.olat.repository.manager.RepositoryEntryDAO) LectureBlockToTeacher(org.olat.modules.lecture.model.LectureBlockToTeacher) CalendarManager(org.olat.commons.calendar.CalendarManager) LectureBlockRef(org.olat.modules.lecture.LectureBlockRef) LectureBlockStatus(org.olat.modules.lecture.LectureBlockStatus) LectureStatisticsSearchParameters(org.olat.modules.lecture.model.LectureStatisticsSearchParameters) Formatter(org.olat.core.util.Formatter) MailerResult(org.olat.core.util.mail.MailerResult) LectureAdminController(org.olat.modules.lecture.ui.LectureAdminController) LectureModule(org.olat.modules.lecture.LectureModule) Iterator(java.util.Iterator) LectureBlockRollCallRef(org.olat.modules.lecture.LectureBlockRollCallRef) File(java.io.File) UserManager(org.olat.user.UserManager) DB(org.olat.core.commons.persistence.DB) BusinessGroup(org.olat.group.BusinessGroup) DeletableGroupData(org.olat.group.DeletableGroupData) LectureRollCallStatus(org.olat.modules.lecture.LectureRollCallStatus) Tracing(org.olat.core.logging.Tracing) ConfigurationHelper(org.olat.modules.lecture.ui.ConfigurationHelper) UserDataDeletable(org.olat.user.UserDataDeletable) ParticipantAndLectureSummary(org.olat.modules.lecture.model.ParticipantAndLectureSummary) ArrayList(java.util.ArrayList) Date(java.util.Date) LectureBlockRollCall(org.olat.modules.lecture.LectureBlockRollCall) Identity(org.olat.core.id.Identity) HashSet(java.util.HashSet)

Example 98 with LectureBlock

use of org.olat.modules.lecture.LectureBlock in project openolat by klemens.

the class ParticipantLectureBlocksController method doAppeal.

private void doAppeal(UserRequest ureq, LectureBlockAndRollCall row) {
    if (appealCtrl != null)
        return;
    LectureBlock block = lectureService.getLectureBlock(row.getLectureBlockRef());
    List<Identity> teachers = lectureService.getTeachers(block);
    List<Identity> onwers = repositoryService.getMembers(entry, GroupRoles.owner.name());
    ContactList contactList = new ContactList(translate("appeal.contact.list"));
    contactList.addAllIdentites(teachers);
    contactList.addAllIdentites(onwers);
    StringBuilder teacherNames = new StringBuilder();
    for (Identity teacher : teachers) {
        if (teacherNames.length() > 0)
            teacherNames.append(", ");
        teacherNames.append(teacher.getUser().getFirstName()).append(" ").append(teacher.getUser().getLastName());
    }
    String date = Formatter.getInstance(getLocale()).formatDate(block.getStartDate());
    String[] args = new String[] { row.getLectureBlockTitle(), teacherNames.toString(), date };
    ContactMessage cmsg = new ContactMessage(getIdentity());
    cmsg.addEmailTo(contactList);
    cmsg.setSubject(translate("appeal.subject", args));
    cmsg.setBodyText(translate("appeal.body", args));
    appealCtrl = new ContactFormController(ureq, getWindowControl(), true, false, false, cmsg);
    appealCtrl.setUserObject(row);
    appealCtrl.setContactFormTitle(translate("new.appeal.title"));
    listenTo(appealCtrl);
    String title = translate("appeal.title", new String[] { row.getLectureBlockTitle() });
    cmc = new CloseableModalController(getWindowControl(), "close", appealCtrl.getInitialComponent(), true, title);
    listenTo(cmc);
    cmc.activate();
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) ContactFormController(org.olat.modules.co.ContactFormController) ContactList(org.olat.core.util.mail.ContactList) Identity(org.olat.core.id.Identity) ContactMessage(org.olat.core.util.mail.ContactMessage)

Example 99 with LectureBlock

use of org.olat.modules.lecture.LectureBlock in project openolat by klemens.

the class LectureListRepositoryController method doEditLectureBlock.

private void doEditLectureBlock(UserRequest ureq, LectureBlockRow row) {
    if (editLectureCtrl != null)
        return;
    LectureBlock block = lectureService.getLectureBlock(row);
    editLectureCtrl = new EditLectureBlockController(ureq, getWindowControl(), entry, block);
    listenTo(editLectureCtrl);
    cmc = new CloseableModalController(getWindowControl(), "close", editLectureCtrl.getInitialComponent(), true, translate("add.lecture"));
    listenTo(cmc);
    cmc.activate();
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)

Example 100 with LectureBlock

use of org.olat.modules.lecture.LectureBlock in project openolat by klemens.

the class LectureListRepositoryController method doDelete.

private void doDelete(List<LectureBlock> blocks) {
    for (LectureBlock block : blocks) {
        lectureService.deleteLectureBlock(block);
        logAudit("Lecture block deleted: " + block, null);
        ThreadLocalUserActivityLogger.log(LearningResourceLoggingAction.LECTURE_BLOCK_DELETED, getClass(), CoreLoggingResourceable.wrap(block, OlatResourceableType.lectureBlock, block.getTitle()));
    }
    showInfo("lecture.deleted");
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock)

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