Search in sources :

Example 56 with CourseEnvironment

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

the class BulkAssessmentTask method getReturnBox.

/**
 * Return the target folder of the assessed identity. This is a factory method which take care
 * of the type of the course node.
 *
 * @param uce
 * @param courseNode
 * @param identity
 * @return
 */
private VFSContainer getReturnBox(UserCourseEnvironment uce, CourseNode courseNode, Identity identity) {
    VFSContainer returnContainer = null;
    if (courseNode instanceof GTACourseNode) {
        final GTAManager gtaManager = CoreSpringFactory.getImpl(GTAManager.class);
        CourseEnvironment courseEnv = uce.getCourseEnvironment();
        returnContainer = gtaManager.getCorrectionContainer(courseEnv, (GTACourseNode) courseNode, identity);
    } else {
        String returnPath = ReturnboxController.getReturnboxPathRelToFolderRoot(uce.getCourseEnvironment(), courseNode);
        OlatRootFolderImpl rootFolder = new OlatRootFolderImpl(returnPath, null);
        VFSItem assessedItem = rootFolder.resolve(identity.getName());
        if (assessedItem == null) {
            returnContainer = rootFolder.createChildContainer(identity.getName());
        } else if (assessedItem instanceof VFSContainer) {
            returnContainer = (VFSContainer) assessedItem;
        }
    }
    return returnContainer;
}
Also used : OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) VFSContainer(org.olat.core.util.vfs.VFSContainer) GTACourseNode(org.olat.course.nodes.GTACourseNode) GTAManager(org.olat.course.nodes.gta.GTAManager) VFSItem(org.olat.core.util.vfs.VFSItem)

Example 57 with CourseEnvironment

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

the class ScormResultDetailsController method event.

@Override
public void event(UserRequest ureq, Controller source, Event event) {
    if (source == summaryTableCtr) {
        TableEvent tEvent = (TableEvent) event;
        if (tEvent.getActionId().equals("sel")) {
            TableGuiConfiguration tableConfig = new TableGuiConfiguration();
            tableConfig.setPreferencesOffered(true, "scormAssessmentDetails");
            removeAsListenerAndDispose(cmiTableCtr);
            cmiTableCtr = new TableController(tableConfig, ureq, getWindowControl(), getTranslator());
            listenTo(cmiTableCtr);
            cmiTableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cmis.column.header.itemId", 0, null, ureq.getLocale()));
            cmiTableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cmis.column.header.translatedKey", 1, null, ureq.getLocale()));
            cmiTableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cmis.column.header.key", 2, null, ureq.getLocale()));
            cmiTableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cmis.column.header.value", 3, null, ureq.getLocale()));
            // <BPS-252> BPS-252_3
            int rowId = tEvent.getRowId();
            List<CmiData> data = ((SummaryTableDataModelMultiResults) summaryTableCtr.getTableDataModel()).getObject(rowId);
            cmiTableCtr.setTableDataModel(new CmiTableDataModel(getTranslator(), data));
            // </BPS-252> BPS-252_3
            removeAsListenerAndDispose(cmc);
            cmc = new CloseableModalController(getWindowControl(), translate("close"), cmiTableCtr.getInitialComponent());
            listenTo(cmc);
            cmc.activate();
        }
    } else if (source == resetConfirmationBox) {
        if (DialogBoxUIFactory.isOkEvent(event)) {
            // delete scorm
            String username = assessedUserCourseEnv.getIdentityEnvironment().getIdentity().getName();
            CourseEnvironment courseEnv = assessedUserCourseEnv.getCourseEnvironment();
            ScormAssessmentManager.getInstance().deleteResults(username, courseEnv, node);
            fireEvent(ureq, Event.DONE_EVENT);
        }
    }
}
Also used : TableEvent(org.olat.core.gui.components.table.TableEvent) CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) TableController(org.olat.core.gui.components.table.TableController) TableGuiConfiguration(org.olat.core.gui.components.table.TableGuiConfiguration) DefaultColumnDescriptor(org.olat.core.gui.components.table.DefaultColumnDescriptor)

Example 58 with CourseEnvironment

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

the class ScormResultDetailsController method init.

protected void init(UserRequest ureq) {
    main = createVelocityContainer("scores");
    TableGuiConfiguration summaryTableConfig = new TableGuiConfiguration();
    summaryTableConfig.setDownloadOffered(true);
    summaryTableCtr = new TableController(summaryTableConfig, ureq, getWindowControl(), getTranslator());
    summaryTableCtr.addColumnDescriptor(new DefaultColumnDescriptor("summary.column.header.date", 0, null, ureq.getLocale()));
    summaryTableCtr.addColumnDescriptor(new DefaultColumnDescriptor("summary.column.header.duration", 1, null, ureq.getLocale()));
    summaryTableCtr.addColumnDescriptor(new DefaultColumnDescriptor("summary.column.header.assesspoints", 2, null, ureq.getLocale()));
    summaryTableCtr.addColumnDescriptor(new StaticColumnDescriptor("sel", "summary.column.header.details", getTranslator().translate("select")));
    CourseEnvironment courseEnv = assessedUserCourseEnv.getCourseEnvironment();
    String username = assessedUserCourseEnv.getIdentityEnvironment().getIdentity().getName();
    // <OLATCE-289>
    Map<Date, List<CmiData>> rawDatas = ScormAssessmentManager.getInstance().visitScoDatasMultiResults(username, courseEnv, node);
    summaryTableCtr.setTableDataModel(new SummaryTableDataModelMultiResults(rawDatas));
    // </OLATCE-289>
    listenTo(summaryTableCtr);
    main.put("summary", summaryTableCtr.getInitialComponent());
    if (!coachCourseEnv.isCourseReadOnly()) {
        resetButton = LinkFactory.createButton("reset", main, this);
        main.put("resetButton", resetButton);
    }
    putInitialPanel(main);
}
Also used : CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) TableController(org.olat.core.gui.components.table.TableController) StaticColumnDescriptor(org.olat.core.gui.components.table.StaticColumnDescriptor) List(java.util.List) TableGuiConfiguration(org.olat.core.gui.components.table.TableGuiConfiguration) DefaultColumnDescriptor(org.olat.core.gui.components.table.DefaultColumnDescriptor) Date(java.util.Date)

Example 59 with CourseEnvironment

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

the class WikiPageChangeOrCreateNotificationHandler method createSubscriptionInfo.

/**
 * @see org.olat.core.commons.services.notifications.NotificationsHandler#createSubscriptionInfo(org.olat.core.commons.services.notifications.Subscriber,
 *      java.util.Locale, java.util.Date)
 */
@Override
public SubscriptionInfo createSubscriptionInfo(Subscriber subscriber, final Locale locale, Date compareDate) {
    Publisher p = subscriber.getPublisher();
    final Date latestNews = p.getLatestNewsDate();
    Long resId = p.getResId();
    SubscriptionInfo si;
    final boolean debug = log.isDebug();
    // there could be news for me, investigate deeper
    if (debug)
        log.debug("compareDate=" + compareDate + " ; latestNews=" + latestNews, null);
    try {
        if (NotificationsManager.getInstance().isPublisherValid(p) && compareDate.before(latestNews)) {
            OLATResourceable ores = null;
            if (p.getResName().equals(CourseModule.getCourseTypeName())) {
                // resId = CourseResourceableId           p.getSubidentifier() = wikiCourseNode.getIdent()
                ICourse course = CourseFactory.loadCourse(resId);
                if (!courseStatus(course)) {
                    return NotificationsManager.getInstance().getNoSubscriptionInfo();
                }
                CourseEnvironment cenv = course.getCourseEnvironment();
                CourseNode courseNode = cenv.getRunStructure().getNode(p.getSubidentifier());
                if (courseNode == null) {
                    // OLAT-3356 because removing wikicoursenodes was not propagated to
                    // disable subcriptions, we may end up here with a NULL wikicoursenode
                    // Best we can do here -> return noSubsInfo and clean up
                    NotificationsManager.getInstance().deactivate(p);
                    // return nothing available
                    return NotificationsManager.getInstance().getNoSubscriptionInfo();
                }
                ModuleConfiguration config = ((WikiCourseNode) courseNode).getModuleConfiguration();
                RepositoryEntry re = WikiEditController.getWikiRepoReference(config, true);
                resId = re.getOlatResource().getResourceableId();
                if (debug)
                    log.debug("resId=" + resId, null);
                ores = OresHelper.createOLATResourceableInstance(WikiResource.TYPE_NAME, resId);
                businessControlString = p.getBusinessPath() + "[path=";
            } else {
                // resName = 'BusinessGroup' or 'FileResource.WIKI'
                if (debug)
                    log.debug("p.getResName()=" + p.getResName(), null);
                ores = OresHelper.createOLATResourceableInstance(p.getResName(), resId);
                businessControlString = p.getBusinessPath() + "[path=";
            }
            Wiki wiki = WikiManager.getInstance().getOrLoadWiki(ores);
            final List<WikiPage> pages = wiki.getPagesByDate();
            Translator translator = Util.createPackageTranslator(WikiPageChangeOrCreateNotificationHandler.class, locale);
            Translator forumTranslator = Util.createPackageTranslator(ForumNotificationsHandler.class, locale);
            TitleItem title = getTitleItem(p, translator);
            si = new SubscriptionInfo(subscriber.getKey(), p.getType(), title, null);
            for (Iterator<WikiPage> it = pages.listIterator(); it.hasNext(); ) {
                WikiPage element = it.next();
                // do only show entries newer then the ones already seen
                Date modDate = new Date(element.getModificationTime());
                if (debug)
                    log.debug("modDate=" + modDate + " ; compareDate=" + compareDate, null);
                if (modDate.after(compareDate)) {
                    if ((element.getPageName().startsWith("O_") || element.getPageName().startsWith(WikiPage.WIKI_MENU_PAGE)) && (element.getModifyAuthor() <= 0)) {
                        // theses pages are created sometimes automatically. Check if this is the case
                        continue;
                    }
                    // build Businesscontrol-Path
                    String businessPath = null;
                    String urlToSend = null;
                    if (p.getBusinessPath() != null) {
                        businessPath = businessControlString + element.getPageName() + "]";
                        urlToSend = BusinessControlFactory.getInstance().getURLFromBusinessPathString(businessPath);
                    }
                    // string[] gets filled into translation key by adding {0...n} to
                    // the string
                    Identity ident = BaseSecurityManager.getInstance().loadIdentityByKey(Long.valueOf(element.getModifyAuthor()));
                    String desc = translator.translate("notifications.entry", new String[] { element.getPageName(), NotificationHelper.getFormatedName(ident) });
                    SubscriptionListItem subListItem = new SubscriptionListItem(desc, urlToSend, businessPath, modDate, CSS_CLASS_WIKI_PAGE_CHANGED_ICON);
                    si.addSubscriptionListItem(subListItem);
                }
                long forumKey = element.getForumKey();
                List<Message> mInfos = ForumManager.getInstance().getNewMessageInfo(forumKey, compareDate);
                for (Message mInfo : mInfos) {
                    String messageTitle = mInfo.getTitle();
                    Identity creator = mInfo.getCreator();
                    Identity modifier = mInfo.getModifier();
                    Date messageModDate = mInfo.getLastModified();
                    String name;
                    if (modifier != null) {
                        name = NotificationHelper.getFormatedName(modifier);
                    } else {
                        name = NotificationHelper.getFormatedName(creator);
                    }
                    final String descKey = "notifications.entry" + (mInfo.getCreationDate().equals(messageModDate) ? "" : ".modified");
                    final String desc = forumTranslator.translate(descKey, new String[] { messageTitle, name });
                    String urlToSend = null;
                    String businessPath = null;
                    if (p.getBusinessPath() != null) {
                        businessPath = businessControlString + element.getPageName() + "][message:" + mInfo.getKey().toString() + "]";
                        urlToSend = BusinessControlFactory.getInstance().getURLFromBusinessPathString(businessPath);
                    }
                    SubscriptionListItem subListItem = new SubscriptionListItem(desc, urlToSend, businessPath, messageModDate, CSS_CLASS_WIKI_PAGE_CHANGED_ICON);
                    si.addSubscriptionListItem(subListItem);
                }
            }
        } else {
            // no news
            si = NotificationsManager.getInstance().getNoSubscriptionInfo();
        }
    } catch (Exception e) {
        log.error("Error creating wiki's notifications for subscriber: " + subscriber.getKey(), e);
        checkPublisher(p);
        si = NotificationsManager.getInstance().getNoSubscriptionInfo();
    }
    return si;
}
Also used : Message(org.olat.modules.fo.Message) OLATResourceable(org.olat.core.id.OLATResourceable) SubscriptionInfo(org.olat.core.commons.services.notifications.SubscriptionInfo) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) TitleItem(org.olat.core.commons.services.notifications.model.TitleItem) SubscriptionListItem(org.olat.core.commons.services.notifications.model.SubscriptionListItem) Translator(org.olat.core.gui.translator.Translator) CourseNode(org.olat.course.nodes.CourseNode) WikiCourseNode(org.olat.course.nodes.WikiCourseNode) Identity(org.olat.core.id.Identity) WikiCourseNode(org.olat.course.nodes.WikiCourseNode) ModuleConfiguration(org.olat.modules.ModuleConfiguration) CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) Publisher(org.olat.core.commons.services.notifications.Publisher) Date(java.util.Date)

Example 60 with CourseEnvironment

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

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