Search in sources :

Example 1 with AssessmentResponse

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);
    }
}
Also used : AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) HashMap(java.util.HashMap) AssessmentItemSession(org.olat.ims.qti21.AssessmentItemSession) AssessmentResponse(org.olat.ims.qti21.AssessmentResponse)

Example 2 with AssessmentResponse

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;
}
Also used : Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) LinkedHashMap(java.util.LinkedHashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) AssessmentResponse(org.olat.ims.qti21.AssessmentResponse)

Example 3 with AssessmentResponse

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;
}
Also used : AbstractEntry(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.AbstractEntry) TextEntryInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction)

Example 4 with AssessmentResponse

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);
            }
        }
    }
}
Also used : AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) RepositoryEntryRef(org.olat.repository.RepositoryEntryRef) Map(java.util.Map) AssessmentResponse(org.olat.ims.qti21.AssessmentResponse)

Example 5 with AssessmentResponse

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;
}
Also used : QtiCandidateStateException(uk.ac.ed.ph.jqtiplus.exception.QtiCandidateStateException) CandidateItemEventType(org.olat.ims.qti21.model.audit.CandidateItemEventType) HashMap(java.util.HashMap) ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) FileResponseData(uk.ac.ed.ph.jqtiplus.types.FileResponseData) StringResponseData(uk.ac.ed.ph.jqtiplus.types.StringResponseData) AssessmentResponseData(org.olat.ims.qti21.model.audit.AssessmentResponseData) ResponseData(uk.ac.ed.ph.jqtiplus.types.ResponseData) NotificationRecorder(uk.ac.ed.ph.jqtiplus.notification.NotificationRecorder) AssessmentResponse(org.olat.ims.qti21.AssessmentResponse) Date(java.util.Date) CandidateEvent(org.olat.ims.qti21.model.audit.CandidateEvent) StringInput(org.olat.ims.qti21.ui.ResponseInput.StringInput) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) StringResponseData(uk.ac.ed.ph.jqtiplus.types.StringResponseData)

Aggregations

AssessmentResponse (org.olat.ims.qti21.AssessmentResponse)22 Date (java.util.Date)12 HashMap (java.util.HashMap)12 AssessmentTestSession (org.olat.ims.qti21.AssessmentTestSession)12 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)12 AssessmentItemSession (org.olat.ims.qti21.AssessmentItemSession)10 File (java.io.File)8 CandidateEvent (org.olat.ims.qti21.model.audit.CandidateEvent)8 StringInput (org.olat.ims.qti21.ui.ResponseInput.StringInput)8 NotificationRecorder (uk.ac.ed.ph.jqtiplus.notification.NotificationRecorder)8 ItemSessionState (uk.ac.ed.ph.jqtiplus.state.ItemSessionState)8 FileResponseData (uk.ac.ed.ph.jqtiplus.types.FileResponseData)8 ResponseData (uk.ac.ed.ph.jqtiplus.types.ResponseData)8 StringResponseData (uk.ac.ed.ph.jqtiplus.types.StringResponseData)8 CandidateItemEventType (org.olat.ims.qti21.model.audit.CandidateItemEventType)6 IOException (java.io.IOException)4 AssessmentResponseData (org.olat.ims.qti21.model.audit.AssessmentResponseData)4 QtiCandidateStateException (uk.ac.ed.ph.jqtiplus.exception.QtiCandidateStateException)4 List (java.util.List)3 Identity (org.olat.core.id.Identity)3