use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration in project OpenOLAT by OpenOLAT.
the class AssessmentObjectVelocityRenderDecorator method getSliderOptions.
/*
<xsl:variable name="is-discrete" select="qw:get-response-declaration(/, @responseIdentifier)/@baseType='integer'" as="xs:boolean"/>
<xsl:variable name="min" select="if ($is-discrete) then string(floor(@lowerBound)) else string(@lowerBound)" as="xs:string"/>
<xsl:variable name="max" select="if ($is-discrete) then string(ceiling(@upperBound)) else string(@upperBound)" as="xs:string"/>
<xsl:variable name="step" select="if (@step) then @step else if ($is-discrete) then '1' else '0.01'" as="xs:string"/>
<xsl:value-of select="if (@reverse) then @reverse else 'false'"/>
*/
public SliderOptions getSliderOptions(SliderInteraction interaction) {
ResponseDeclaration responseDeclaration = getResponseDeclaration(interaction.getResponseIdentifier());
boolean discrete = responseDeclaration.hasBaseType(BaseType.INTEGER);
boolean reverse = interaction.getReverse() == null ? false : interaction.getReverse().booleanValue();
String step;
if (interaction.getStep() != null) {
step = Integer.toString(interaction.getStep().intValue());
} else {
step = discrete ? "1" : "0.01";
}
String min;
String max;
if (discrete) {
min = Long.toString(java.lang.Math.round(java.lang.Math.floor(interaction.getLowerBound())));
max = Long.toString(java.lang.Math.round(java.lang.Math.ceil(interaction.getUpperBound())));
} else {
min = Long.toString(java.lang.Math.round(interaction.getLowerBound()));
max = Long.toString(java.lang.Math.round(interaction.getUpperBound()));
}
return new SliderOptions(discrete, reverse, min, max, step);
}
use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration in project OpenOLAT by OpenOLAT.
the class AssessmentObjectVelocityRenderDecorator method isSingleChoice.
/**
* Check the maxChoices and the cardinality
* @param interaction
* @return
*/
public boolean isSingleChoice(Interaction interaction) {
if (interaction instanceof ChoiceInteraction) {
ChoiceInteraction choiceInteraction = (ChoiceInteraction) interaction;
boolean sc = choiceInteraction.getMaxChoices() == 1;
ResponseDeclaration responseDeclaration = assessmentItem.getResponseDeclaration(choiceInteraction.getResponseIdentifier());
if (responseDeclaration != null && responseDeclaration.hasCardinality(Cardinality.MULTIPLE)) {
return false;
}
return sc;
} else if (interaction instanceof HottextInteraction) {
HottextInteraction hottextInteraction = (HottextInteraction) interaction;
boolean sc = hottextInteraction.getMaxChoices() == 1;
ResponseDeclaration responseDeclaration = assessmentItem.getResponseDeclaration(hottextInteraction.getResponseIdentifier());
if (responseDeclaration != null && responseDeclaration.hasCardinality(Cardinality.MULTIPLE)) {
return false;
}
return sc;
} else if (interaction instanceof HotspotInteraction) {
HotspotInteraction hotspotInteraction = (HotspotInteraction) interaction;
ResponseDeclaration responseDeclaration = assessmentItem.getResponseDeclaration(hotspotInteraction.getResponseIdentifier());
if (responseDeclaration != null && responseDeclaration.hasCardinality(Cardinality.SINGLE)) {
return true;
}
return false;
}
return false;
}
use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration in project OpenOLAT by OpenOLAT.
the class HottextAssessmentItemBuilder method extractCorrectAnswers.
private void extractCorrectAnswers() {
correctAnswers = new ArrayList<>(5);
if (hottextInteraction != null) {
ResponseDeclaration responseDeclaration = assessmentItem.getResponseDeclaration(hottextInteraction.getResponseIdentifier());
if (responseDeclaration != null && responseDeclaration.getCorrectResponse() != null) {
CorrectResponse correctResponse = responseDeclaration.getCorrectResponse();
extractIdentifiersFromCorrectResponse(correctResponse, correctAnswers);
}
}
}
use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration in project OpenOLAT by OpenOLAT.
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;
}
use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration in project OpenOLAT by OpenOLAT.
the class MultipleChoiceAssessmentItemBuilder method extract.
@Override
public void extract() {
super.extract();
correctAnswers = new ArrayList<>(5);
if (choiceInteraction != null) {
ResponseDeclaration responseDeclaration = assessmentItem.getResponseDeclaration(choiceInteraction.getResponseIdentifier());
if (responseDeclaration != null && responseDeclaration.getCorrectResponse() != null) {
CorrectResponse correctResponse = responseDeclaration.getCorrectResponse();
Value value = FieldValue.computeValue(Cardinality.MULTIPLE, correctResponse.getFieldValues());
if (value instanceof MultipleValue) {
MultipleValue multiValue = (MultipleValue) value;
for (SingleValue sValue : multiValue.getAll()) {
if (sValue instanceof IdentifierValue) {
IdentifierValue identifierValue = (IdentifierValue) sValue;
Identifier correctAnswer = identifierValue.identifierValue();
correctAnswers.add(correctAnswer);
}
}
}
}
}
}
Aggregations