use of uk.ac.ed.ph.jqtiplus.node.content.ItemBody 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.content.ItemBody 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;
}
use of uk.ac.ed.ph.jqtiplus.node.content.ItemBody 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.content.ItemBody in project openolat by klemens.
the class AlienItemAnalyzer method checkItemBody.
/**
* Check if there are text after the interaction
*/
private void checkItemBody(Report report) {
if (report.getType() == QTI21QuestionType.sc || report.getType() == QTI21QuestionType.mc || report.getType() == QTI21QuestionType.kprim || report.getType() == QTI21QuestionType.match || report.getType() == QTI21QuestionType.matchdraganddrop || report.getType() == QTI21QuestionType.hotspot || report.getType() == QTI21QuestionType.essay || report.getType() == QTI21QuestionType.upload) {
ItemBody itemBody = item.getItemBody();
List<Block> blocks = itemBody.getBlocks();
Block lastBlock = blocks.get(blocks.size() - 1);
if (!(lastBlock instanceof Interaction)) {
report.addWarning(ReportWarningEnum.textAfterInteraction);
}
}
}
use of uk.ac.ed.ph.jqtiplus.node.content.ItemBody 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;
}
Aggregations