Search in sources :

Example 21 with AssessmentContext

use of org.olat.ims.qti.container.AssessmentContext in project OpenOLAT by OpenOLAT.

the class DefaultNavigator method submitMultipleItems.

public int submitMultipleItems(ItemsInput curitsinp) {
    // = submit a whole section at once
    if (info.getStatus() != QTIConstants.ASSESSMENT_RUNNING)
        throw new RuntimeException("assessment is NOT running yet or anymore");
    int cnt = curitsinp.getItemCount();
    if (cnt == 0)
        throw new RuntimeException("bug: not even one iteminput in the answer");
    AssessmentContext ac = getAssessmentContext();
    SectionContext sc = ac.getCurrentSectionContext();
    if (!ac.isOpen())
        return QTIConstants.ERROR_ASSESSMENT_OUTOFTIME;
    if (!sc.isOpen())
        return QTIConstants.ERROR_SUBMITTEDSECTION_OUTOFTIME;
    int sectionResult = QTIConstants.SECTION_SUBMITTED;
    for (Iterator<ItemInput> it_inp = curitsinp.getItemInputIterator(); it_inp.hasNext(); ) {
        ItemInput itemInput = it_inp.next();
        String ident = itemInput.getIdent();
        ItemContext ict = sc.getItemContext(ident);
        if (ict == null)
            throw new RuntimeException("submitted item id (" + ident + ") not found in section sectioncontext " + sc.getIdent());
        int subres = ict.addItemInput(itemInput);
        // to be up-to-date with the scores
        ict.eval();
        if (subres != QTIConstants.ITEM_SUBMITTED) {
            // item had a timelimit or maxattempts, which is nonsense if displaymode = sectionPage
            // throw new RuntimeException("section "+sc.getIdent()+" was submitted, but item "+ict.getIdent()+"  could not be submitted, because it had a timelimit or maxattempts, which is nonsense if displaymode = sectionPage");
            sectionResult = QTIConstants.ERROR_SECTION_PART_OUTOFTIME;
        }
    }
    return sectionResult;
}
Also used : SectionContext(org.olat.ims.qti.container.SectionContext) AssessmentContext(org.olat.ims.qti.container.AssessmentContext) ItemContext(org.olat.ims.qti.container.ItemContext) ItemInput(org.olat.ims.qti.container.ItemInput)

Example 22 with AssessmentContext

use of org.olat.ims.qti.container.AssessmentContext in project OpenOLAT by OpenOLAT.

the class DefaultNavigator method submitAssessment.

/**
 * @see org.olat.qti.process.Navigator#submitAssessment()
 */
public final void submitAssessment() {
    Output pendingOutput = null;
    boolean pendingFeedback = getInfo().isFeedback();
    boolean alreadyClosed = getAssessmentInstance().isClosed();
    if (pendingFeedback && getAssessmentInstance().getAssessmentContext().getCurrentSectionContext() != null) {
        ItemContext itc = getAssessmentInstance().getAssessmentContext().getCurrentSectionContext().getCurrentItemContext();
        pendingOutput = itc.getOutput();
    }
    getAssessmentInstance().stop();
    if (!getAssessmentInstance().isPreview() && !alreadyClosed) {
        CoreSpringFactory.getImpl(IQManager.class).persistResults(getAssessmentInstance());
    }
    AssessmentContext ac = getAssessmentContext();
    info.clear();
    if (ac.isFeedbackavailable()) {
        Output outp = ac.getOutput();
        getInfo().setCurrentOutput(outp);
        getInfo().setFeedback(true);
    } else if (pendingFeedback) {
        getInfo().setCurrentOutput(pendingOutput);
        getInfo().setFeedback(true);
    }
    // info.clear();
    info.setMessage(QTIConstants.MESSAGE_ASSESSMENT_SUBMITTED);
    info.setStatus(QTIConstants.ASSESSMENT_FINISHED);
    info.setRenderItems(false);
    if (delegate != null && !getAssessmentInstance().isPreview() && !alreadyClosed) {
        delegate.submitAssessment(assessmentInstance);
    }
    getAssessmentInstance().cleanUp();
}
Also used : ItemContext(org.olat.ims.qti.container.ItemContext) IQManager(org.olat.modules.iq.IQManager) AssessmentContext(org.olat.ims.qti.container.AssessmentContext) Output(org.olat.ims.qti.container.Output)

Example 23 with AssessmentContext

use of org.olat.ims.qti.container.AssessmentContext in project OpenOLAT by OpenOLAT.

the class MenuItemNavigator method goToSection.

/**
 * go to the section (not the item yet): display the objectives of the section
 * @see org.olat.qti.process.Navigator#goToSection(int)
 */
public void goToSection(int sectionPos) {
    if (getInfo().getStatus() != QTIConstants.ASSESSMENT_RUNNING)
        throw new RuntimeException("assessment is NOT running yet or anymore");
    clearInfo();
    AssessmentContext ac = getAssessmentContext();
    ac.setCurrentSectionContextPos(sectionPos);
    SectionContext sc = ac.getCurrentSectionContext();
    if (!ac.isOpen()) {
        getInfo().setError(QTIConstants.ERROR_ASSESSMENT_OUTOFTIME);
        getInfo().setRenderItems(false);
    } else if (!sc.isOpen()) {
        getInfo().setError(QTIConstants.ERROR_SECTION_OUTOFTIME);
        getInfo().setRenderItems(false);
    } else {
        // no current item position, since we display section info only
        sc.setCurrentItemContextPos(-1);
        sc.start();
        getInfo().setStatus(QTIConstants.ASSESSMENT_RUNNING);
        // only section info
        getInfo().setRenderItems(false);
        getInfo().setMessage(QTIConstants.MESSAGE_SECTION_INFODEMANDED);
    }
    getAssessmentInstance().persist();
}
Also used : SectionContext(org.olat.ims.qti.container.SectionContext) AssessmentContext(org.olat.ims.qti.container.AssessmentContext)

Example 24 with AssessmentContext

use of org.olat.ims.qti.container.AssessmentContext in project OpenOLAT by OpenOLAT.

the class SequentialItemNavigator method startAssessment.

/**
 * starts the assessment: assuming we have at least one section with at least
 * one item
 */
public void startAssessment() {
    AssessmentContext ac = getAssessmentContext();
    ac.setCurrentSectionContextPos(0);
    ac.getCurrentSectionContext().setCurrentItemContextPos(0);
    // start assessment, section, and item
    getAssessmentInstance().start();
    ac.getCurrentSectionContext().start();
    ac.getCurrentSectionContext().getCurrentItemContext().start();
    getInfo().setStatus(QTIConstants.ASSESSMENT_RUNNING);
    if (!ac.isOpen()) {
        getInfo().setError(QTIConstants.ERROR_ASSESSMENT_OUTOFTIME);
        getInfo().setRenderItems(false);
    } else {
        // show test title and description first
        getInfo().setMessage(QTIConstants.MESSAGE_ASSESSMENT_INFODEMANDED);
        // do not show items as first step
        getInfo().setRenderItems(false);
    }
    getAssessmentInstance().persist();
}
Also used : AssessmentContext(org.olat.ims.qti.container.AssessmentContext)

Example 25 with AssessmentContext

use of org.olat.ims.qti.container.AssessmentContext in project OpenOLAT by OpenOLAT.

the class SequentialItemNavigator method goToItem.

/**
 * @see org.olat.ims.qti.navigator.Navigator#goToItem(int, int)
 */
public void goToItem(int sectionPos, int itemPos) {
    AssessmentContext ac = getAssessmentContext();
    ac.setCurrentSectionContextPos(sectionPos);
    SectionContext sc = ac.getCurrentSectionContext();
    sc.setCurrentItemContextPos(itemPos);
    getInfo().setRenderItems(true);
    getInfo().setMessage(QTIConstants.MESSAGE_NONE);
}
Also used : SectionContext(org.olat.ims.qti.container.SectionContext) AssessmentContext(org.olat.ims.qti.container.AssessmentContext)

Aggregations

AssessmentContext (org.olat.ims.qti.container.AssessmentContext)44 SectionContext (org.olat.ims.qti.container.SectionContext)28 ItemContext (org.olat.ims.qti.container.ItemContext)20 AssessmentInstance (org.olat.ims.qti.process.AssessmentInstance)12 ItemInput (org.olat.ims.qti.container.ItemInput)10 ScoreEvaluation (org.olat.course.run.scoring.ScoreEvaluation)8 Output (org.olat.ims.qti.container.Output)8 Document (org.dom4j.Document)6 AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)6 UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)6 Hint (org.olat.ims.qti.container.qtielements.Hint)6 ModuleConfiguration (org.olat.modules.ModuleConfiguration)6 Date (java.util.Date)4 List (java.util.List)4 StringOutput (org.olat.core.gui.render.StringOutput)4 QTIResultSet (org.olat.ims.qti.QTIResultSet)4 HttpItemInput (org.olat.ims.qti.container.HttpItemInput)4 Info (org.olat.ims.qti.navigator.Info)4 Resolver (org.olat.ims.qti.process.Resolver)4 Navigator (org.olat.ims.qti.navigator.Navigator)3