Search in sources :

Example 66 with AssessmentItemBuilder

use of org.olat.ims.qti21.model.xml.AssessmentItemBuilder in project openolat by klemens.

the class FIBScoreController method sync.

@Override
public void sync(UserRequest ureq, AssessmentItemBuilder assessmentItemBuilder) {
    if (itemBuilder == assessmentItemBuilder) {
        List<AbstractEntry> entries = itemBuilder.getOrderedTextEntries();
        for (AbstractEntry entry : entries) {
            FIBEntryWrapper wrapper = getTextEntryWrapper(entry);
            if (wrapper == null) {
                wrappers.add(createTextEntryWrapper(entry));
            }
        }
        // remove removed entry
        for (Iterator<FIBEntryWrapper> wrapperIt = wrappers.iterator(); wrapperIt.hasNext(); ) {
            Identifier responseIdentifier = wrapperIt.next().getEntry().getResponseIdentifier();
            if (itemBuilder.getTextEntry(responseIdentifier.toString()) == null) {
                wrapperIt.remove();
            }
        }
        // reorder the wrappers
        Map<AbstractEntry, FIBEntryWrapper> wrapperMap = new HashMap<>();
        for (FIBEntryWrapper wrapper : wrappers) {
            wrapperMap.put(wrapper.getEntry(), wrapper);
        }
        List<FIBEntryWrapper> reorderedWrappers = new ArrayList<>();
        for (AbstractEntry entry : entries) {
            FIBEntryWrapper wrapper = wrapperMap.get(entry);
            if (wrapper != null) {
                reorderedWrappers.add(wrapper);
                wrapperMap.remove(entry);
            }
        }
        if (wrapperMap.size() > 0) {
            // paranoid security
            for (FIBEntryWrapper wrapper : wrapperMap.values()) {
                if (!reorderedWrappers.contains(wrapper)) {
                    reorderedWrappers.add(wrapper);
                }
            }
        }
        wrappers.clear();
        wrappers.addAll(reorderedWrappers);
    }
}
Also used : AbstractEntry(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.AbstractEntry) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList)

Aggregations

EssayAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.EssayAssessmentItemBuilder)28 FIBAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder)28 KPrimAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.KPrimAssessmentItemBuilder)28 MultipleChoiceAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.MultipleChoiceAssessmentItemBuilder)28 SingleChoiceAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.SingleChoiceAssessmentItemBuilder)28 MatchAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.MatchAssessmentItemBuilder)26 AssessmentItemBuilder (org.olat.ims.qti21.model.xml.AssessmentItemBuilder)24 SimpleChoiceAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.SimpleChoiceAssessmentItemBuilder)18 EssayQuestion (org.olat.ims.qti.editor.beecom.objects.EssayQuestion)14 ChoiceQuestion (org.olat.ims.qti.editor.beecom.objects.ChoiceQuestion)12 EssayResponse (org.olat.ims.qti.editor.beecom.objects.EssayResponse)12 Question (org.olat.ims.qti.editor.beecom.objects.Question)12 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)12 ChoiceResponse (org.olat.ims.qti.editor.beecom.objects.ChoiceResponse)10 FIBResponse (org.olat.ims.qti.editor.beecom.objects.FIBResponse)10 Response (org.olat.ims.qti.editor.beecom.objects.Response)10 File (java.io.File)8 HashMap (java.util.HashMap)8 DrawingAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.DrawingAssessmentItemBuilder)8 HotspotAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.HotspotAssessmentItemBuilder)8