Search in sources :

Example 6 with ScoreEvaluation

use of org.olat.ims.qti21.model.xml.interactions.SimpleChoiceAssessmentItemBuilder.ScoreEvaluation in project openolat by klemens.

the class FIBAssessmentItemBuilder method buildResponseAndOutcomeDeclarations.

@Override
protected void buildResponseAndOutcomeDeclarations() {
    List<ResponseDeclaration> responseDeclarations = assessmentItem.getResponseDeclarations();
    /*
		<responseDeclaration identifier="RESPONSE_1" cardinality="single" baseType="string">
			<correctResponse>
				<value>
					Gap
				</value>
			</correctResponse>
			<mapping defaultValue="0">
				<mapEntry mapKey="Gap" mappedValue="2" />
				<mapEntry mapKey="gap1" mappedValue="2" />
				<mapEntry mapKey="gap2" mappedValue="1" />
			</mapping>
		</responseDeclaration>
		*/
    for (Map.Entry<String, AbstractEntry> textEntryEntry : responseIdentifierToTextEntry.entrySet()) {
        AbstractEntry entry = textEntryEntry.getValue();
        if (entry instanceof TextEntry) {
            TextEntry textEntry = (TextEntry) entry;
            if (textEntry.getSolution() != null) {
                Double score = -1.0d;
                if (scoreEvaluation == ScoreEvaluation.perAnswer) {
                    score = textEntry.getScore();
                }
                ResponseDeclaration responseDeclaration = createTextEntryResponseDeclaration(assessmentItem, textEntry.getResponseIdentifier(), textEntry.getSolution(), score, textEntry.isCaseSensitive(), textEntry.getAlternatives());
                responseDeclarations.add(responseDeclaration);
            }
        } else if (entry instanceof NumericalEntry) {
            NumericalEntry textEntry = (NumericalEntry) entry;
            if (textEntry.getSolution() != null) {
                ResponseDeclaration responseDeclaration = createNumericalEntryResponseDeclaration(assessmentItem, textEntry.getResponseIdentifier(), textEntry.getSolution());
                responseDeclarations.add(responseDeclaration);
            }
        }
    }
}
Also used : AssessmentItemFactory.createNumericalEntryResponseDeclaration(org.olat.ims.qti21.model.xml.AssessmentItemFactory.createNumericalEntryResponseDeclaration) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration) AssessmentItemFactory.createTextEntryResponseDeclaration(org.olat.ims.qti21.model.xml.AssessmentItemFactory.createTextEntryResponseDeclaration) Map(java.util.Map) HashMap(java.util.HashMap)

Example 7 with ScoreEvaluation

use of org.olat.ims.qti21.model.xml.interactions.SimpleChoiceAssessmentItemBuilder.ScoreEvaluation in project openolat by klemens.

the class FIBAssessmentItemBuilder method extractEntriesSettingsFromResponseDeclaration.

/**
 * We loop around the textEntryInteraction, search the responseDeclaration. responseDeclaration
 * of type string are gap text, of type float are numerical.
 */
public void extractEntriesSettingsFromResponseDeclaration() {
    DoubleAdder mappedScore = new DoubleAdder();
    AtomicInteger countAlternatives = new AtomicInteger(0);
    responseIdentifierToTextEntry = new HashMap<>();
    List<Interaction> interactions = assessmentItem.getItemBody().findInteractions();
    for (Interaction interaction : interactions) {
        if (interaction instanceof TextEntryInteraction && interaction.getResponseIdentifier() != null) {
            AbstractEntry entry = null;
            TextEntryInteraction textInteraction = (TextEntryInteraction) interaction;
            ResponseDeclaration responseDeclaration = assessmentItem.getResponseDeclaration(interaction.getResponseIdentifier());
            if (responseDeclaration != null) {
                if (responseDeclaration.hasBaseType(BaseType.STRING) && responseDeclaration.hasCardinality(Cardinality.SINGLE)) {
                    TextEntry textEntry = new TextEntry(textInteraction);
                    extractTextEntrySettingsFromResponseDeclaration(textEntry, responseDeclaration, countAlternatives, mappedScore);
                    String marker = "responseIdentifier=\"" + interaction.getResponseIdentifier().toString() + "\"";
                    question = question.replace(marker, marker + " openolatType=\"string\"");
                    if (StringHelper.containsNonWhitespace(textEntry.getSolution())) {
                        question = question.replace(marker, marker + " data-qti-solution=\"" + escapeForDataQtiSolution(textEntry.getSolution()) + "\"");
                    }
                    entry = textEntry;
                } else if (responseDeclaration.hasBaseType(BaseType.FLOAT) && responseDeclaration.hasCardinality(Cardinality.SINGLE)) {
                    NumericalEntry numericalEntry = new NumericalEntry(textInteraction);
                    entry = numericalEntry;
                    extractNumericalEntrySettings(assessmentItem, numericalEntry, responseDeclaration, countAlternatives, mappedScore);
                    String marker = "responseIdentifier=\"" + interaction.getResponseIdentifier().toString() + "\"";
                    question = question.replace(marker, marker + " openolatType=\"float\"");
                    if (numericalEntry.getSolution() != null) {
                        question = question.replace(marker, marker + " data-qti-solution=\"" + Double.toString(numericalEntry.getSolution()) + "\"");
                    }
                }
            }
            if (entry != null) {
                responseIdentifierToTextEntry.put(interaction.getResponseIdentifier().toString(), entry);
            }
        }
    }
    boolean hasMapping = Math.abs(mappedScore.doubleValue() - (-1.0 * countAlternatives.get())) > 0.0001;
    scoreEvaluation = hasMapping ? ScoreEvaluation.perAnswer : ScoreEvaluation.allCorrectAnswers;
}
Also used : DoubleAdder(java.util.concurrent.atomic.DoubleAdder) AssessmentItemFactory.appendTextEntryInteraction(org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendTextEntryInteraction) TextEntryInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) AssessmentItemFactory.appendTextEntryInteraction(org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendTextEntryInteraction) TextEntryInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction) Interaction(uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction) AssessmentItemFactory.createNumericalEntryResponseDeclaration(org.olat.ims.qti21.model.xml.AssessmentItemFactory.createNumericalEntryResponseDeclaration) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration) AssessmentItemFactory.createTextEntryResponseDeclaration(org.olat.ims.qti21.model.xml.AssessmentItemFactory.createTextEntryResponseDeclaration)

Example 8 with ScoreEvaluation

use of org.olat.ims.qti21.model.xml.interactions.SimpleChoiceAssessmentItemBuilder.ScoreEvaluation in project openolat by klemens.

the class HottextAssessmentItemBuilder method extractScoreEvaluationMode.

private void extractScoreEvaluationMode() {
    boolean hasMapping = false;
    if (hottextInteraction != null) {
        ResponseDeclaration responseDeclaration = assessmentItem.getResponseDeclaration(hottextInteraction.getResponseIdentifier());
        if (responseDeclaration != null) {
            Mapping mapping = responseDeclaration.getMapping();
            hasMapping = (mapping != null && mapping.getMapEntries() != null && mapping.getMapEntries().size() > 0);
            if (hasMapping) {
                scoreMapping = new HashMap<>();
                for (MapEntry entry : mapping.getMapEntries()) {
                    SingleValue sValue = entry.getMapKey();
                    if (sValue instanceof IdentifierValue) {
                        Identifier identifier = ((IdentifierValue) sValue).identifierValue();
                        scoreMapping.put(identifier, entry.getMappedValue());
                    }
                }
            }
        }
    }
    scoreEvaluation = hasMapping ? ScoreEvaluation.perAnswer : ScoreEvaluation.allCorrectAnswers;
}
Also used : MapEntry(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.MapEntry) SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) ComplexReferenceIdentifier(uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier) Mapping(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.Mapping) IdentifierValue(uk.ac.ed.ph.jqtiplus.value.IdentifierValue) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration) AssessmentItemFactory.createHottextCorrectResponseDeclaration(org.olat.ims.qti21.model.xml.AssessmentItemFactory.createHottextCorrectResponseDeclaration)

Example 9 with ScoreEvaluation

use of org.olat.ims.qti21.model.xml.interactions.SimpleChoiceAssessmentItemBuilder.ScoreEvaluation in project openolat by klemens.

the class MatchAssessmentItemBuilder method buildResponseAndOutcomeDeclarations.

@Override
protected void buildResponseAndOutcomeDeclarations() {
    // refresh correct response
    ResponseDeclaration responseDeclaration;
    if (assessmentItem.getResponseDeclaration(responseIdentifier) != null) {
        responseDeclaration = assessmentItem.getResponseDeclaration(responseIdentifier);
        appendAssociationMatchResponseDeclaration(responseDeclaration, associations);
    } else {
        responseDeclaration = createMatchResponseDeclaration(assessmentItem, responseIdentifier, associations);
        assessmentItem.getResponseDeclarations().add(responseDeclaration);
    }
    if (scoreEvaluation == ScoreEvaluation.perAnswer) {
        Map<DirectedPairValue, Double> pairMapping = new HashMap<>();
        if (scoreMapping != null && scoreMapping.size() > 0) {
            for (Map.Entry<DirectedPairValue, Double> entry : scoreMapping.entrySet()) {
                DirectedPairValue sdKey = entry.getKey();
                pairMapping.put(new DirectedPairValue(sdKey.sourceValue(), sdKey.destValue()), entry.getValue());
            }
        }
        AssessmentItemFactory.appendPairMapping(responseDeclaration, pairMapping);
    } else {
        // make sure there isn't any mapping
        responseDeclaration.setMapping(null);
    }
}
Also used : HashMap(java.util.HashMap) DirectedPairValue(uk.ac.ed.ph.jqtiplus.value.DirectedPairValue) AssessmentItemFactory.appendAssociationMatchResponseDeclaration(org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendAssociationMatchResponseDeclaration) AssessmentItemFactory.createMatchResponseDeclaration(org.olat.ims.qti21.model.xml.AssessmentItemFactory.createMatchResponseDeclaration) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration) Map(java.util.Map) HashMap(java.util.HashMap)

Example 10 with ScoreEvaluation

use of org.olat.ims.qti21.model.xml.interactions.SimpleChoiceAssessmentItemBuilder.ScoreEvaluation in project openolat by klemens.

the class SingleChoiceAssessmentItemBuilder method buildResponseAndOutcomeDeclarations.

@Override
protected void buildResponseAndOutcomeDeclarations() {
    ResponseDeclaration responseDeclaration = AssessmentItemFactory.createSingleChoiceCorrectResponseDeclaration(assessmentItem, responseIdentifier, correctAnswer);
    if (scoreEvaluation == ScoreEvaluation.perAnswer) {
        AssessmentItemFactory.appendMapping(responseDeclaration, scoreMapping);
    }
    assessmentItem.getResponseDeclarations().add(responseDeclaration);
}
Also used : AssessmentItemFactory.createSingleChoiceCorrectResponseDeclaration(org.olat.ims.qti21.model.xml.AssessmentItemFactory.createSingleChoiceCorrectResponseDeclaration) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)

Aggregations

ResponseDeclaration (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)16 ScoreEvaluation (org.olat.course.run.scoring.ScoreEvaluation)6 AssessmentTestSession (org.olat.ims.qti21.AssessmentTestSession)6 HashMap (java.util.HashMap)4 Map (java.util.Map)4 IQTESTCourseNode (org.olat.course.nodes.IQTESTCourseNode)4 AssessmentItemFactory.appendAssociationMatchResponseDeclaration (org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendAssociationMatchResponseDeclaration)4 AssessmentItemFactory.createHottextCorrectResponseDeclaration (org.olat.ims.qti21.model.xml.AssessmentItemFactory.createHottextCorrectResponseDeclaration)4 AssessmentItemFactory.createMatchResponseDeclaration (org.olat.ims.qti21.model.xml.AssessmentItemFactory.createMatchResponseDeclaration)4 AssessmentItemFactory.createNumericalEntryResponseDeclaration (org.olat.ims.qti21.model.xml.AssessmentItemFactory.createNumericalEntryResponseDeclaration)4 AssessmentItemFactory.createTextEntryResponseDeclaration (org.olat.ims.qti21.model.xml.AssessmentItemFactory.createTextEntryResponseDeclaration)4 MapEntry (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.MapEntry)4 Mapping (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.Mapping)4 ComplexReferenceIdentifier (uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier)4 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)4 DirectedPairValue (uk.ac.ed.ph.jqtiplus.value.DirectedPairValue)4 SingleValue (uk.ac.ed.ph.jqtiplus.value.SingleValue)4 File (java.io.File)2 BigDecimal (java.math.BigDecimal)2 Date (java.util.Date)2