Search in sources :

Example 11 with ItemContext

use of org.olat.ims.qti.container.ItemContext in project openolat by klemens.

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 12 with ItemContext

use of org.olat.ims.qti.container.ItemContext in project openolat by klemens.

the class MenuItemNavigator method goToItem.

/**
 * @see org.olat.qti.process.Navigator#goToItem(int, int)
 */
public void goToItem(int sectionPos, int itemPos) {
    if (getInfo().getStatus() != QTIConstants.ASSESSMENT_RUNNING)
        throw new RuntimeException("assessment is NOT running yet or anymore");
    clearInfo();
    AssessmentContext ac = getAssessmentContext();
    SectionContext sc = ac.getSectionContext(sectionPos);
    ItemContext target = sc.getItemContext(itemPos);
    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 if (!target.isOpen()) {
        getInfo().setError(QTIConstants.ERROR_ITEM_OUTOFTIME);
        getInfo().setRenderItems(false);
    } else {
        getInfo().setStatus(QTIConstants.ASSESSMENT_RUNNING);
        getInfo().setRenderItems(true);
        ac.setCurrentSectionContextPos(sectionPos);
        sc.start();
        sc.setCurrentItemContextPos(itemPos);
        sc.getCurrentItemContext().start();
    }
    getAssessmentInstance().persist();
}
Also used : SectionContext(org.olat.ims.qti.container.SectionContext) AssessmentContext(org.olat.ims.qti.container.AssessmentContext) ItemContext(org.olat.ims.qti.container.ItemContext)

Example 13 with ItemContext

use of org.olat.ims.qti.container.ItemContext in project openolat by klemens.

the class SequentialItemNavigator method submitItems.

/**
 * @see org.olat.ims.qti.navigator.Navigator#submitItems(org.olat.ims.qti.container.ItemsInput)
 */
public void submitItems(ItemsInput curitsinp) {
    clearInfo();
    AssessmentContext ac = getAssessmentContext();
    SectionContext sc = ac.getCurrentSectionContext();
    int st = submitOneItem(curitsinp);
    if (st != QTIConstants.ITEM_SUBMITTED) {
        // item or assessment-finished-text
        if (st == QTIConstants.ERROR_SUBMITTEDITEM_TOOMANYATTEMPTS) {
            throw new RuntimeException("import check failed: there was a maxattempts in a item, but mode is sequential/item");
        } else if (st == QTIConstants.ERROR_ASSESSMENT_OUTOFTIME) {
            getInfo().setError(st);
            getInfo().setRenderItems(false);
        } else if (st == QTIConstants.ERROR_SUBMITTEDITEM_OUTOFTIME) {
            getInfo().setError(st);
            // still continue to next item
            getInfo().setRenderItems(true);
        }
    } else {
        // ok, display feedback
        ItemContext itc = getAssessmentContext().getCurrentSectionContext().getCurrentItemContext();
        Output outp = itc.getOutput();
        if (outp != null)
            getInfo().setCurrentOutput(outp);
        // check on item feedback
        if (itc.isFeedback()) {
            // feedback allowed
            getInfo().setFeedback(itc.getOutput().hasItem_Responses());
        }
        getInfo().setMessage(QTIConstants.MESSAGE_ITEM_SUBMITTED);
        getInfo().setRenderItems(true);
    }
    // find next item
    int itpos = sc.getCurrentItemContextPos();
    if (itpos < sc.getItemContextCount() - 1 && sc.isOpen()) {
        // there are still further items in the current section
        sc.setCurrentItemContextPos(++itpos);
        sc.getCurrentItemContext().start();
    } else {
        // fetch next section
        if (!sc.isOpen()) {
            getInfo().setError(QTIConstants.ERROR_SECTION_OUTOFTIME);
            getInfo().setRenderItems(true);
        }
        ac.getCurrentSectionContext().sectionWasSubmitted();
        int secPos = ac.getCurrentSectionContextPos();
        int secPosMax = ac.getSectionContextCount() - 1;
        if (!ac.isOpen()) {
            getInfo().setError(QTIConstants.ERROR_ASSESSMENT_OUTOFTIME);
            getInfo().setRenderItems(false);
            submitAssessment();
        } else if (secPos == secPosMax)
            submitAssessment();
        else {
            while (secPos < secPosMax) {
                // there are still further section(s)
                secPos++;
                if (ac.getSectionContext(secPos).getItemContextCount() != 0)
                    break;
            }
            if (secPos == secPosMax && ac.getSectionContext(secPos).getItemContextCount() == 0) {
                // reached last section but section is empty -> finish assessment
                submitAssessment();
            } else {
                ac.setCurrentSectionContextPos(secPos);
                ac.getCurrentSectionContext().setCurrentItemContextPos(0);
                ac.getCurrentSectionContext().start();
                ac.getCurrentSectionContext().getCurrentItemContext().start();
                // since new section starts, show next the section title and description
                getInfo().setRenderItems(false);
            }
        }
    }
    getAssessmentInstance().persist();
}
Also used : SectionContext(org.olat.ims.qti.container.SectionContext) AssessmentContext(org.olat.ims.qti.container.AssessmentContext) ItemContext(org.olat.ims.qti.container.ItemContext) Output(org.olat.ims.qti.container.Output)

Example 14 with ItemContext

use of org.olat.ims.qti.container.ItemContext in project openolat by klemens.

the class SequentialSectionNavigator method startSection.

private void startSection(SectionContext sc) {
    sc.start();
    for (int i = 0; i < sc.getItemContextCount(); i++) {
        ItemContext itc = sc.getItemContext(i);
        itc.start();
    }
}
Also used : ItemContext(org.olat.ims.qti.container.ItemContext)

Example 15 with ItemContext

use of org.olat.ims.qti.container.ItemContext 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)

Aggregations

ItemContext (org.olat.ims.qti.container.ItemContext)28 AssessmentContext (org.olat.ims.qti.container.AssessmentContext)20 SectionContext (org.olat.ims.qti.container.SectionContext)20 ItemInput (org.olat.ims.qti.container.ItemInput)10 Output (org.olat.ims.qti.container.Output)8 AssessmentInstance (org.olat.ims.qti.process.AssessmentInstance)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 Hint (org.olat.ims.qti.container.qtielements.Hint)4 Info (org.olat.ims.qti.navigator.Info)4 IQManager (org.olat.modules.iq.IQManager)4 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Iterator (java.util.Iterator)2 Set (java.util.Set)2 WebApplicationException (javax.ws.rs.WebApplicationException)2