Search in sources :

Example 1 with AssessmentResult

use of uk.ac.ed.ph.jqtiplus.node.result.AssessmentResult in project OpenOLAT by OpenOLAT.

the class QTI21ServiceImpl method getAssessmentResult.

@Override
public AssessmentResult getAssessmentResult(AssessmentTestSession candidateSession) {
    File assessmentResultFile = getAssessmentResultFile(candidateSession);
    ResourceLocator fileResourceLocator = new PathResourceLocator(assessmentResultFile.getParentFile().toPath());
    ResourceLocator inputResourceLocator = ImsQTI21Resource.createResolvingResourceLocator(fileResourceLocator);
    URI assessmentResultUri = assessmentResultFile.toURI();
    QtiObjectReader qtiObjectReader = qtiXmlReader().createQtiObjectReader(inputResourceLocator, false, false);
    try {
        QtiObjectReadResult<AssessmentResult> result = qtiObjectReader.lookupRootNode(assessmentResultUri, AssessmentResult.class);
        return result.getRootNode();
    } catch (XmlResourceNotFoundException | QtiXmlInterpretationException | ClassCastException e) {
        log.error("", e);
        return null;
    }
}
Also used : ClassPathResourceLocator(uk.ac.ed.ph.jqtiplus.xmlutils.locators.ClassPathResourceLocator) PathResourceLocator(org.olat.fileresource.types.ImsQTI21Resource.PathResourceLocator) XmlResourceNotFoundException(uk.ac.ed.ph.jqtiplus.xmlutils.XmlResourceNotFoundException) QtiXmlInterpretationException(uk.ac.ed.ph.jqtiplus.reading.QtiXmlInterpretationException) QtiObjectReader(uk.ac.ed.ph.jqtiplus.reading.QtiObjectReader) File(java.io.File) URI(java.net.URI) AssessmentResult(uk.ac.ed.ph.jqtiplus.node.result.AssessmentResult) ClassPathResourceLocator(uk.ac.ed.ph.jqtiplus.xmlutils.locators.ClassPathResourceLocator) ResourceLocator(uk.ac.ed.ph.jqtiplus.xmlutils.locators.ResourceLocator) PathResourceLocator(org.olat.fileresource.types.ImsQTI21Resource.PathResourceLocator)

Example 2 with AssessmentResult

use of uk.ac.ed.ph.jqtiplus.node.result.AssessmentResult in project OpenOLAT by OpenOLAT.

the class AssessmentItemDisplayController method computeAndRecordItemAssessmentResult.

public AssessmentResult computeAndRecordItemAssessmentResult(UserRequest ureq) {
    final AssessmentResult assessmentResult = computeItemAssessmentResult(ureq);
    qtiService.recordItemAssessmentResult(candidateSession, assessmentResult, candidateAuditLogger);
    return assessmentResult;
}
Also used : AssessmentResult(uk.ac.ed.ph.jqtiplus.node.result.AssessmentResult)

Example 3 with AssessmentResult

use of uk.ac.ed.ph.jqtiplus.node.result.AssessmentResult in project OpenOLAT by OpenOLAT.

the class AssessmentItemDisplayController method enterSession.

private ItemSessionController enterSession(UserRequest ureq) /*, final UserTestSession candidateSession */
{
    /* Set up listener to record any notifications */
    final NotificationRecorder notificationRecorder = new NotificationRecorder(NotificationLevel.INFO);
    /* Create fresh JQTI+ state Object and try to create controller */
    itemSessionController = createNewItemSessionStateAndController(notificationRecorder);
    if (itemSessionController == null) {
        logError("Cannot create item session controller for:" + itemFileRef, null);
        return null;
    }
    /* Try to Initialise JQTI+ state */
    final ItemSessionState itemSessionState = itemSessionController.getItemSessionState();
    try {
        final Date timestamp = ureq.getRequestTimestamp();
        itemSessionController.initialize(timestamp);
        itemSessionController.performTemplateProcessing(timestamp);
        itemSessionController.enterItem(timestamp);
    } catch (final RuntimeException e) {
        logError("", e);
        return null;
    }
    /* Record and log entry event */
    final CandidateEvent candidateEvent = qtiService.recordCandidateItemEvent(candidateSession, null, entry, CandidateItemEventType.ENTER, itemSessionState, notificationRecorder);
    candidateAuditLogger.logCandidateEvent(candidateEvent);
    lastEvent = candidateEvent;
    /* Record current result state */
    final AssessmentResult assessmentResult = computeAndRecordItemAssessmentResult(ureq);
    /* Handle immediate end of session */
    if (itemSessionState.isEnded()) {
        qtiService.finishItemSession(candidateSession, assessmentResult, ureq.getRequestTimestamp());
    }
    return itemSessionController;
}
Also used : ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) NotificationRecorder(uk.ac.ed.ph.jqtiplus.notification.NotificationRecorder) AssessmentResult(uk.ac.ed.ph.jqtiplus.node.result.AssessmentResult) Date(java.util.Date) CandidateEvent(org.olat.ims.qti21.model.audit.CandidateEvent)

Example 4 with AssessmentResult

use of uk.ac.ed.ph.jqtiplus.node.result.AssessmentResult in project OpenOLAT by OpenOLAT.

the class AssessmentItemDisplayController method endSession.

public void endSession(UserRequest ureq) {
    NotificationRecorder notificationRecorder = new NotificationRecorder(NotificationLevel.INFO);
    // final ItemSessionController itemSessionController = candidateDataService.createItemSessionController(mostRecentEvent, notificationRecorder);
    ItemSessionState itemSessionState = itemSessionController.getItemSessionState();
    if (itemSessionState.isEnded()) {
        logError("END_SESSION_WHEN_ALREADY_ENDED", null);
        candidateAuditLogger.logAndThrowCandidateException(candidateSession, CandidateExceptionReason.END_SESSION_WHEN_ALREADY_ENDED, null);
        return;
    }
    /* else if (!itemDeliverySettings.isAllowEnd()) {
            candidateAuditLogger.logAndThrowCandidateException(candidateSession, CandidateExceptionReason.END_SESSION_WHEN_INTERACTING_FORBIDDEN);
            return null;
        }*/
    /* Update state */
    final Date timestamp = ureq.getRequestTimestamp();
    try {
        itemSessionController.endItem(timestamp);
    } catch (QtiCandidateStateException e) {
        String msg = itemSessionState.isEnded() ? "END_SESSION_WHEN_ALREADY_ENDED" : "END_SESSION_WHEN_INTERACTING_FORBIDDEN";
        logError(msg, e);
        candidateAuditLogger.logAndThrowCandidateException(candidateSession, itemSessionState.isEnded() ? CandidateExceptionReason.END_SESSION_WHEN_ALREADY_ENDED : CandidateExceptionReason.END_SESSION_WHEN_INTERACTING_FORBIDDEN, null);
        return;
    } catch (final RuntimeException e) {
        logError("", e);
        // handleExplosion(e, candidateSession);
        return;
    }
    /* Record current result state */
    final AssessmentResult assessmentResult = computeAndRecordItemAssessmentResult(ureq);
    /* Record and log event */
    final CandidateEvent candidateEvent = qtiService.recordCandidateItemEvent(candidateSession, null, entry, CandidateItemEventType.END, itemSessionState, notificationRecorder);
    candidateAuditLogger.logCandidateEvent(candidateEvent);
    lastEvent = candidateEvent;
    /* Close session */
    qtiService.finishItemSession(candidateSession, assessmentResult, timestamp);
}
Also used : QtiCandidateStateException(uk.ac.ed.ph.jqtiplus.exception.QtiCandidateStateException) ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) NotificationRecorder(uk.ac.ed.ph.jqtiplus.notification.NotificationRecorder) AssessmentResult(uk.ac.ed.ph.jqtiplus.node.result.AssessmentResult) Date(java.util.Date) CandidateEvent(org.olat.ims.qti21.model.audit.CandidateEvent)

Example 5 with AssessmentResult

use of uk.ac.ed.ph.jqtiplus.node.result.AssessmentResult in project OpenOLAT by OpenOLAT.

the class AssessmentTestDisplayController method enterSession.

// private CandidateSession enterCandidateSession(final CandidateSession candidateSession)
private TestSessionController enterSession(UserRequest ureq) {
    /* Set up listener to record any notifications */
    final NotificationRecorder notificationRecorder = new NotificationRecorder(NotificationLevel.INFO);
    /* Create fresh JQTI+ state & controller for it */
    testSessionController = createNewTestSessionStateAndController(notificationRecorder);
    if (testSessionController == null) {
        return null;
    }
    /* Initialise test state and enter test */
    final TestSessionState testSessionState = testSessionController.getTestSessionState();
    final Date timestamp = ureq.getRequestTimestamp();
    try {
        testSessionController.initialize(timestamp);
        final int testPartCount = testSessionController.enterTest(timestamp);
        if (testPartCount == 1) {
            /* If there is only testPart, then enter this (if possible).
                 * (Note that this may cause the test to exit immediately if there is a failed
                 * preCondition on this part.)
                 */
            testSessionController.enterNextAvailableTestPart(timestamp);
        } else {
        /* Don't enter first testPart yet - we shall tell candidate that
                 * there are multiple parts and let them enter manually.
                 */
        }
    } catch (final RuntimeException e) {
        logError("", e);
        return null;
    }
    /* Record and log event */
    final CandidateEvent candidateEvent = qtiService.recordCandidateTestEvent(candidateSession, testEntry, entry, CandidateTestEventType.ENTER_TEST, testSessionState, notificationRecorder);
    candidateAuditLogger.logCandidateEvent(candidateEvent);
    this.lastEvent = candidateEvent;
    boolean ended = testSessionState.isEnded();
    /* Record current result state */
    final AssessmentResult assessmentResult = computeAndRecordTestAssessmentResult(timestamp, testSessionState, ended);
    /* Handle immediate end of test session */
    if (ended) {
        candidateSession = qtiService.finishTestSession(candidateSession, testSessionState, assessmentResult, timestamp, getDigitalSignatureOptions(), getIdentity());
    } else {
        TestPart currentTestPart = testSessionController.getCurrentTestPart();
        if (currentTestPart != null && currentTestPart.getNavigationMode() == NavigationMode.NONLINEAR) {
            // go to the first assessment item
            if (testSessionController.hasFollowingNonLinearItem()) {
                testSessionController.selectFollowingItemNonLinear(currentRequestTimestamp);
            }
        }
    }
    return testSessionController;
}
Also used : OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) TestSessionState(uk.ac.ed.ph.jqtiplus.state.TestSessionState) TestPart(uk.ac.ed.ph.jqtiplus.node.test.TestPart) NotificationRecorder(uk.ac.ed.ph.jqtiplus.notification.NotificationRecorder) AssessmentResult(uk.ac.ed.ph.jqtiplus.node.result.AssessmentResult) Date(java.util.Date) CandidateEvent(org.olat.ims.qti21.model.audit.CandidateEvent)

Aggregations

AssessmentResult (uk.ac.ed.ph.jqtiplus.node.result.AssessmentResult)30 Date (java.util.Date)20 CandidateEvent (org.olat.ims.qti21.model.audit.CandidateEvent)20 NotificationRecorder (uk.ac.ed.ph.jqtiplus.notification.NotificationRecorder)16 ItemSessionState (uk.ac.ed.ph.jqtiplus.state.ItemSessionState)14 TestSessionState (uk.ac.ed.ph.jqtiplus.state.TestSessionState)12 OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)10 QtiCandidateStateException (uk.ac.ed.ph.jqtiplus.exception.QtiCandidateStateException)7 TestPlanNode (uk.ac.ed.ph.jqtiplus.state.TestPlanNode)6 File (java.io.File)4 HashMap (java.util.HashMap)4 List (java.util.List)4 AssessmentItemSession (org.olat.ims.qti21.AssessmentItemSession)4 AssessmentResponse (org.olat.ims.qti21.AssessmentResponse)4 ParentPartItemRefs (org.olat.ims.qti21.model.ParentPartItemRefs)4 CandidateTestEventType (org.olat.ims.qti21.model.audit.CandidateTestEventType)4 StringInput (org.olat.ims.qti21.ui.ResponseInput.StringInput)4 TestPlanNodeKey (uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey)4 FileResponseData (uk.ac.ed.ph.jqtiplus.types.FileResponseData)4 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)4