use of uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseProcessing in project openolat by klemens.
the class EssayAssessmentItemBuilder method createAssessmentItem.
private static AssessmentItem createAssessmentItem(String title) {
AssessmentItem assessmentItem = AssessmentItemFactory.createAssessmentItem(QTI21QuestionType.essay, title);
// define the response
Identifier responseDeclarationId = Identifier.assumedLegal("RESPONSE_1");
ResponseDeclaration responseDeclaration = createExtendedTextResponseDeclaration(assessmentItem, responseDeclarationId);
assessmentItem.getNodeGroups().getResponseDeclarationGroup().getResponseDeclarations().add(responseDeclaration);
// outcomes
appendDefaultOutcomeDeclarations(assessmentItem, 1.0d);
ItemBody itemBody = appendDefaultItemBody(assessmentItem);
appendExtendedTextInteraction(itemBody, responseDeclarationId);
// response processing
ResponseProcessing responseProcessing = createResponseProcessing(assessmentItem, responseDeclarationId);
assessmentItem.getNodeGroups().getResponseProcessingGroup().setResponseProcessing(responseProcessing);
return assessmentItem;
}
use of uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseProcessing in project OpenOLAT by OpenOLAT.
the class AssessmentItemFactory method createResponseProcessing.
public static ResponseProcessing createResponseProcessing(AssessmentItem assessmentItem, Identifier responseId) {
ResponseProcessing responseProcessing = new ResponseProcessing(assessmentItem);
ResponseCondition rule = new ResponseCondition(responseProcessing);
// if no response
ResponseIf responseIf = new ResponseIf(rule);
rule.setResponseIf(responseIf);
IsNull isNull = new IsNull(responseIf);
responseIf.getExpressions().add(isNull);
Variable variable = new Variable(isNull);
variable.setIdentifier(ComplexReferenceIdentifier.parseString(responseId.toString()));
isNull.getExpressions().add(variable);
{
SetOutcomeValue feedbackVar = new SetOutcomeValue(responseIf);
feedbackVar.setIdentifier(QTI21Constants.FEEDBACKBASIC_IDENTIFIER);
BaseValue feedbackVal = new BaseValue(feedbackVar);
feedbackVal.setBaseTypeAttrValue(BaseType.IDENTIFIER);
feedbackVal.setSingleValue(new IdentifierValue("empty"));
feedbackVar.setExpression(feedbackVal);
responseIf.getResponseRules().add(feedbackVar);
}
// else if correct response
ResponseElseIf responseElseIf = new ResponseElseIf(rule);
rule.getResponseElseIfs().add(responseElseIf);
// match
{
Match match = new Match(responseElseIf);
responseElseIf.getExpressions().add(match);
Variable responseVar = new Variable(match);
responseVar.setIdentifier(ComplexReferenceIdentifier.parseString(responseId.toString()));
match.getExpressions().add(responseVar);
Correct correct = new Correct(match);
correct.setIdentifier(ComplexReferenceIdentifier.parseString(responseId.toString()));
match.getExpressions().add(correct);
}
// outcome score
{
SetOutcomeValue scoreOutcomeVar = new SetOutcomeValue(responseIf);
scoreOutcomeVar.setIdentifier(QTI21Constants.SCORE_IDENTIFIER);
responseElseIf.getResponseRules().add(scoreOutcomeVar);
Sum sum = new Sum(scoreOutcomeVar);
scoreOutcomeVar.getExpressions().add(sum);
Variable scoreVar = new Variable(sum);
scoreVar.setIdentifier(QTI21Constants.SCORE_CLX_IDENTIFIER);
sum.getExpressions().add(scoreVar);
Variable maxScoreVar = new Variable(sum);
maxScoreVar.setIdentifier(QTI21Constants.MAXSCORE_CLX_IDENTIFIER);
sum.getExpressions().add(maxScoreVar);
}
// outcome feedback
{
SetOutcomeValue correctFeedbackVar = new SetOutcomeValue(responseIf);
correctFeedbackVar.setIdentifier(QTI21Constants.FEEDBACKBASIC_IDENTIFIER);
BaseValue correctFeedbackVal = new BaseValue(correctFeedbackVar);
correctFeedbackVal.setBaseTypeAttrValue(BaseType.IDENTIFIER);
correctFeedbackVal.setSingleValue(QTI21Constants.CORRECT_IDENTIFIER_VALUE);
correctFeedbackVar.setExpression(correctFeedbackVal);
responseElseIf.getResponseRules().add(correctFeedbackVar);
}
// else failed
ResponseElse responseElse = new ResponseElse(rule);
rule.setResponseElse(responseElse);
{
// feedback incorrect
SetOutcomeValue incorrectFeedbackVar = new SetOutcomeValue(responseIf);
incorrectFeedbackVar.setIdentifier(QTI21Constants.FEEDBACKBASIC_IDENTIFIER);
BaseValue incorrectFeedbackVal = new BaseValue(incorrectFeedbackVar);
incorrectFeedbackVal.setBaseTypeAttrValue(BaseType.IDENTIFIER);
incorrectFeedbackVal.setSingleValue(QTI21Constants.INCORRECT_IDENTIFIER_VALUE);
incorrectFeedbackVar.setExpression(incorrectFeedbackVal);
responseElse.getResponseRules().add(incorrectFeedbackVar);
}
responseProcessing.getResponseRules().add(rule);
return responseProcessing;
}
use of uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseProcessing in project OpenOLAT by OpenOLAT.
the class AssessmentItemFactory method createSingleChoice.
public static AssessmentItem createSingleChoice(String title, String defaultAnswer) {
AssessmentItem assessmentItem = createAssessmentItem(QTI21QuestionType.sc, title);
// define correct answer
Identifier responseDeclarationId = Identifier.assumedLegal("RESPONSE_1");
Identifier correctResponseId = IdentifierGenerator.newAsIdentifier("sc");
ResponseDeclaration responseDeclaration = createSingleChoiceCorrectResponseDeclaration(assessmentItem, responseDeclarationId, correctResponseId);
assessmentItem.getNodeGroups().getResponseDeclarationGroup().getResponseDeclarations().add(responseDeclaration);
// outcomes
appendDefaultOutcomeDeclarations(assessmentItem, 1.0d);
// the single choice interaction
ItemBody itemBody = appendDefaultItemBody(assessmentItem);
ChoiceInteraction choiceInteraction = appendChoiceInteraction(itemBody, responseDeclarationId, 1, true);
appendSimpleChoice(choiceInteraction, defaultAnswer, correctResponseId);
// response processing
ResponseProcessing responseProcessing = createResponseProcessing(assessmentItem, responseDeclarationId);
assessmentItem.getNodeGroups().getResponseProcessingGroup().setResponseProcessing(responseProcessing);
return assessmentItem;
}
use of uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseProcessing in project OpenOLAT by OpenOLAT.
the class HottextAssessmentItemBuilder method createAssessmentItem.
private static AssessmentItem createAssessmentItem(String title, String text, String hottext) {
AssessmentItem assessmentItem = AssessmentItemFactory.createAssessmentItem(QTI21QuestionType.hottext, title);
// define correct answer
Identifier responseDeclarationId = Identifier.assumedLegal("RESPONSE_1");
Identifier correctResponseId = IdentifierGenerator.newAsIdentifier("ht");
List<Identifier> correctResponseIds = new ArrayList<>();
correctResponseIds.add(correctResponseId);
ResponseDeclaration responseDeclaration = createHottextCorrectResponseDeclaration(assessmentItem, responseDeclarationId, correctResponseIds);
assessmentItem.getNodeGroups().getResponseDeclarationGroup().getResponseDeclarations().add(responseDeclaration);
// outcomes
appendDefaultOutcomeDeclarations(assessmentItem, 1.0d);
// the single choice interaction
ItemBody itemBody = appendDefaultItemBody(assessmentItem);
HottextInteraction hottextInteraction = appendHottextInteraction(itemBody, responseDeclarationId, 0);
P p = new P(itemBody);
p.getInlines().add(new TextRun(p, text));
appendHottext(p, correctResponseId, hottext);
hottextInteraction.getBlockStatics().add(p);
// response processing
ResponseProcessing responseProcessing = createResponseProcessing(assessmentItem, responseDeclarationId);
assessmentItem.getNodeGroups().getResponseProcessingGroup().setResponseProcessing(responseProcessing);
return assessmentItem;
}
use of uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseProcessing in project openolat by klemens.
the class HotspotAssessmentItemBuilder method createAssessmentItem.
private static AssessmentItem createAssessmentItem(String title) {
AssessmentItem assessmentItem = AssessmentItemFactory.createAssessmentItem(QTI21QuestionType.hotspot, title);
// define the response
Identifier responseDeclarationId = Identifier.assumedLegal("RESPONSE_1");
Identifier correctResponseId = IdentifierGenerator.newNumberAsIdentifier("hc");
ResponseDeclaration responseDeclaration = createHotspotEntryResponseDeclarationSingle(assessmentItem, responseDeclarationId, correctResponseId);
assessmentItem.getNodeGroups().getResponseDeclarationGroup().getResponseDeclarations().add(responseDeclaration);
// outcomes
appendDefaultOutcomeDeclarations(assessmentItem, 1.0d);
ItemBody itemBody = appendDefaultItemBody(assessmentItem);
appendHotspotInteraction(itemBody, responseDeclarationId, correctResponseId);
// response processing
ResponseProcessing responseProcessing = createResponseProcessing(assessmentItem, responseDeclarationId);
assessmentItem.getNodeGroups().getResponseProcessingGroup().setResponseProcessing(responseProcessing);
return assessmentItem;
}
Aggregations