use of org.olat.ims.qti21.AssessmentResponse in project OpenOLAT by OpenOLAT.
the class QTI21ArchiveFormat method writeData.
/**
* The 2 lists, sessions and responses are order by the user name and the test session key.
* @param sessions A list of test sessions ordered by test session key
* @param responses A list of responses ordered by test session key
* @param exportSheet
* @param workbook
*/
private void writeData(List<AssessmentTestSession> sessions, List<AssessmentResponse> responses, OpenXMLWorksheet exportSheet, OpenXMLWorkbook workbook) {
int numOfSessions = sessions.size();
Map<AssessmentTestSession, SessionResponses> sessionToResponses = new HashMap<>();
for (int i = 0; i < numOfSessions; i++) {
AssessmentTestSession testSession = sessions.get(i);
sessionToResponses.put(testSession, new SessionResponses(testSession));
}
int numOfResponses = responses.size();
for (int j = 0; j < numOfResponses; j++) {
AssessmentResponse response = responses.get(j);
AssessmentItemSession itemSession = response.getAssessmentItemSession();
AssessmentTestSession responseTestSession = itemSession.getAssessmentTestSession();
SessionResponses sessionResponses = sessionToResponses.get(responseTestSession);
if (sessionResponses != null) {
sessionResponses.addResponse(itemSession, response);
}
}
for (int i = 0; i < numOfSessions; i++) {
AssessmentTestSession testSession = sessions.get(i);
SessionResponses sessionResponses = sessionToResponses.get(testSession);
writeDataRow(i + 2, sessionResponses, exportSheet, workbook);
}
}
use of org.olat.ims.qti21.AssessmentResponse 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 org.olat.ims.qti21.AssessmentResponse in project OpenOLAT by OpenOLAT.
the class TextEntryInteractionArchive method writeInteractionData.
@Override
public int writeInteractionData(AssessmentItem item, AssessmentResponse response, Interaction interaction, int itemNumber, Row dataRow, int col, OpenXMLWorkbook workbook) {
String stringuifiedResponses = response == null ? null : response.getStringuifiedResponse();
if (StringHelper.containsNonWhitespace(stringuifiedResponses)) {
TextEntryInteraction textEntryInteraction = (TextEntryInteraction) interaction;
AbstractEntry correctAnswers = CorrectResponsesUtil.getCorrectTextResponses(item, textEntryInteraction);
stringuifiedResponses = CorrectResponsesUtil.stripResponse(stringuifiedResponses);
boolean correct = correctAnswers.match(stringuifiedResponses);
if (correct) {
dataRow.addCell(col++, stringuifiedResponses, workbook.getStyles().getCorrectStyle());
} else {
dataRow.addCell(col++, stringuifiedResponses, null);
}
} else {
col++;
}
return col;
}
use of org.olat.ims.qti21.AssessmentResponse in project OpenOLAT by OpenOLAT.
the class AuditLogFormatter method log.
protected static void log(CandidateEvent candidateEvent, Map<Identifier, AssessmentResponse> candidateResponseMap, Writer writer) throws IOException {
writer.append("QTI21 audit [");
AssessmentTestSession testSession = candidateEvent.getCandidateSession();
if (testSession != null) {
RepositoryEntryRef testEntry = candidateEvent.getTestEntry();
RepositoryEntryRef courseEntry = candidateEvent.getRepositoryEntry();
if (courseEntry != null && !testEntry.getKey().equals(courseEntry.getKey())) {
writer.write(courseEntry.getKey().toString());
writer.write(":");
if (testSession.getSubIdent() == null) {
writer.write("NULL:");
} else {
writer.write(testSession.getSubIdent());
writer.write(":");
}
}
if (testEntry != null) {
writer.write(testEntry.getKey().toString());
}
}
writer.write("] ");
if (candidateEvent.getTestEventType() != null) {
writer.append("TestEvent:");
writer.append(candidateEvent.getTestEventType().toString());
writer.write(" ");
}
if (candidateEvent.getItemEventType() != null) {
writer.append("ItemEvent:");
writer.append(candidateEvent.getItemEventType().toString());
writer.write(" ");
}
if (candidateEvent.getTestItemKey() != null) {
writer.append("TestItemKey[");
writer.append(candidateEvent.getTestItemKey());
writer.write("] ");
}
if (candidateResponseMap != null) {
writer.write("params=");
for (Map.Entry<Identifier, AssessmentResponse> responseEntry : candidateResponseMap.entrySet()) {
Identifier identifier = responseEntry.getKey();
AssessmentResponse response = responseEntry.getValue();
writer.append("|");
writer.append(identifier.toString());
writer.append("=");
String stringuifiedResponse = response.getStringuifiedResponse();
if (stringuifiedResponse == null) {
writer.append("NULL");
} else {
writer.append(stringuifiedResponse);
}
}
}
}
use of org.olat.ims.qti21.AssessmentResponse in project OpenOLAT by OpenOLAT.
the class AssessmentItemDisplayController method handleTemporaryResponses.
public void handleTemporaryResponses(UserRequest ureq, Map<Identifier, ResponseInput> stringResponseMap) {
/* Retrieve current JQTI state and set up JQTI controller */
NotificationRecorder notificationRecorder = new NotificationRecorder(NotificationLevel.INFO);
ItemSessionState itemSessionState = itemSessionController.getItemSessionState();
/* Make sure an attempt is allowed */
if (itemSessionState.isEnded()) {
candidateAuditLogger.logAndThrowCandidateException(candidateSession, CandidateExceptionReason.RESPONSES_NOT_EXPECTED, null);
logError("RESPONSES_NOT_EXPECTED", null);
return;
}
/* Build response map in required format for JQTI+.
* NB: The following doesn't test for duplicate keys in the two maps. I'm not sure
* it's worth the effort.
*/
final Map<Identifier, ResponseData> responseDataMap = new HashMap<>();
final Map<Identifier, AssessmentResponse> assessmentResponseDataMap = new HashMap<>();
if (stringResponseMap != null) {
for (final Entry<Identifier, ResponseInput> stringResponseEntry : stringResponseMap.entrySet()) {
Identifier identifier = stringResponseEntry.getKey();
ResponseInput responseData = stringResponseEntry.getValue();
if (responseData instanceof StringInput) {
responseDataMap.put(identifier, new StringResponseData(((StringInput) responseData).getResponseData()));
}
}
}
final Date timestamp = ureq.getRequestTimestamp();
/* Attempt to bind responses */
boolean allResponsesValid = false;
boolean allResponsesBound = false;
try {
itemSessionController.bindResponses(timestamp, responseDataMap);
} catch (final QtiCandidateStateException e) {
candidateAuditLogger.logAndThrowCandidateException(candidateSession, CandidateExceptionReason.RESPONSES_NOT_EXPECTED, null);
logError("RESPONSES_NOT_EXPECTED", e);
return;
} catch (final RuntimeException e) {
logError("", e);
return;
}
/* Record resulting attempt and event */
final CandidateItemEventType eventType = allResponsesBound ? (allResponsesValid ? CandidateItemEventType.ATTEMPT_VALID : CandidateItemEventType.RESPONSE_INVALID) : CandidateItemEventType.RESPONSE_BAD;
final CandidateEvent candidateEvent = qtiService.recordCandidateItemEvent(candidateSession, null, entry, eventType, itemSessionState, notificationRecorder);
candidateAuditLogger.logCandidateEvent(candidateEvent, assessmentResponseDataMap);
lastEvent = candidateEvent;
}
Aggregations