Search in sources :

Example 1 with ItemProcessingContext

use of uk.ac.ed.ph.jqtiplus.running.ItemProcessingContext in project OpenOLAT by OpenOLAT.

the class AssessmentTreeComponentRenderer method renderItemStatus.

private void renderItemStatus(StringOutput sb, AssessmentTreeComponent component, TestPlanNode itemNode, Translator translator, RenderingRequest options) {
    ItemProcessingContext itemProcessingContext = component.getItemSessionState(itemNode);
    ItemSessionState itemSessionState = itemProcessingContext.getItemSessionState();
    renderItemStatus(sb, itemSessionState, options, translator);
}
Also used : ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) ItemProcessingContext(uk.ac.ed.ph.jqtiplus.running.ItemProcessingContext)

Example 2 with ItemProcessingContext

use of uk.ac.ed.ph.jqtiplus.running.ItemProcessingContext in project OpenOLAT by OpenOLAT.

the class AssessmentTreeComponentRenderer method renderAssessmentItemAttempts.

private void renderAssessmentItemAttempts(StringOutput sb, AssessmentTreeComponent component, TestPlanNode itemNode, Translator translator) {
    ItemProcessingContext itemProcessingContext = component.getItemSessionState(itemNode);
    ItemSessionState itemSessionState = itemProcessingContext.getItemSessionState();
    // attempts
    int numOfAttempts = itemSessionState.getNumAttempts();
    int maxAttempts = 0;
    if (itemProcessingContext instanceof ItemSessionController) {
        ItemSessionController itemSessionController = (ItemSessionController) itemProcessingContext;
        maxAttempts = itemSessionController.getItemSessionControllerSettings().getMaxAttempts();
    }
    sb.append("<span class='o_assessmentitem_attempts ");
    if (maxAttempts > 0) {
        if (maxAttempts - numOfAttempts > 0) {
            sb.append("o_assessmentitem_attempts_limited");
        } else {
            sb.append("o_assessmentitem_attempts_nomore");
        }
        String title = translator.translate("attemptsleft", new String[] { Integer.toString((maxAttempts - numOfAttempts)) });
        sb.append("' title=\"").append(StringHelper.escapeHtml(title)).append("\">");
        sb.append(numOfAttempts).append(" / ").append(Integer.toString(maxAttempts));
    } else {
        sb.append("'>").append(numOfAttempts);
    }
    sb.append("</span>");
}
Also used : ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) ItemSessionController(uk.ac.ed.ph.jqtiplus.running.ItemSessionController) ItemProcessingContext(uk.ac.ed.ph.jqtiplus.running.ItemProcessingContext)

Example 3 with ItemProcessingContext

use of uk.ac.ed.ph.jqtiplus.running.ItemProcessingContext 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 4 with ItemProcessingContext

use of uk.ac.ed.ph.jqtiplus.running.ItemProcessingContext in project openolat by klemens.

the class AssessmentTestDisplayController method suspendAssessmentTest.

/**
 * It suspend the current item
 * @return
 */
private boolean suspendAssessmentTest(Date requestTimestamp) {
    if (!deliveryOptions.isEnableSuspend() || testSessionController == null || testSessionController.getTestSessionState() == null || testSessionController.getTestSessionState().isEnded() || testSessionController.getTestSessionState().isExited() || testSessionController.getTestSessionState().isSuspended()) {
        return false;
    }
    testSessionController.touchDurations(currentRequestTimestamp);
    testSessionController.suspendTestSession(requestTimestamp);
    TestSessionState testSessionState = testSessionController.getTestSessionState();
    TestPlanNodeKey currentItemKey = testSessionState.getCurrentItemKey();
    if (currentItemKey == null) {
        return false;
    }
    TestPlanNode currentItemNode = testSessionState.getTestPlan().getNode(currentItemKey);
    ItemProcessingContext itemProcessingContext = testSessionController.getItemProcessingContext(currentItemNode);
    ItemSessionState itemSessionState = itemProcessingContext.getItemSessionState();
    if (itemProcessingContext instanceof ItemSessionController && !itemSessionState.isEnded() && !itemSessionState.isExited() && itemSessionState.isOpen() && !itemSessionState.isSuspended()) {
        ItemSessionController itemSessionController = (ItemSessionController) itemProcessingContext;
        itemSessionController.suspendItemSession(requestTimestamp);
        computeAndRecordTestAssessmentResult(requestTimestamp, testSessionState, false);
        NotificationRecorder notificationRecorder = new NotificationRecorder(NotificationLevel.INFO);
        final CandidateEvent candidateEvent = qtiService.recordCandidateTestEvent(candidateSession, testEntry, entry, CandidateTestEventType.SUSPEND, null, null, testSessionState, notificationRecorder);
        candidateAuditLogger.logCandidateEvent(candidateEvent);
        this.lastEvent = candidateEvent;
        return true;
    }
    return false;
}
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) ItemSessionController(uk.ac.ed.ph.jqtiplus.running.ItemSessionController) TestPlanNodeKey(uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey) ItemProcessingContext(uk.ac.ed.ph.jqtiplus.running.ItemProcessingContext) CandidateEvent(org.olat.ims.qti21.model.audit.CandidateEvent)

Example 5 with ItemProcessingContext

use of uk.ac.ed.ph.jqtiplus.running.ItemProcessingContext in project openolat by klemens.

the class AssessmentTreeComponentRenderer method renderItemStatus.

private void renderItemStatus(StringOutput sb, AssessmentTreeComponent component, TestPlanNode itemNode, Translator translator, RenderingRequest options) {
    ItemProcessingContext itemProcessingContext = component.getItemSessionState(itemNode);
    ItemSessionState itemSessionState = itemProcessingContext.getItemSessionState();
    renderItemStatus(sb, itemSessionState, options, translator);
}
Also used : ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) ItemProcessingContext(uk.ac.ed.ph.jqtiplus.running.ItemProcessingContext)

Aggregations

ItemProcessingContext (uk.ac.ed.ph.jqtiplus.running.ItemProcessingContext)10 ItemSessionState (uk.ac.ed.ph.jqtiplus.state.ItemSessionState)10 ItemSessionController (uk.ac.ed.ph.jqtiplus.running.ItemSessionController)8 NotificationRecorder (uk.ac.ed.ph.jqtiplus.notification.NotificationRecorder)4 TestPlanNode (uk.ac.ed.ph.jqtiplus.state.TestPlanNode)4 TestPlanNodeKey (uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey)4 TestSessionState (uk.ac.ed.ph.jqtiplus.state.TestSessionState)4 URI (java.net.URI)2 Date (java.util.Date)2 CandidateEvent (org.olat.ims.qti21.model.audit.CandidateEvent)2 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)2 ModalFeedback (uk.ac.ed.ph.jqtiplus.node.item.ModalFeedback)2 Interaction (uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction)2 ResolvedAssessmentItem (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem)2 TestSessionController (uk.ac.ed.ph.jqtiplus.running.TestSessionController)2