Search in sources :

Example 11 with CourseEnvironment

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

the class PFNotifications method getItems.

public List<SubscriptionListItem> getItems() throws Exception {
    Publisher p = subscriber.getPublisher();
    Identity identity = subscriber.getIdentity();
    ICourse course = CourseFactory.loadCourse(p.getResId());
    CourseEnvironment courseEnv = course.getCourseEnvironment();
    CourseGroupManager groupManager = courseEnv.getCourseGroupManager();
    CourseNode node = course.getRunStructure().getNode(p.getSubidentifier());
    RepositoryEntry entry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
    Date latestNews = p.getLatestNewsDate();
    if (notificationsManager.isPublisherValid(p) && compareDate.before(latestNews)) {
        this.displayname = entry.getDisplayname();
        if (groupManager.isIdentityCourseCoach(identity) || groupManager.isIdentityCourseAdministrator(identity)) {
            List<Identity> participants = pfManager.getParticipants(identity, courseEnv, groupManager.isIdentityCourseAdministrator(identity));
            for (Identity participant : participants) {
                gatherItems(participant, p, courseEnv, node);
            }
        } else {
            gatherItems(identity, p, courseEnv, node);
        }
    }
    return items;
}
Also used : CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) ICourse(org.olat.course.ICourse) Publisher(org.olat.core.commons.services.notifications.Publisher) CourseNode(org.olat.course.nodes.CourseNode) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Date(java.util.Date)

Example 12 with CourseEnvironment

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

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 13 with CourseEnvironment

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

the class IQIdentityListCourseNodeController method doExportResults.

private void doExportResults(UserRequest ureq) {
    List<Identity> identities = getIdentities();
    if (identities != null && !identities.isEmpty()) {
        MediaResource resource;
        CourseEnvironment courseEnv = getCourseEnvironment();
        if (isTestQTI21()) {
            resource = new QTI21ResultsExportMediaResource(courseEnv, identities, (IQTESTCourseNode) courseNode, getLocale());
        } else {
            resource = new QTI12ResultsExportMediaResource(courseEnv, getLocale(), identities, (IQTESTCourseNode) courseNode);
        }
        ureq.getDispatchResult().setResultingMediaResource(resource);
    } else {
        showWarning("error.no.assessed.users");
    }
}
Also used : IQTESTCourseNode(org.olat.course.nodes.IQTESTCourseNode) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) QTI12ResultsExportMediaResource(org.olat.ims.qti.resultexport.QTI12ResultsExportMediaResource) MediaResource(org.olat.core.gui.media.MediaResource) QTI21ResultsExportMediaResource(org.olat.ims.qti21.resultexport.QTI21ResultsExportMediaResource) Identity(org.olat.core.id.Identity) QTI21ResultsExportMediaResource(org.olat.ims.qti21.resultexport.QTI21ResultsExportMediaResource) QTI12ResultsExportMediaResource(org.olat.ims.qti.resultexport.QTI12ResultsExportMediaResource)

Example 14 with CourseEnvironment

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

the class IQIdentityListCourseNodeController method doConfirmResetData.

private void doConfirmResetData(UserRequest ureq) {
    AssessmentToolOptions asOptions = getOptions();
    CourseEnvironment courseEnv = getCourseEnvironment();
    resetDataCtrl = new QTI21ResetDataController(ureq, getWindowControl(), courseEnv, asOptions, (IQTESTCourseNode) courseNode);
    listenTo(resetDataCtrl);
    String title = translate("tool.reset");
    cmc = new CloseableModalController(getWindowControl(), null, resetDataCtrl.getInitialComponent(), true, title, true);
    listenTo(cmc);
    cmc.activate();
}
Also used : IQTESTCourseNode(org.olat.course.nodes.IQTESTCourseNode) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) AssessmentToolOptions(org.olat.modules.assessment.AssessmentToolOptions) QTI21ResetDataController(org.olat.ims.qti21.ui.QTI21ResetDataController)

Example 15 with CourseEnvironment

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

the class CourseAssessmentWebService method importTestItems.

private void importTestItems(ICourse course, String nodeKey, Identity identity, AssessableResultsVO resultsVO) {
    try {
        IQManager iqManager = CoreSpringFactory.getImpl(IQManager.class);
        // load the course and the course node
        CourseNode courseNode = getParentNode(course, nodeKey);
        ModuleConfiguration modConfig = courseNode.getModuleConfiguration();
        // check if the result set is already saved
        QTIResultSet set = iqManager.getLastResultSet(identity, course.getResourceableId(), courseNode.getIdent());
        if (set == null) {
            String resourcePathInfo = course.getResourceableId() + File.separator + courseNode.getIdent();
            // The use of these classes AssessmentInstance, AssessmentContext and
            // Navigator
            // allow the use of the persistence mechanism of OLAT without
            // duplicating the code.
            // The consequence is that we must loop on section and items and set the
            // navigator on
            // the right position before submitting the inputs.
            AssessmentInstance ai = AssessmentFactory.createAssessmentInstance(identity, "", modConfig, false, course.getResourceableId(), courseNode.getIdent(), resourcePathInfo, null);
            Navigator navigator = ai.getNavigator();
            navigator.startAssessment();
            // The type of the navigator depends on the setting of the course node
            boolean perItem = (navigator instanceof MenuItemNavigator);
            Map<String, ItemInput> datas = convertToHttpItemInput(resultsVO.getResults());
            AssessmentContext ac = ai.getAssessmentContext();
            int sectioncnt = ac.getSectionContextCount();
            // loop on the sections
            for (int i = 0; i < sectioncnt; i++) {
                SectionContext sc = ac.getSectionContext(i);
                navigator.goToSection(i);
                ItemsInput iips = new ItemsInput();
                int itemcnt = sc.getItemContextCount();
                // loop on the items
                for (int j = 0; j < itemcnt; j++) {
                    ItemContext it = sc.getItemContext(j);
                    if (datas.containsKey(it.getIdent())) {
                        if (perItem) {
                            // save the datas on a per item base
                            navigator.goToItem(i, j);
                            // the navigator can give informations on its current status
                            Info info = navigator.getInfo();
                            if (info.containsError()) {
                            // some items cannot processed twice
                            } else {
                                iips.addItemInput(datas.get(it.getIdent()));
                                navigator.submitItems(iips);
                                iips = new ItemsInput();
                            }
                        } else {
                            // put for a section
                            iips.addItemInput(datas.get(it.getIdent()));
                        }
                    }
                }
                if (!perItem) {
                    // save the inputs of the section. In a section based navigation,
                    // we must saved the inputs of the whole section at once
                    navigator.submitItems(iips);
                }
            }
            navigator.submitAssessment();
            // persist the QTIResultSet (o_qtiresultset and o_qtiresult) on the
            // database
            // TODO iqManager.persistResults(ai, course.getResourceableId(),
            // courseNode.getIdent(), identity, "127.0.0.1");
            // write the reporting file on the file system
            // The path is <olatdata> / resreporting / <username> / Assessment /
            // <assessId>.xml
            // TODO Document docResReporting = iqManager.getResultsReporting(ai,
            // identity, Locale.getDefault());
            // TODO FilePersister.createResultsReporting(docResReporting, identity,
            // ai.getFormattedType(), ai.getAssessID());
            // prepare all instances needed to save the score at the course node
            // level
            CourseEnvironment cenv = course.getCourseEnvironment();
            IdentityEnvironment identEnv = new IdentityEnvironment();
            identEnv.setIdentity(identity);
            UserCourseEnvironment userCourseEnv = new UserCourseEnvironmentImpl(identEnv, cenv);
            // update scoring overview for the user in the current course
            Float score = ac.getScore();
            Boolean passed = ac.isPassed();
            // perhaps don't pass this key directly
            ScoreEvaluation sceval = new ScoreEvaluation(score, passed, passed, new Long(nodeKey));
            AssessableCourseNode acn = (AssessableCourseNode) courseNode;
            // assessment nodes are assessable
            boolean incrementUserAttempts = true;
            acn.updateUserScoreEvaluation(sceval, userCourseEnv, identity, incrementUserAttempts, Role.coach);
        } else {
            log.error("Result set already saved");
        }
    } catch (Exception e) {
        log.error("", e);
    }
}
Also used : SectionContext(org.olat.ims.qti.container.SectionContext) ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) HttpItemInput(org.olat.ims.qti.container.HttpItemInput) ItemInput(org.olat.ims.qti.container.ItemInput) ItemsInput(org.olat.ims.qti.container.ItemsInput) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) AssessmentInstance(org.olat.ims.qti.process.AssessmentInstance) CourseNode(org.olat.course.nodes.CourseNode) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) IQTESTCourseNode(org.olat.course.nodes.IQTESTCourseNode) IdentityEnvironment(org.olat.core.id.IdentityEnvironment) IQManager(org.olat.modules.iq.IQManager) ModuleConfiguration(org.olat.modules.ModuleConfiguration) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) Navigator(org.olat.ims.qti.navigator.Navigator) MenuItemNavigator(org.olat.ims.qti.navigator.MenuItemNavigator) Info(org.olat.ims.qti.navigator.Info) WebApplicationException(javax.ws.rs.WebApplicationException) QTIResultSet(org.olat.ims.qti.QTIResultSet) MenuItemNavigator(org.olat.ims.qti.navigator.MenuItemNavigator) AssessmentContext(org.olat.ims.qti.container.AssessmentContext) ItemContext(org.olat.ims.qti.container.ItemContext) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl)

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