Search in sources :

Example 16 with CourseEnvironment

use of org.olat.course.run.environment.CourseEnvironment in project OpenOLAT by OpenOLAT.

the class FinishCallback method execute.

@Override
public Step execute(UserRequest ureq, WindowControl wControl, StepsRunContext runContext) {
    FOCourseNode node = (FOCourseNode) runContext.get(SendMailStepForm.FORUM);
    ICourse course = (ICourse) runContext.get(SendMailStepForm.ICOURSE);
    CourseEnvironment courseEnv = course.getCourseEnvironment();
    Forum chosenforum = node.loadOrCreateForum(courseEnv);
    Message msg = (Message) runContext.get(SendMailStepForm.MESSAGE_TO_MOVE);
    msg = forumManager.getMessageById(msg.getKey());
    Message parentMessage = (Message) runContext.get(SendMailStepForm.PARENT_MESSAGE);
    if (parentMessage != null) {
        parentMessage = forumManager.getMessageById(parentMessage.getKey());
    }
    if (msg.getParentKey() == null && msg.getThreadtop() == null) {
        msg = forumManager.createOrAppendThreadInAnotherForum(msg, chosenforum, parentMessage);
    } else {
        msg = forumManager.moveMessageToAnotherForum(msg, chosenforum, parentMessage);
    }
    // commit before sending event
    DBFactory.getInstance().commit();
    if ((Boolean) runContext.get(SendMailStepForm.SENDMAIL)) {
        sendMail(ureq, wControl, runContext);
    }
    return StepsMainRunController.DONE_MODIFIED;
}
Also used : CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) Message(org.olat.modules.fo.Message) FOCourseNode(org.olat.course.nodes.FOCourseNode) ICourse(org.olat.course.ICourse) Forum(org.olat.modules.fo.Forum)

Example 17 with CourseEnvironment

use of org.olat.course.run.environment.CourseEnvironment in project OpenOLAT by OpenOLAT.

the class IQTESTCourseNode method archiveNodeData.

@Override
public boolean archiveNodeData(Locale locale, ICourse course, ArchiveOptions options, ZipOutputStream exportStream, String charset) {
    String repositorySoftKey = (String) getModuleConfiguration().get(IQEditController.CONFIG_KEY_REPOSITORY_SOFTKEY);
    Long courseResourceableId = course.getResourceableId();
    // 1) prepare result export
    CourseEnvironment courseEnv = course.getCourseEnvironment();
    try {
        RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntryBySoftkey(repositorySoftKey, true);
        boolean onyx = OnyxModule.isOnyxTest(re.getOlatResource());
        if (onyx) {
            return true;
        } else if (ImsQTI21Resource.TYPE_NAME.equals(re.getOlatResource().getResourceableTypeName())) {
            // 2a) create export resource
            List<Identity> identities = ScoreAccountingHelper.loadUsers(courseEnv, options);
            new QTI21ResultsExportMediaResource(courseEnv, identities, this, locale).exportTestResults(exportStream);
            // excel results
            RepositoryEntry courseEntry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
            QTI21StatisticSearchParams searchParams = new QTI21StatisticSearchParams(options, re, courseEntry, getIdent());
            QTI21ArchiveFormat qaf = new QTI21ArchiveFormat(locale, searchParams);
            qaf.exportCourseElement(exportStream);
            return true;
        } else {
            // 2b) create export resource
            List<Identity> identities = ScoreAccountingHelper.loadUsers(courseEnv, options);
            new QTI12ResultsExportMediaResource(courseEnv, locale, identities, this).exportTestResults(exportStream);
            // excel results
            String shortTitle = getShortTitle();
            QTIExportManager qem = QTIExportManager.getInstance();
            QTIExportFormatter qef = new QTIExportFormatterCSVType1(locale, "\t", "\"", "\r\n", false);
            if (options != null && options.getExportFormat() != null) {
                Map<Class<?>, QTIExportItemFormatConfig> itemConfigs = new HashMap<>();
                Class<?>[] itemTypes = new Class<?>[] { QTIExportSCQItemFormatConfig.class, QTIExportMCQItemFormatConfig.class, QTIExportKPRIMItemFormatConfig.class, QTIExportFIBItemFormatConfig.class, QTIExportEssayItemFormatConfig.class };
                for (Class<?> itemClass : itemTypes) {
                    itemConfigs.put(itemClass, new QTIExportItemFormatDelegate(options.getExportFormat()));
                }
                qef.setMapWithExportItemConfigs(itemConfigs);
            }
            return qem.selectAndExportResults(qef, courseResourceableId, shortTitle, getIdent(), re, exportStream, locale, ".xls");
        }
    } catch (IOException e) {
        log.error("", e);
        return false;
    }
}
Also used : UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) QTI21StatisticSearchParams(org.olat.ims.qti21.model.QTI21StatisticSearchParams) QTIExportFormatterCSVType1(org.olat.ims.qti.export.QTIExportFormatterCSVType1) RepositoryEntry(org.olat.repository.RepositoryEntry) QTIExportItemFormatDelegate(org.olat.ims.qti.export.QTIExportItemFormatDelegate) IOException(java.io.IOException) QTI21ResultsExportMediaResource(org.olat.ims.qti21.resultexport.QTI21ResultsExportMediaResource) QTI12ResultsExportMediaResource(org.olat.ims.qti.resultexport.QTI12ResultsExportMediaResource) QTIExportFormatter(org.olat.ims.qti.export.QTIExportFormatter) QTIExportManager(org.olat.ims.qti.export.QTIExportManager) List(java.util.List) QTI21ArchiveFormat(org.olat.ims.qti21.manager.archive.QTI21ArchiveFormat) Map(java.util.Map) HashMap(java.util.HashMap)

Example 18 with CourseEnvironment

use of org.olat.course.run.environment.CourseEnvironment in project OpenOLAT by OpenOLAT.

the class WikiEditController method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
 *      org.olat.core.gui.components.Component,
 *      org.olat.core.gui.control.Event)
 */
public void event(UserRequest ureq, Component source, Event event) {
    if (source == previewLink) {
        // Preview as modal dialogue only if the config is valid
        RepositoryEntry re = getWikiRepoReference(moduleConfiguration, false);
        if (re == null) {
            // we cannot preview it, because the repository entry
            // had been deleted between the time when it was
            // chosen here, and now
            this.showError("error.repoentrymissing");
        } else {
            // File cpRoot =
            // FileResourceManager.getInstance().unzipFileResource(re.getOlatResource());
            Identity ident = ureq.getIdentity();
            boolean isOlatAdmin = ureq.getUserSession().getRoles().isOLATAdmin();
            boolean isResourceOwner = RepositoryManager.getInstance().isOwnerOfRepositoryEntry(ident, re);
            CourseEnvironment cenv = course.getCourseEnvironment();
            SubscriptionContext subsContext = WikiManager.createTechnicalSubscriptionContextForCourse(cenv, wikiCourseNode);
            WikiSecurityCallback callback = new WikiSecurityCallbackImpl(null, isOlatAdmin, false, false, isResourceOwner, subsContext);
            wikiCtr = WikiManager.getInstance().createWikiMainController(ureq, getWindowControl(), re.getOlatResource(), callback, null);
            cmcWikiCtr = new CloseableModalController(getWindowControl(), translate("command.close"), wikiCtr.getInitialComponent());
            this.listenTo(cmcWikiCtr);
            cmcWikiCtr.activate();
        }
    } else if (source == chooseButton || source == changeButton) {
        searchController = new ReferencableEntriesSearchController(getWindowControl(), ureq, WikiResource.TYPE_NAME, translate("command.choose"));
        this.listenTo(searchController);
        cmcSearchController = new CloseableModalController(getWindowControl(), translate("close"), searchController.getInitialComponent(), true, translate("command.create"));
        cmcSearchController.activate();
    } else if (source == editLink) {
        RepositoryEntry repositoryEntry = wikiCourseNode.getReferencedRepositoryEntry();
        if (repositoryEntry == null) {
            // do nothing
            return;
        }
        String bPath = "[RepositoryEntry:" + repositoryEntry.getKey() + "][Editor:0]";
        NewControllerFactory.getInstance().launch(bPath, ureq, getWindowControl());
    }
}
Also used : WikiSecurityCallbackImpl(org.olat.modules.wiki.WikiSecurityCallbackImpl) CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) RepositoryEntry(org.olat.repository.RepositoryEntry) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) Identity(org.olat.core.id.Identity) WikiSecurityCallback(org.olat.modules.wiki.WikiSecurityCallback) ReferencableEntriesSearchController(org.olat.repository.controllers.ReferencableEntriesSearchController)

Example 19 with CourseEnvironment

use of org.olat.course.run.environment.CourseEnvironment in project OpenOLAT by OpenOLAT.

the class DropboxController method init.

protected void init(UserRequest ureq, WindowControl wControl, boolean previewMode, boolean hasNotification) {
    myContent = createVelocityContainer("dropbox");
    ulButton = LinkFactory.createButton("dropbox.upload", myContent, this);
    ulButton.setVisible(!userCourseEnv.isCourseReadOnly());
    if (!previewMode) {
        VFSContainer fDropbox = getDropBox(ureq.getIdentity());
        int numFiles = fDropbox.getItems().size();
        if (numFiles > 0)
            myContent.contextPut("numfiles", new String[] { Integer.toString(numFiles) });
    } else {
        myContent.contextPut("numfiles", "0");
    }
    myContent.contextPut("previewMode", previewMode ? Boolean.TRUE : Boolean.FALSE);
    // notification
    CourseEnvironment courseEnv = userCourseEnv.getCourseEnvironment();
    subsContext = DropboxFileUploadNotificationHandler.getSubscriptionContext(courseEnv, node);
    if (hasNotification && !previewMode) {
        // offer subscription, but not to guests
        if (subsContext != null) {
            String path = getDropboxPathRelToFolderRoot(courseEnv, node);
            contextualSubscriptionCtr = AbstractTaskNotificationHandler.createContextualSubscriptionController(ureq, wControl, path, subsContext, DropboxController.class);
            myContent.put("subscription", contextualSubscriptionCtr.getInitialComponent());
            myContent.contextPut("hasNotification", Boolean.TRUE);
        }
    } else {
        myContent.contextPut("hasNotification", Boolean.FALSE);
    }
    putInitialPanel(myContent);
}
Also used : UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) VFSContainer(org.olat.core.util.vfs.VFSContainer)

Example 20 with CourseEnvironment

use of org.olat.course.run.environment.CourseEnvironment in project OpenOLAT by OpenOLAT.

the class OLATUpgrade_11_2_1 method processTaskCourseNode.

private boolean processTaskCourseNode(ICourse course, RepositoryEntry entry, TACourseNode courseNode) {
    List<AssessmentEntry> assessmentEntries = getAssessmentEntries(entry, courseNode);
    if (assessmentEntries.size() > 0) {
        CourseEnvironment courseEnv = course.getCourseEnvironment();
        CoursePropertyManager cpm = courseEnv.getCoursePropertyManager();
        File dropbox = new File(FolderConfig.getCanonicalRoot(), DropboxController.getDropboxPathRelToFolderRoot(courseEnv, courseNode));
        File returnBox = new File(FolderConfig.getCanonicalRoot(), ReturnboxController.getReturnboxPathRelToFolderRoot(courseEnv, courseNode));
        for (AssessmentEntry assessmentEntry : assessmentEntries) {
            Identity assessedIdentity = assessmentEntry.getIdentity();
            boolean changed = false;
            List<Property> properties = cpm.findCourseNodeProperties(courseNode, assessedIdentity, null, TaskController.PROP_ASSIGNED);
            if (properties != null && properties.size() > 0) {
                assessmentEntry.setAssessmentStatus(AssessmentEntryStatus.inProgress);
            } else {
                File identityDropbox = new File(dropbox, assessedIdentity.getName());
                File identityReturnBox = new File(returnBox, assessedIdentity.getName());
                if (hasBoxedFiles(identityDropbox, identityReturnBox)) {
                    assessmentEntry.setAssessmentStatus(AssessmentEntryStatus.inProgress);
                }
            }
            if (changed) {
                courseEnv.getAssessmentManager().updateAssessmentEntry(assessmentEntry);
            }
        }
        dbInstance.commitAndCloseSession();
    }
    return true;
}
Also used : CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) Identity(org.olat.core.id.Identity) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) File(java.io.File) Property(org.olat.properties.Property) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager)

Aggregations

CourseEnvironment (org.olat.course.run.environment.CourseEnvironment)80 UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)64 RepositoryEntry (org.olat.repository.RepositoryEntry)34 Identity (org.olat.core.id.Identity)28 ICourse (org.olat.course.ICourse)18 VFSContainer (org.olat.core.util.vfs.VFSContainer)16 File (java.io.File)14 Date (java.util.Date)14 CourseNode (org.olat.course.nodes.CourseNode)14 Test (org.junit.Test)12 AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)12 BusinessGroup (org.olat.group.BusinessGroup)12 ModuleConfiguration (org.olat.modules.ModuleConfiguration)12 ArrayList (java.util.ArrayList)10 OlatRootFolderImpl (org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)10 IdentityEnvironment (org.olat.core.id.IdentityEnvironment)10 IQTESTCourseNode (org.olat.course.nodes.IQTESTCourseNode)10 Path (java.nio.file.Path)8 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)8 OLATResourceable (org.olat.core.id.OLATResourceable)8