use of uk.ac.ed.ph.jqtiplus.types.Identifier in project OpenOLAT by OpenOLAT.
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.types.Identifier in project OpenOLAT by OpenOLAT.
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.types.Identifier in project OpenOLAT by OpenOLAT.
the class QTI21ServiceImpl method getAssessmentResponses.
@Override
public Map<Identifier, AssessmentResponse> getAssessmentResponses(AssessmentItemSession assessmentItemSession) {
List<AssessmentResponse> responses = testResponseDao.getResponses(assessmentItemSession);
Map<Identifier, AssessmentResponse> responseMap = new HashMap<>();
for (AssessmentResponse response : responses) {
responseMap.put(Identifier.assumedLegal(response.getResponseIdentifier()), response);
}
return responseMap;
}
use of uk.ac.ed.ph.jqtiplus.types.Identifier in project OpenOLAT by OpenOLAT.
the class QTI21ServiceImpl method recordOutcomeVariable.
private void recordOutcomeVariable(AssessmentTestSession candidateSession, OutcomeVariable outcomeVariable, Map<Identifier, String> outcomes) {
Identifier identifier = outcomeVariable.getIdentifier();
Value computedValue = outcomeVariable.getComputedValue();
if (QtiConstants.VARIABLE_DURATION_IDENTIFIER.equals(identifier)) {
log.audit(candidateSession.getKey() + " :: " + outcomeVariable.getIdentifier() + " - " + stringifyQtiValue(computedValue));
} else if (QTI21Constants.SCORE_IDENTIFIER.equals(identifier)) {
if (computedValue instanceof NumberValue) {
double score = ((NumberValue) computedValue).doubleValue();
candidateSession.setScore(new BigDecimal(score));
}
} else if (QTI21Constants.PASS_IDENTIFIER.equals(identifier)) {
if (computedValue instanceof BooleanValue) {
boolean pass = ((BooleanValue) computedValue).booleanValue();
candidateSession.setPassed(pass);
}
}
try {
outcomes.put(identifier, stringifyQtiValue(computedValue));
} catch (Exception e) {
log.error("", e);
}
}
use of uk.ac.ed.ph.jqtiplus.types.Identifier in project OpenOLAT by OpenOLAT.
the class OrderInteractionArchive method writeInteractionData.
@Override
public int writeInteractionData(AssessmentItem item, AssessmentResponse response, Interaction interaction, int itemNumber, Row dataRow, int col, OpenXMLWorkbook workbook) {
OrderInteraction orderInteraction = (OrderInteraction) interaction;
List<SimpleChoice> choices = orderInteraction.getSimpleChoices();
if (choices.size() > 0) {
String stringuifiedResponse = response == null ? null : response.getStringuifiedResponse();
List<String> responses = CorrectResponsesUtil.parseResponses(stringuifiedResponse);
List<Identifier> correctAnswers = CorrectResponsesUtil.getCorrectOrderedIdentifierResponses(item, interaction);
for (int i = 0; i < choices.size(); i++) {
String currentResponse = null;
String currentResponseText = null;
if (responses.size() > i) {
currentResponse = currentResponseText = responses.get(i);
SimpleChoice selectedChoice = orderInteraction.getSimpleChoice(Identifier.assumedLegal(currentResponse));
if (selectedChoice != null) {
currentResponseText = getContent(selectedChoice);
}
}
String correctAnswer = null;
if (correctAnswers.size() > i) {
correctAnswer = correctAnswers.get(i).toString();
}
if (correctAnswer != null && correctAnswer.equals(currentResponse)) {
dataRow.addCell(col++, currentResponseText, workbook.getStyles().getCorrectStyle());
} else {
dataRow.addCell(col++, currentResponseText, null);
}
}
} else {
col++;
}
return col;
}
Aggregations