Search in sources :

Example 26 with AssessableCourseNode

use of org.olat.course.nodes.AssessableCourseNode in project OpenOLAT by OpenOLAT.

the class IQRunController method submitAssessment.

@Override
public void submitAssessment(AssessmentInstance ai) {
    if (type.equals(AssessmentInstance.QMD_ENTRY_TYPE_ASSESS)) {
        AssessmentContext ac = ai.getAssessmentContext();
        AssessmentManager am = userCourseEnv.getCourseEnvironment().getAssessmentManager();
        Boolean fullyAssed = am.getNodeFullyAssessed(courseNode, getIdentity());
        String correctionMode = courseNode.getModuleConfiguration().getStringValue(IQEditController.CONFIG_CORRECTION_MODE);
        Boolean userVisibility;
        AssessmentEntryStatus assessmentStatus;
        if (IQEditController.CORRECTION_MANUAL.equals(correctionMode)) {
            assessmentStatus = AssessmentEntryStatus.inReview;
            userVisibility = Boolean.FALSE;
        } else {
            assessmentStatus = AssessmentEntryStatus.done;
            userVisibility = Boolean.TRUE;
        }
        ScoreEvaluation sceval = new ScoreEvaluation(ac.getScore(), ac.isPassed(), assessmentStatus, userVisibility, fullyAssed, null, null, ai.getAssessID());
        // assessment nodes are assessable
        AssessableCourseNode acn = (AssessableCourseNode) courseNode;
        acn.updateUserScoreEvaluation(sceval, userCourseEnv, getIdentity(), true, Role.user);
        // Mark publisher for notifications
        Long courseId = userCourseEnv.getCourseEnvironment().getCourseResourceableId();
        assessmentNotificationsHandler.markPublisherNews(getIdentity(), courseId);
        if (!assessmentStopped) {
            assessmentStopped = true;
            AssessmentEvent assessmentStoppedEvent = new AssessmentEvent(AssessmentEvent.TYPE.STOPPED, userSession);
            singleUserEventCenter.deregisterFor(this, assessmentInstanceOres);
            singleUserEventCenter.fireEventToListenersOf(assessmentStoppedEvent, assessmentEventOres);
        }
    } else if (type.equals(AssessmentInstance.QMD_ENTRY_TYPE_SURVEY)) {
        // save number of attempts
        // although this is not an assessable node we still use the assessment
        // manager since this one uses caching
        AssessmentManager am = userCourseEnv.getCourseEnvironment().getAssessmentManager();
        am.incrementNodeAttempts(courseNode, getIdentity(), userCourseEnv, Role.user);
    } else if (type.equals(AssessmentInstance.QMD_ENTRY_TYPE_SELF)) {
        AssessmentManager am = userCourseEnv.getCourseEnvironment().getAssessmentManager();
        am.incrementNodeAttempts(courseNode, getIdentity(), userCourseEnv, Role.user);
    }
}
Also used : AssessmentContext(org.olat.ims.qti.container.AssessmentContext) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) PersistentAssessableCourseNode(org.olat.course.nodes.PersistentAssessableCourseNode) SelfAssessableCourseNode(org.olat.course.nodes.SelfAssessableCourseNode) ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) AssessmentManager(org.olat.course.assessment.AssessmentManager) AssessmentEntryStatus(org.olat.modules.assessment.model.AssessmentEntryStatus)

Example 27 with AssessableCourseNode

use of org.olat.course.nodes.AssessableCourseNode in project OpenOLAT by OpenOLAT.

the class CourseAssessmentWebService method getRootResult.

private AssessableResultsVO getRootResult(Identity identity, ICourse course, CourseNode courseNode) {
    AssessableResultsVO results = new AssessableResultsVO();
    results.setIdentityKey(identity.getKey());
    // create an identenv with no roles, no attributes, no locale
    IdentityEnvironment ienv = new IdentityEnvironment();
    ienv.setIdentity(identity);
    UserCourseEnvironment userCourseEnvironment = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
    // Fetch all score and passed and calculate score accounting for the entire course
    ScoreAccounting scoreAccounting = userCourseEnvironment.getScoreAccounting();
    scoreAccounting.evaluateAll();
    if (courseNode instanceof AssessableCourseNode) {
        AssessableCourseNode assessableRootNode = (AssessableCourseNode) courseNode;
        ScoreEvaluation scoreEval = scoreAccounting.evalCourseNode(assessableRootNode);
        results.setScore(scoreEval.getScore());
        results.setPassed(scoreEval.getPassed());
        results.setLastModifiedDate(getLastModificationDate(identity, course, courseNode));
    }
    return results;
}
Also used : AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) AssessableResultsVO(org.olat.restapi.support.vo.AssessableResultsVO) ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) ScoreAccounting(org.olat.course.run.scoring.ScoreAccounting) IdentityEnvironment(org.olat.core.id.IdentityEnvironment)

Example 28 with AssessableCourseNode

use of org.olat.course.nodes.AssessableCourseNode 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)

Example 29 with AssessableCourseNode

use of org.olat.course.nodes.AssessableCourseNode in project OpenOLAT by OpenOLAT.

the class CourseAssessmentWebService method attachAssessableResults.

private void attachAssessableResults(Long courseResourceableId, String nodeKey, Identity requestIdentity, AssessableResultsVO resultsVO) {
    try {
        ICourse course = CourseFactory.openCourseEditSession(courseResourceableId);
        CourseNode node = getParentNode(course, nodeKey);
        if (!(node instanceof AssessableCourseNode)) {
            throw new IllegalArgumentException("The supplied node key does not refer to an AssessableCourseNode");
        }
        BaseSecurity securityManager = BaseSecurityManager.getInstance();
        Identity userIdentity = securityManager.loadIdentityByKey(resultsVO.getIdentityKey());
        // create an identenv with no roles, no attributes, no locale
        IdentityEnvironment ienv = new IdentityEnvironment();
        ienv.setIdentity(userIdentity);
        UserCourseEnvironment userCourseEnvironment = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
        // Fetch all score and passed and calculate score accounting for the
        // entire course
        userCourseEnvironment.getScoreAccounting().evaluateAll();
        if (node instanceof IQTESTCourseNode) {
            importTestItems(course, nodeKey, requestIdentity, resultsVO);
        } else {
            AssessableCourseNode assessableNode = (AssessableCourseNode) node;
            // not directly pass this key
            ScoreEvaluation scoreEval = new ScoreEvaluation(resultsVO.getScore(), Boolean.TRUE, Boolean.TRUE, new Long(nodeKey));
            assessableNode.updateUserScoreEvaluation(scoreEval, userCourseEnvironment, requestIdentity, true, Role.coach);
        }
        CourseFactory.saveCourseEditorTreeModel(course.getResourceableId());
        CourseFactory.closeCourseEditSession(course.getResourceableId(), true);
    } catch (Throwable e) {
        throw new WebApplicationException(e);
    }
}
Also used : ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) WebApplicationException(javax.ws.rs.WebApplicationException) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) ICourse(org.olat.course.ICourse) BaseSecurity(org.olat.basesecurity.BaseSecurity) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) IQTESTCourseNode(org.olat.course.nodes.IQTESTCourseNode) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) CourseNode(org.olat.course.nodes.CourseNode) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) IQTESTCourseNode(org.olat.course.nodes.IQTESTCourseNode) Identity(org.olat.core.id.Identity) IdentityEnvironment(org.olat.core.id.IdentityEnvironment)

Example 30 with AssessableCourseNode

use of org.olat.course.nodes.AssessableCourseNode in project OpenOLAT by OpenOLAT.

the class PassedRuleEditor method searchPassedNodes.

private void searchPassedNodes(CourseNode courseNode, List<CourseNode> nodes) {
    if (courseNode instanceof AssessableCourseNode) {
        AssessableCourseNode assessableCourseNode = (AssessableCourseNode) courseNode;
        if (assessableCourseNode.hasPassedConfigured()) {
            nodes.add(courseNode);
        }
    }
    for (int i = 0; i < courseNode.getChildCount(); i++) {
        CourseNode child = (CourseNode) courseNode.getChildAt(i);
        searchPassedNodes(child, nodes);
    }
}
Also used : AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) CourseNode(org.olat.course.nodes.CourseNode)

Aggregations

AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)118 CourseNode (org.olat.course.nodes.CourseNode)48 ICourse (org.olat.course.ICourse)40 Identity (org.olat.core.id.Identity)32 UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)28 ScoreEvaluation (org.olat.course.run.scoring.ScoreEvaluation)26 IdentityEnvironment (org.olat.core.id.IdentityEnvironment)22 UserCourseEnvironmentImpl (org.olat.course.run.userview.UserCourseEnvironmentImpl)22 Date (java.util.Date)20 IQTESTCourseNode (org.olat.course.nodes.IQTESTCourseNode)18 STCourseNode (org.olat.course.nodes.STCourseNode)18 ArrayList (java.util.ArrayList)16 AssessmentEntry (org.olat.modules.assessment.AssessmentEntry)16 CalculatedAssessableCourseNode (org.olat.course.nodes.CalculatedAssessableCourseNode)14 GTACourseNode (org.olat.course.nodes.GTACourseNode)12 File (java.io.File)10 IOException (java.io.IOException)10 WindowControl (org.olat.core.gui.control.WindowControl)10 MSCourseNode (org.olat.course.nodes.MSCourseNode)10 PersistentAssessableCourseNode (org.olat.course.nodes.PersistentAssessableCourseNode)10