use of uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseProcessing in project openolat by klemens.
the class FIBAssessmentItemBuilder method createAssessmentItem.
private static AssessmentItem createAssessmentItem(String title, EntryType type) {
AssessmentItem assessmentItem = AssessmentItemFactory.createAssessmentItem(QTI21QuestionType.fib, title);
// define the response
Identifier responseDeclarationId = Identifier.assumedLegal("RESPONSE_1");
if (type == EntryType.numerical) {
ResponseDeclaration responseDeclaration = createNumericalEntryResponseDeclaration(assessmentItem, responseDeclarationId, 42);
assessmentItem.getNodeGroups().getResponseDeclarationGroup().getResponseDeclarations().add(responseDeclaration);
} else {
ResponseDeclaration responseDeclaration = createTextEntryResponseDeclaration(assessmentItem, responseDeclarationId, "gap", Collections.emptyList());
assessmentItem.getNodeGroups().getResponseDeclarationGroup().getResponseDeclarations().add(responseDeclaration);
}
// outcomes
appendDefaultOutcomeDeclarations(assessmentItem, 1.0d);
ItemBody itemBody = appendDefaultItemBody(assessmentItem);
appendTextEntryInteraction(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 klemens.
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 MatchAssessmentItemBuilder method createAssessmentItem.
private static AssessmentItem createAssessmentItem(String title, String matchCssClass, String unanswered, String right, String wrong) {
AssessmentItem assessmentItem = AssessmentItemFactory.createAssessmentItem(QTI21QuestionType.match, title);
NodeGroupList nodeGroups = assessmentItem.getNodeGroups();
double maxScore = 1.0d;
Identifier responseDeclarationId = Identifier.assumedLegal("RESPONSE_1");
// define correct answer
ResponseDeclaration responseDeclaration = createMatchResponseDeclaration(assessmentItem, responseDeclarationId, new HashMap<>());
nodeGroups.getResponseDeclarationGroup().getResponseDeclarations().add(responseDeclaration);
appendDefaultOutcomeDeclarations(assessmentItem, maxScore);
// the single choice interaction
ItemBody itemBody = appendDefaultItemBody(assessmentItem);
Map<Identifier, List<Identifier>> associations = new HashMap<>();
MatchInteraction interaction;
if (QTI21Constants.CSS_MATCH_TRUE_FALSE.equals(matchCssClass)) {
interaction = appendMatchInteractionTrueFalse(itemBody, unanswered, right, wrong, responseDeclarationId);
// default correct answers set to "right"
SimpleAssociableChoice rightChoice = interaction.getSimpleMatchSets().get(1).getSimpleAssociableChoices().get(1);
List<SimpleAssociableChoice> sourceChoices = interaction.getSimpleMatchSets().get(0).getSimpleAssociableChoices();
for (SimpleAssociableChoice sourceChoice : sourceChoices) {
List<Identifier> targetIdentifiers = new ArrayList<>();
targetIdentifiers.add(rightChoice.getIdentifier());
associations.put(sourceChoice.getIdentifier(), targetIdentifiers);
}
} else {
interaction = appendMatchInteraction(itemBody, responseDeclarationId);
}
List<String> cssClasses = new ArrayList<>();
cssClasses.add(matchCssClass);
interaction.setClassAttr(cssClasses);
appendAssociationMatchResponseDeclaration(responseDeclaration, associations);
// 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 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.processing.ResponseProcessing in project openolat by klemens.
the class DrawingAssessmentItemBuilder method createAssessmentItem.
private static AssessmentItem createAssessmentItem(String title) {
AssessmentItem assessmentItem = AssessmentItemFactory.createAssessmentItem(QTI21QuestionType.drawing, title);
// define the response
Identifier responseDeclarationId = Identifier.assumedLegal("RESPONSE_1");
ResponseDeclaration responseDeclaration = createDrawingResponseDeclaration(assessmentItem, responseDeclarationId);
assessmentItem.getNodeGroups().getResponseDeclarationGroup().getResponseDeclarations().add(responseDeclaration);
// outcomes
appendDefaultOutcomeDeclarations(assessmentItem, 1.0d);
ItemBody itemBody = appendDefaultItemBody(assessmentItem);
appendDrawingInteraction(itemBody, responseDeclarationId);
// response processing
ResponseProcessing responseProcessing = createResponseProcessing(assessmentItem, responseDeclarationId);
assessmentItem.getNodeGroups().getResponseProcessingGroup().setResponseProcessing(responseProcessing);
return assessmentItem;
}
Aggregations