Search in sources :

Example 6 with TestPlanNode

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

the class AssessmentTestDisplayController method confirmAdvanceTestPart.

/**
 * In the case of a multi-part test, the entry to the first part
 * must not be confirmed.
 * @param ureq
 */
private void confirmAdvanceTestPart(UserRequest ureq) {
    TestPlanNode nextTestPart = testSessionController.findNextEnterableTestPart();
    if (nextTestPart == null) {
        String title = translate("confirm.close.test.title");
        String text = translate("confirm.close.test.text");
        advanceTestPartDialog = activateOkCancelDialog(ureq, title, text, advanceTestPartDialog);
    } else {
        TestPart currentTestPart = testSessionController.getCurrentTestPart();
        if (currentTestPart == null) {
            processAdvanceTestPart(ureq);
        } else {
            String title = translate("confirm.advance.testpart.title");
            String text = translate("confirm.advance.testpart.text");
            advanceTestPartDialog = activateOkCancelDialog(ureq, title, text, advanceTestPartDialog);
        }
    }
}
Also used : TestPlanNode(uk.ac.ed.ph.jqtiplus.state.TestPlanNode) TestPart(uk.ac.ed.ph.jqtiplus.node.test.TestPart)

Example 7 with TestPlanNode

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

the class AssessmentTestDisplayController method handleTemporaryResponse.

private void handleTemporaryResponse(UserRequest ureq, Map<Identifier, ResponseInput> stringResponseMap) {
    NotificationRecorder notificationRecorder = new NotificationRecorder(NotificationLevel.INFO);
    TestSessionState testSessionState = testSessionController.getTestSessionState();
    TestPlanNodeKey currentItemKey = testSessionState.getCurrentItemKey();
    if (currentItemKey == null) {
        // 
        return;
    }
    String cmd = ureq.getParameter("tmpResponse");
    if (!qtiWorksCtrl.validateResponseIdentifierCommand(cmd, currentItemKey)) {
        // this is not the right node in the plan
        return;
    }
    final Date timestamp = ureq.getRequestTimestamp();
    final Map<Identifier, ResponseData> responseDataMap = new HashMap<>();
    if (stringResponseMap != null) {
        for (final Entry<Identifier, ResponseInput> responseEntry : stringResponseMap.entrySet()) {
            final Identifier identifier = responseEntry.getKey();
            final ResponseInput responseData = responseEntry.getValue();
            if (responseData instanceof StringInput) {
                responseDataMap.put(identifier, new StringResponseData(((StringInput) responseData).getResponseData()));
            }
        }
    }
    ParentPartItemRefs parentParts = getParentSection(currentItemKey);
    String assessmentItemIdentifier = currentItemKey.getIdentifier().toString();
    AssessmentItemSession itemSession = qtiService.getOrCreateAssessmentItemSession(candidateSession, parentParts, assessmentItemIdentifier);
    TestPlanNode currentItemRefNode = testSessionState.getTestPlan().getNode(currentItemKey);
    ItemSessionController itemSessionController = (ItemSessionController) testSessionController.getItemProcessingContext(currentItemRefNode);
    ItemSessionState itemSessionState = itemSessionController.getItemSessionState();
    List<Interaction> interactions = itemSessionController.getInteractions();
    Map<Identifier, Interaction> interactionMap = new HashMap<>();
    for (Interaction interaction : interactions) {
        interactionMap.put(interaction.getResponseIdentifier(), interaction);
    }
    Map<Identifier, AssessmentResponse> candidateResponseMap = qtiService.getAssessmentResponses(itemSession);
    for (Entry<Identifier, ResponseData> responseEntry : responseDataMap.entrySet()) {
        Identifier responseIdentifier = responseEntry.getKey();
        ResponseData responseData = responseEntry.getValue();
        AssessmentResponse candidateItemResponse;
        if (candidateResponseMap.containsKey(responseIdentifier)) {
            candidateItemResponse = candidateResponseMap.get(responseIdentifier);
        } else {
            candidateItemResponse = qtiService.createAssessmentResponse(candidateSession, itemSession, responseIdentifier.toString(), ResponseLegality.VALID, responseData.getType());
        }
        switch(responseData.getType()) {
            case STRING:
                {
                    List<String> data = ((StringResponseData) responseData).getResponseData();
                    String stringuifiedResponse = ResponseFormater.format(data);
                    candidateItemResponse.setStringuifiedResponse(stringuifiedResponse);
                    break;
                }
            default:
                throw new OLATRuntimeException("Unexpected switch case: " + responseData.getType());
        }
        candidateResponseMap.put(responseIdentifier, candidateItemResponse);
        itemSessionState.setRawResponseData(responseIdentifier, responseData);
        try {
            Interaction interaction = interactionMap.get(responseIdentifier);
            interaction.bindResponse(itemSessionController, responseData);
        } catch (final ResponseBindingException e) {
        // 
        }
    }
    /* Copy uncommitted responses over */
    for (final Entry<Identifier, Value> uncommittedResponseEntry : itemSessionState.getUncommittedResponseValues().entrySet()) {
        final Identifier identifier = uncommittedResponseEntry.getKey();
        final Value value = uncommittedResponseEntry.getValue();
        itemSessionState.setResponseValue(identifier, value);
    }
    /* Persist CandidateResponse entities */
    qtiService.recordTestAssessmentResponses(itemSession, candidateResponseMap.values());
    /* Record resulting event */
    final CandidateEvent candidateEvent = qtiService.recordCandidateTestEvent(candidateSession, testEntry, entry, CandidateTestEventType.ITEM_EVENT, null, currentItemKey, testSessionState, notificationRecorder);
    candidateAuditLogger.logCandidateEvent(candidateEvent, candidateResponseMap);
    /* Record current result state */
    AssessmentResult assessmentResult = computeTestAssessmentResult(timestamp, candidateSession);
    synchronized (this) {
        qtiService.recordTestAssessmentResult(candidateSession, testSessionState, assessmentResult, candidateAuditLogger);
    }
}
Also used : TestSessionState(uk.ac.ed.ph.jqtiplus.state.TestSessionState) HashMap(java.util.HashMap) ResponseBindingException(uk.ac.ed.ph.jqtiplus.exception.ResponseBindingException) CandidateEvent(org.olat.ims.qti21.model.audit.CandidateEvent) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) StringResponseData(uk.ac.ed.ph.jqtiplus.types.StringResponseData) AssessmentItemSession(org.olat.ims.qti21.AssessmentItemSession) List(java.util.List) AssessmentResult(uk.ac.ed.ph.jqtiplus.node.result.AssessmentResult) ParentPartItemRefs(org.olat.ims.qti21.model.ParentPartItemRefs) TestPlanNode(uk.ac.ed.ph.jqtiplus.state.TestPlanNode) Interaction(uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction) FileResponseData(uk.ac.ed.ph.jqtiplus.types.FileResponseData) StringResponseData(uk.ac.ed.ph.jqtiplus.types.StringResponseData) ResponseData(uk.ac.ed.ph.jqtiplus.types.ResponseData) ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) NotificationRecorder(uk.ac.ed.ph.jqtiplus.notification.NotificationRecorder) ItemSessionController(uk.ac.ed.ph.jqtiplus.running.ItemSessionController) AssessmentResponse(org.olat.ims.qti21.AssessmentResponse) Date(java.util.Date) StringInput(org.olat.ims.qti21.ui.ResponseInput.StringInput) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) Value(uk.ac.ed.ph.jqtiplus.value.Value) NumberValue(uk.ac.ed.ph.jqtiplus.value.NumberValue) FloatValue(uk.ac.ed.ph.jqtiplus.value.FloatValue) IntegerValue(uk.ac.ed.ph.jqtiplus.value.IntegerValue) BooleanValue(uk.ac.ed.ph.jqtiplus.value.BooleanValue) TestPlanNodeKey(uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey)

Example 8 with TestPlanNode

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

the class AssessmentResultController method initFormSections.

private void initFormSections(FormLayoutContainer layoutCont, Results testResults) {
    List<Results> itemResults = new ArrayList<>();
    layoutCont.contextPut("itemResults", itemResults);
    Map<Identifier, AssessmentItemRef> identifierToRefs = new HashMap<>();
    for (AssessmentItemRef itemRef : resolvedAssessmentTest.getAssessmentItemRefs()) {
        identifierToRefs.put(itemRef.getIdentifier(), itemRef);
    }
    Map<TestPlanNode, Results> resultsMap = new HashMap<>();
    TestPlan testPlan = testSessionState.getTestPlan();
    List<TestPlanNode> nodes = testPlan.getTestPlanNodeList();
    for (TestPlanNode node : nodes) {
        TestPlanNodeKey testPlanNodeKey = node.getKey();
        TestNodeType testNodeType = node.getTestNodeType();
        if (testNodeType == TestNodeType.ASSESSMENT_SECTION) {
            Results r = new Results(true, node.getSectionPartTitle(), "o_mi_qtisection", options.isSectionSummary());
            AssessmentSectionSessionState sectionState = testSessionState.getAssessmentSectionSessionStates().get(testPlanNodeKey);
            if (sectionState != null) {
                r.setSessionState(sectionState);
            }
            resultsMap.put(node, r);
            itemResults.add(r);
            testResults.setNumberOfSections(testResults.getNumberOfSections() + 1);
        } else if (testNodeType == TestNodeType.ASSESSMENT_ITEM_REF) {
            Results results = initFormItemResult(layoutCont, node, identifierToRefs, resultsMap);
            if (results != null) {
                itemResults.add(results);
            }
            testResults.setNumberOfQuestions(testResults.getNumberOfQuestions() + 1);
            if (results.sessionStatus == SessionStatus.FINAL) {
                testResults.setNumberOfAnsweredQuestions(testResults.getNumberOfAnsweredQuestions() + 1);
            }
            if (results.hasMaxScore()) {
                testResults.addMaxScore(results);
            }
        }
    }
}
Also used : TestPlanNode(uk.ac.ed.ph.jqtiplus.state.TestPlanNode) HashMap(java.util.HashMap) TestPlan(uk.ac.ed.ph.jqtiplus.state.TestPlan) ArrayList(java.util.ArrayList) AssessmentSectionSessionState(uk.ac.ed.ph.jqtiplus.state.AssessmentSectionSessionState) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef) TestNodeType(uk.ac.ed.ph.jqtiplus.state.TestPlanNode.TestNodeType) TestPlanNodeKey(uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey)

Example 9 with TestPlanNode

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

the class AssessmentResultController method updateSectionScoreInformations.

private void updateSectionScoreInformations(TestPlanNode node, Results assessmentItemResults, Map<TestPlanNode, Results> resultsMap) {
    if (node.getParent() == null && resultsMap.get(node.getParent()) == null)
        return;
    TestPlanNode section = node.getParent();
    Results sectionResults = resultsMap.get(section);
    if (sectionResults != null) {
        sectionResults.addSubResults(assessmentItemResults);
        if (assessmentItemResults.hasMaxScore()) {
            sectionResults.addMaxScore(assessmentItemResults);
            if (assessmentItemResults.hasScore()) {
                sectionResults.addScore(assessmentItemResults);
            }
        }
    }
}
Also used : TestPlanNode(uk.ac.ed.ph.jqtiplus.state.TestPlanNode)

Example 10 with TestPlanNode

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

the class AssessmentTestComponentRenderer method renderTestItem.

private void renderTestItem(AssessmentRenderer renderer, StringOutput sb, AssessmentTestComponent component, TestPlanNodeKey itemRefKey, URLBuilder ubu, Translator translator, RenderingRequest options) {
    final TestSessionController testSessionController = component.getTestSessionController();
    final TestSessionState testSessionState = testSessionController.getTestSessionState();
    String key = itemRefKey.toString();
    /* We finally do the transform on the _item_ (NB!) */
    sb.append("<div class='qtiworks o_assessmentitem o_assessmenttest'>");
    // test part feedback 'during'
    // test feedback 'during'
    TestPlanNode itemRefNode = testSessionState.getTestPlan().getNode(itemRefKey);
    final EffectiveItemSessionControl effectiveItemSessionControl = itemRefNode.getEffectiveItemSessionControl();
    final boolean allowComments = effectiveItemSessionControl.isAllowComment() && component.isPersonalNotes();
    renderer.setCandidateCommentAllowed(allowComments);
    // write section rubric
    renderSectionRubrics(renderer, sb, component, itemRefNode, ubu, translator);
    // test part -> section -> item
    renderTestItemBody(renderer, sb, component, itemRefNode, ubu, translator, options);
    // controls
    sb.append("<div class='o_button_group o_assessmentitem_controls'>");
    // submit button
    final ItemSessionState itemSessionState = component.getItemSessionState(itemRefNode.getKey());
    if (component.isItemSessionOpen(itemSessionState, options.isSolutionMode())) {
        Component submit = component.getQtiItem().getSubmitButton().getComponent();
        submit.getHTMLRendererSingleton().render(renderer.getRenderer(), sb, submit, ubu, translator, new RenderResult(), null);
    }
    // advanceTestItemAllowed /* && testSessionState.getCurrentItemKey() != null && testSessionController.mayAdvanceItemLinear() */
    if (options.isAdvanceTestItemAllowed()) {
        // TODO need to find if there is a next question
        String title = translator.translate("assessment.test.nextQuestion");
        renderControl(sb, component, title, false, "o_sel_next_question", new NameValuePair("cid", Event.finishItem.name()));
    }
    // nextItem
    if (options.isNextItemAllowed() && testSessionController.hasFollowingNonLinearItem()) {
        String title = translator.translate("assessment.test.nextQuestion");
        renderControl(sb, component, title, false, "o_sel_next_question", new NameValuePair("cid", Event.nextItem.name()));
    }
    // testPartNavigationAllowed"
    if (options.isTestPartNavigationAllowed() && component.isRenderNavigation()) {
        String title = translator.translate("assessment.test.questionMenu");
        renderControl(sb, component, title, false, "o_sel_question_menu", new NameValuePair("cid", Event.testPartNavigation.name()));
    }
    // endTestPartAllowed
    if (options.isEndTestPartAllowed()) {
        String title = component.hasMultipleTestParts() ? translator.translate("assessment.test.end.testPart") : translator.translate("assessment.test.end.test");
        renderControl(sb, component, title, false, "o_sel_end_testpart", new NameValuePair("cid", Event.endTestPart.name()));
    }
    // reviewMode
    if (options.isReviewMode()) {
        String title = translator.translate("assessment.test.backToTestFeedback");
        renderControl(sb, component, title, false, "o_sel_back_test_feedback", new NameValuePair("cid", Event.reviewTestPart.name()));
    }
    // <xsl:variable name="provideItemSolutionButton" as="xs:boolean" select="$reviewMode and $showSolution and not($solutionMode)"/>
    if (options.isReviewMode() && effectiveItemSessionControl.isShowSolution() && !options.isSolutionMode()) {
        String title = translator.translate("assessment.solution.show");
        renderControl(sb, component, title, false, "o_sel_show_solution", new NameValuePair("cid", Event.itemSolution.name()), new NameValuePair("item", key));
    }
    if (options.isReviewMode() && options.isSolutionMode()) {
        String title = translator.translate("assessment.solution.hide");
        renderControl(sb, component, title, false, "o_sel_solution_hide", new NameValuePair("cid", Event.reviewItem.name()), new NameValuePair("item", key));
    }
    // end controls
    sb.append("</div>");
    // end assessmentItem
    sb.append("</div>");
}
Also used : TestPlanNode(uk.ac.ed.ph.jqtiplus.state.TestPlanNode) NameValuePair(org.olat.core.gui.components.form.flexible.impl.NameValuePair) TestSessionState(uk.ac.ed.ph.jqtiplus.state.TestSessionState) ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) RenderResult(org.olat.core.gui.render.RenderResult) TestSessionController(uk.ac.ed.ph.jqtiplus.running.TestSessionController) AssessmentRenderFunctions.contentAsString(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.contentAsString) Component(org.olat.core.gui.components.Component) EffectiveItemSessionControl(uk.ac.ed.ph.jqtiplus.state.EffectiveItemSessionControl)

Aggregations

TestPlanNode (uk.ac.ed.ph.jqtiplus.state.TestPlanNode)54 TestSessionState (uk.ac.ed.ph.jqtiplus.state.TestSessionState)32 TestPlanNodeKey (uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey)26 ItemSessionState (uk.ac.ed.ph.jqtiplus.state.ItemSessionState)22 Date (java.util.Date)16 NotificationRecorder (uk.ac.ed.ph.jqtiplus.notification.NotificationRecorder)16 CandidateEvent (org.olat.ims.qti21.model.audit.CandidateEvent)14 ArrayList (java.util.ArrayList)10 HashMap (java.util.HashMap)10 AssessmentItemSession (org.olat.ims.qti21.AssessmentItemSession)10 AssessmentItemRef (uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef)10 TestPlan (uk.ac.ed.ph.jqtiplus.state.TestPlan)10 OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)8 AssessmentTestSession (org.olat.ims.qti21.AssessmentTestSession)8 TestPart (uk.ac.ed.ph.jqtiplus.node.test.TestPart)8 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)8 QtiCandidateStateException (uk.ac.ed.ph.jqtiplus.exception.QtiCandidateStateException)7 OLATResourceable (org.olat.core.id.OLATResourceable)6 ParentPartItemRefs (org.olat.ims.qti21.model.ParentPartItemRefs)6 CandidateTestEventType (org.olat.ims.qti21.model.audit.CandidateTestEventType)6