use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration in project openolat by klemens.
the class SingleChoiceAssessmentItemBuilder method extract.
@Override
public void extract() {
super.extract();
if (choiceInteraction != null) {
ResponseDeclaration responseDeclaration = assessmentItem.getResponseDeclaration(choiceInteraction.getResponseIdentifier());
if (responseDeclaration != null && responseDeclaration.getCorrectResponse() != null) {
CorrectResponse correctResponse = responseDeclaration.getCorrectResponse();
List<FieldValue> values = correctResponse.getFieldValues();
Value value = FieldValue.computeValue(Cardinality.SINGLE, values);
if (value instanceof IdentifierValue) {
IdentifierValue identifierValue = (IdentifierValue) value;
correctAnswer = identifierValue.identifierValue();
}
}
}
}
use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration 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);
}
use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration in project openolat by klemens.
the class AssessmentItemBuilder method build.
public final void build() {
List<OutcomeDeclaration> outcomeDeclarations = assessmentItem.getOutcomeDeclarations();
outcomeDeclarations.clear();
ResponseProcessing responseProcessing = assessmentItem.getResponseProcessing();
List<ResponseRule> responseRules = responseProcessing.getResponseRules();
responseRules.clear();
List<ResponseDeclaration> responseDeclarations = assessmentItem.getResponseDeclarations();
responseDeclarations.clear();
List<ModalFeedback> modalFeedbacks = assessmentItem.getModalFeedbacks();
modalFeedbacks.clear();
buildItemBody();
buildResponseAndOutcomeDeclarations();
buildModalFeedbacksAndHints(outcomeDeclarations, responseRules);
buildMinMaxScores(outcomeDeclarations, responseRules);
buildMainScoreRule(outcomeDeclarations, responseRules);
buildHint(outcomeDeclarations, responseRules);
}
use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration in project openolat by klemens.
the class AssessmentItemChecker method checkSetCorrectResponse.
/**
* responseDeclaration -> float
*
* templateVraiable -> integer
*
* setCorrectResponse
* -> variable -> integer doesn't match float -> issue
* @param item
* @return
*/
private static boolean checkSetCorrectResponse(AssessmentItem item) {
boolean allOk = true;
List<SetCorrectResponse> setCorrectResponses = QueryUtils.search(SetCorrectResponse.class, item);
for (SetCorrectResponse setCorrectResponse : setCorrectResponses) {
Identifier responseIdentifier = setCorrectResponse.getIdentifier();
ResponseDeclaration responseDeclaration = item.getResponseDeclaration(responseIdentifier);
BaseType baseType = responseDeclaration.getBaseType();
Expression expression = setCorrectResponse.getExpression();
if (expression instanceof Variable) {
Variable variable = (Variable) expression;
ComplexReferenceIdentifier cpxVariableIdentifier = variable.getIdentifier();
Identifier variableIdentifier = Identifier.assumedLegal(cpxVariableIdentifier.toString());
TemplateDeclaration templateDeclaration = item.getTemplateDeclaration(variableIdentifier);
if (templateDeclaration != null && !templateDeclaration.hasBaseType(baseType)) {
templateDeclaration.setBaseType(baseType);
allOk &= false;
}
}
}
return allOk;
}
use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration in project openolat by klemens.
the class AssessmentItemFactory method createHottextCorrectResponseDeclaration.
public static ResponseDeclaration createHottextCorrectResponseDeclaration(AssessmentItem assessmentItem, Identifier declarationId, List<Identifier> correctResponseIds) {
ResponseDeclaration responseDeclaration = new ResponseDeclaration(assessmentItem);
responseDeclaration.setIdentifier(declarationId);
responseDeclaration.setCardinality(Cardinality.MULTIPLE);
responseDeclaration.setBaseType(BaseType.IDENTIFIER);
CorrectResponse correctResponse = new CorrectResponse(responseDeclaration);
responseDeclaration.setCorrectResponse(correctResponse);
for (Identifier correctResponseId : correctResponseIds) {
appendIdentifierValue(correctResponse, correctResponseId);
}
return responseDeclaration;
}
Aggregations