use of org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.NumericalEntry in project OpenOLAT by OpenOLAT.
the class CorrectResponsesUtil method getCorrectTextResponses.
public static final AbstractEntry getCorrectTextResponses(AssessmentItem assessmentItem, TextEntryInteraction interaction) {
ResponseDeclaration responseDeclaration = assessmentItem.getResponseDeclaration(interaction.getResponseIdentifier());
if (responseDeclaration.hasBaseType(BaseType.STRING) && responseDeclaration.hasCardinality(Cardinality.SINGLE)) {
TextEntry textEntry = new TextEntry(interaction);
FIBAssessmentItemBuilder.extractTextEntrySettingsFromResponseDeclaration(textEntry, responseDeclaration, new AtomicInteger(), new DoubleAdder());
return textEntry;
} else if (responseDeclaration.hasBaseType(BaseType.FLOAT) && responseDeclaration.hasCardinality(Cardinality.SINGLE)) {
NumericalEntry numericalEntry = new NumericalEntry(interaction);
FIBAssessmentItemBuilder.extractNumericalEntrySettings(assessmentItem, numericalEntry, responseDeclaration, new AtomicInteger(), new DoubleAdder());
return numericalEntry;
}
return null;
}
use of org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.NumericalEntry in project OpenOLAT by OpenOLAT.
the class QTI21StatisticsManagerImpl method getNumericalInputInteractionSettings.
private NumericalInputInteractionStatistics getNumericalInputInteractionSettings(Identifier responseIdentifier, ResponseDeclaration responseDeclaration, AssessmentItem item) {
NumericalEntry numericalEntry = new NumericalEntry(responseIdentifier);
FIBAssessmentItemBuilder.extractNumericalEntrySettings(item, numericalEntry, responseDeclaration, new AtomicInteger(), new DoubleAdder());
String correctResponse = "";
Double solution = numericalEntry.getSolution();
if (numericalEntry.getSolution() != null) {
correctResponse = solution.toString();
}
double points = Double.NaN;
if (numericalEntry.getScore() == null) {
// all score
points = 0.0d;
} else {
points = numericalEntry.getScore().doubleValue();
}
return new NumericalInputInteractionStatistics(responseIdentifier, correctResponse, solution, numericalEntry.getToleranceMode(), numericalEntry.getLowerTolerance(), numericalEntry.getUpperTolerance(), points);
}
use of org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.NumericalEntry in project OpenOLAT by OpenOLAT.
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);
}
}
}
}
use of org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.NumericalEntry 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);
}
}
}
}
use of org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.NumericalEntry 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;
}
Aggregations