Search in sources :

Example 16 with TestSessionState

use of uk.ac.ed.ph.jqtiplus.state.TestSessionState in project OpenOLAT by OpenOLAT.

the class CorrectionIdentityAssessmentItemListController method doSelect.

private void doSelect(UserRequest ureq, CorrectionIdentityAssessmentItemRow row) {
    removeAsListenerAndDispose(identityItemCtrl);
    doUnlock();
    AssessmentItemRef itemRef = row.getItemRef();
    TestSessionState testSessionState = qtiService.loadTestSessionState(candidateSession);
    List<TestPlanNode> nodes = testSessionState.getTestPlan().getNodes(itemRef.getIdentifier());
    AssessmentItemSession reloadItemSession = null;
    if (nodes.size() == 1) {
        TestPlanNode itemNode = nodes.get(0);
        String stringuifiedIdentifier = itemNode.getKey().getIdentifier().toString();
        ParentPartItemRefs parentParts = AssessmentTestHelper.getParentSection(itemNode.getKey(), testSessionState, model.getResolvedAssessmentTest());
        reloadItemSession = qtiService.getOrCreateAssessmentItemSession(candidateSession, parentParts, stringuifiedIdentifier);
    }
    // lock on item, need to check the lock on identity / test
    String lockSubKey = "item-" + reloadItemSession.getKey();
    OLATResourceable testOres = OresHelper.clone(model.getTestEntry().getOlatResource());
    lockResult = CoordinatorManager.getInstance().getCoordinator().getLocker().acquireLock(testOres, getIdentity(), lockSubKey);
    if (lockResult.isSuccess()) {
        if (nodes.size() == 1) {
            TestPlanNode itemNode = nodes.get(0);
            ItemSessionState itemSessionState = testSessionState.getItemSessionStates().get(itemNode.getKey());
            AssessmentItemCorrection itemCorrection = new AssessmentItemCorrection(assessedIdentity, candidateSession, testSessionState, reloadItemSession, itemSessionState, itemRef, itemNode);
            itemCorrection.setItemSession(reloadItemSession);
            ResolvedAssessmentItem resolvedAssessmentItem = model.getResolvedAssessmentTest().getResolvedAssessmentItem(itemRef);
            AssessmentItem assessmentItem = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
            identityItemCtrl = new CorrectionIdentityAssessmentItemNavigationController(ureq, getWindowControl(), model.getTestEntry(), model.getResolvedAssessmentTest(), itemCorrection, row, tableModel.getObjects(), model);
            listenTo(identityItemCtrl);
            stackPanel.pushController(assessmentItem.getTitle(), identityItemCtrl);
            updatePreviousNext();
        }
    } else {
        String lockOwnerName = userManager.getUserDisplayName(lockResult.getOwner());
        showWarning("warning.assessment.item.locked", new String[] { lockOwnerName });
    }
}
Also used : TestPlanNode(uk.ac.ed.ph.jqtiplus.state.TestPlanNode) ParentPartItemRefs(org.olat.ims.qti21.model.ParentPartItemRefs) TestSessionState(uk.ac.ed.ph.jqtiplus.state.TestSessionState) OLATResourceable(org.olat.core.id.OLATResourceable) ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) AssessmentItemCorrection(org.olat.ims.qti21.ui.assessment.model.AssessmentItemCorrection) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItemSession(org.olat.ims.qti21.AssessmentItemSession) AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef)

Example 17 with TestSessionState

use of uk.ac.ed.ph.jqtiplus.state.TestSessionState in project OpenOLAT by OpenOLAT.

the class CorrectionIdentityAssessmentItemController method doSave.

private void doSave() {
    TestSessionState testSessionState = itemCorrection.getTestSessionState();
    AssessmentTestSession candidateSession = itemCorrection.getTestSession();
    try (AssessmentSessionAuditLogger candidateAuditLogger = qtiService.getAssessmentSessionAuditLogger(candidateSession, false)) {
        TestPlanNodeKey testPlanNodeKey = itemCorrection.getItemNode().getKey();
        String stringuifiedIdentifier = testPlanNodeKey.getIdentifier().toString();
        ParentPartItemRefs parentParts = AssessmentTestHelper.getParentSection(testPlanNodeKey, testSessionState, resolvedAssessmentTest);
        AssessmentItemSession itemSession = qtiService.getOrCreateAssessmentItemSession(candidateSession, parentParts, stringuifiedIdentifier);
        itemSession.setManualScore(identityInteractionsCtrl.getManualScore());
        itemSession.setCoachComment(identityInteractionsCtrl.getComment());
        itemSession.setToReview(identityInteractionsCtrl.isToReview());
        itemSession = qtiService.updateAssessmentItemSession(itemSession);
        itemCorrection.setItemSession(itemSession);
        candidateAuditLogger.logCorrection(candidateSession, itemSession, getIdentity());
        candidateSession = qtiService.recalculateAssessmentTestSessionScores(candidateSession.getKey());
        itemCorrection.setTestSession(candidateSession);
        model.updateLastSession(itemCorrection.getAssessedIdentity(), candidateSession);
    } catch (IOException e) {
        logError("", e);
    }
}
Also used : ParentPartItemRefs(org.olat.ims.qti21.model.ParentPartItemRefs) AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) TestSessionState(uk.ac.ed.ph.jqtiplus.state.TestSessionState) AssessmentItemSession(org.olat.ims.qti21.AssessmentItemSession) AssessmentSessionAuditLogger(org.olat.ims.qti21.AssessmentSessionAuditLogger) IOException(java.io.IOException) TestPlanNodeKey(uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey)

Example 18 with TestSessionState

use of uk.ac.ed.ph.jqtiplus.state.TestSessionState in project openolat by klemens.

the class AssessmentTestDisplayController method resumeSession.

private TestSessionController resumeSession(UserRequest ureq) {
    Date requestTimestamp = ureq.getRequestTimestamp();
    final NotificationRecorder notificationRecorder = new NotificationRecorder(NotificationLevel.INFO);
    TestSessionController controller = createTestSessionController(notificationRecorder);
    if (!controller.getTestSessionState().isEnded() && !controller.getTestSessionState().isExited()) {
        controller.unsuspendTestSession(requestTimestamp);
        TestSessionState testSessionState = controller.getTestSessionState();
        TestPlanNodeKey currentItemKey = testSessionState.getCurrentItemKey();
        if (currentItemKey != null) {
            TestPlanNode currentItemNode = testSessionState.getTestPlan().getNode(currentItemKey);
            ItemProcessingContext itemProcessingContext = controller.getItemProcessingContext(currentItemNode);
            ItemSessionState itemSessionState = itemProcessingContext.getItemSessionState();
            if (itemProcessingContext instanceof ItemSessionController && itemSessionState.isSuspended()) {
                ItemSessionController itemSessionController = (ItemSessionController) itemProcessingContext;
                itemSessionController.unsuspendItemSession(requestTimestamp);
            }
        }
    }
    return controller;
}
Also used : TestPlanNode(uk.ac.ed.ph.jqtiplus.state.TestPlanNode) TestSessionState(uk.ac.ed.ph.jqtiplus.state.TestSessionState) ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) NotificationRecorder(uk.ac.ed.ph.jqtiplus.notification.NotificationRecorder) TestSessionController(uk.ac.ed.ph.jqtiplus.running.TestSessionController) ItemSessionController(uk.ac.ed.ph.jqtiplus.running.ItemSessionController) Date(java.util.Date) TestPlanNodeKey(uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey) ItemProcessingContext(uk.ac.ed.ph.jqtiplus.running.ItemProcessingContext)

Example 19 with TestSessionState

use of uk.ac.ed.ph.jqtiplus.state.TestSessionState in project openolat by klemens.

the class AssessmentTestDisplayController method processReviewTestPart.

private void processReviewTestPart() {
    NotificationRecorder notificationRecorder = new NotificationRecorder(NotificationLevel.INFO);
    TestSessionState testSessionState = testSessionController.getTestSessionState();
    // assertSessionNotTerminated(candidateSession);
    if (testSessionState.getCurrentTestPartKey() == null || !testSessionState.getCurrentTestPartSessionState().isEnded()) {
        candidateAuditLogger.logAndThrowCandidateException(candidateSession, CandidateExceptionReason.CANNOT_REVIEW_TEST_PART, null);
        logError("CANNOT_REVIEW_TEST_PART", null);
        return;
    }
    /* Record and log event */
    final CandidateEvent candidateTestEvent = qtiService.recordCandidateTestEvent(candidateSession, testEntry, entry, CandidateTestEventType.REVIEW_TEST_PART, null, null, testSessionState, notificationRecorder);
    candidateAuditLogger.logCandidateEvent(candidateTestEvent);
    this.lastEvent = candidateTestEvent;
}
Also used : TestSessionState(uk.ac.ed.ph.jqtiplus.state.TestSessionState) NotificationRecorder(uk.ac.ed.ph.jqtiplus.notification.NotificationRecorder) CandidateEvent(org.olat.ims.qti21.model.audit.CandidateEvent)

Example 20 with TestSessionState

use of uk.ac.ed.ph.jqtiplus.state.TestSessionState in project openolat by klemens.

the class AssessmentTestDisplayController method processExitTest.

/**
 * Exit multi-part tests
 */
private void processExitTest(UserRequest ureq) {
    NotificationRecorder notificationRecorder = new NotificationRecorder(NotificationLevel.INFO);
    TestSessionState testSessionState = testSessionController.getTestSessionState();
    /* Perform action */
    final Date currentTimestamp = ureq.getRequestTimestamp();
    try {
        testSessionController.exitTest(currentTimestamp);
    } catch (final QtiCandidateStateException e) {
        candidateAuditLogger.logAndThrowCandidateException(candidateSession, CandidateExceptionReason.CANNOT_EXIT_TEST, e);
        logError("CANNOT_EXIT_TEST", null);
        return;
    } catch (final RuntimeException e) {
        candidateAuditLogger.logAndThrowCandidateException(candidateSession, CandidateExceptionReason.CANNOT_EXIT_TEST, e);
        logError("Exploded", null);
        // handleExplosion(e, candidateSession);
        return;
    }
    /* Update CandidateSession as appropriate */
    candidateSession.setTerminationTime(currentTimestamp);
    candidateSession = qtiService.updateAssessmentTestSession(candidateSession);
    /* Record current result state (final) */
    computeAndRecordTestAssessmentResult(currentTimestamp, testSessionState, true);
    /* Record and log event */
    final CandidateEvent candidateTestEvent = qtiService.recordCandidateTestEvent(candidateSession, testEntry, entry, CandidateTestEventType.EXIT_TEST, testSessionState, notificationRecorder);
    candidateAuditLogger.logCandidateEvent(candidateTestEvent);
    this.lastEvent = candidateTestEvent;
    doExitTest(ureq);
}
Also used : QtiCandidateStateException(uk.ac.ed.ph.jqtiplus.exception.QtiCandidateStateException) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) TestSessionState(uk.ac.ed.ph.jqtiplus.state.TestSessionState) NotificationRecorder(uk.ac.ed.ph.jqtiplus.notification.NotificationRecorder) Date(java.util.Date) CandidateEvent(org.olat.ims.qti21.model.audit.CandidateEvent)

Aggregations

TestSessionState (uk.ac.ed.ph.jqtiplus.state.TestSessionState)78 TestPlanNodeKey (uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey)42 CandidateEvent (org.olat.ims.qti21.model.audit.CandidateEvent)34 TestPlanNode (uk.ac.ed.ph.jqtiplus.state.TestPlanNode)32 NotificationRecorder (uk.ac.ed.ph.jqtiplus.notification.NotificationRecorder)30 Date (java.util.Date)24 ItemSessionState (uk.ac.ed.ph.jqtiplus.state.ItemSessionState)24 AssessmentTestSession (org.olat.ims.qti21.AssessmentTestSession)19 OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)18 AssessmentItemSession (org.olat.ims.qti21.AssessmentItemSession)18 HashMap (java.util.HashMap)15 QtiCandidateStateException (uk.ac.ed.ph.jqtiplus.exception.QtiCandidateStateException)13 AssessmentResult (uk.ac.ed.ph.jqtiplus.node.result.AssessmentResult)12 TestSessionController (uk.ac.ed.ph.jqtiplus.running.TestSessionController)12 ArrayList (java.util.ArrayList)10 CandidateTestEventType (org.olat.ims.qti21.model.audit.CandidateTestEventType)10 AssessmentItemRef (uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef)10 Identity (org.olat.core.id.Identity)9 File (java.io.File)8 ParentPartItemRefs (org.olat.ims.qti21.model.ParentPartItemRefs)8