Search in sources :

Example 36 with ItemSessionState

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

the class AssessmentTestComponent method isItemFeedbackAllowed.

// <xsl:if test="$itemFeedbackAllowed and $sessionStatus='final'">
// <xsl:variable name="itemFeedbackAllowed" as="xs:boolean"
// select="if ($reviewMode)
// then (/qti:assessentItem/@adaptive='true' or $showFeedback)
// else (not($solutionMode))"/>
public boolean isItemFeedbackAllowed(TestPlanNode itemNode, AssessmentItem assessmentItem, RenderingRequest options) {
    ItemSessionState itemSessionState = getItemSessionState(itemNode.getKey());
    boolean itemFeedbackAllowed = false;
    if (itemSessionState.getSessionStatus() == SessionStatus.FINAL) {
        if (options.isReviewMode()) {
            if (assessmentItem.getAdaptive() || itemNode.getEffectiveItemSessionControl().isShowFeedback()) {
                itemFeedbackAllowed = true;
            }
        } else if (!options.isSolutionMode()) {
            itemFeedbackAllowed = true;
        }
    }
    return itemFeedbackAllowed;
}
Also used : ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState)

Example 37 with ItemSessionState

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

the class AssessmentTestComponent method getResponseUniqueIdentifier.

@Override
public String getResponseUniqueIdentifier(ItemSessionState itemSessionState, Interaction interaction) {
    TestPlanNodeKey tpnk = null;
    for (Map.Entry<TestPlanNodeKey, ItemSessionState> entry : testSessionController.getTestSessionState().getItemSessionStates().entrySet()) {
        if (entry.getValue() == itemSessionState) {
            tpnk = entry.getKey();
            break;
        }
    }
    String id = "oo" + (tpnk.toString().replace(":", "_")) + "_" + interaction.getResponseIdentifier().toString();
    responseIdentifiersMap.put(id, interaction);
    return id;
}
Also used : ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) HashMap(java.util.HashMap) Map(java.util.Map) TestPlanNodeKey(uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey)

Example 38 with ItemSessionState

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

the class AssessmentTestComponentRenderer method renderTestItemBody.

private void renderTestItemBody(AssessmentRenderer renderer, StringOutput sb, AssessmentTestComponent component, TestPlanNode itemNode, URLBuilder ubu, Translator translator, RenderingRequest options) {
    final ItemSessionState itemSessionState = component.getItemSessionState(itemNode.getKey());
    URI itemSystemId = itemNode.getItemSystemId();
    ResolvedAssessmentItem resolvedAssessmentItem = component.getResolvedAssessmentTest().getResolvedAssessmentItemBySystemIdMap().get(itemSystemId);
    if (resolvedAssessmentItem == null) {
        log.error("Missing assessment item: " + itemSystemId);
        renderMissingItem(sb, translator);
        return;
    }
    final AssessmentItem assessmentItem = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
    sb.append("<div class='o_assessmentitem_wrapper'>");
    // title + status
    sb.append("<h4 class='itemTitle'>");
    renderItemStatus(sb, itemSessionState, options, translator);
    renderMaxScoreItem(sb, component, itemSessionState, translator);
    String title;
    if (component.isShowTitles()) {
        title = StringHelper.escapeHtml(itemNode.getSectionPartTitle());
    } else {
        int num = component.getCandidateSessionContext().getNumber(itemNode);
        title = translator.translate("question.title", new String[] { Integer.toString(num) });
    }
    sb.append(title).append("</h4>").append("<div id='itemBody' class='o_qti_item_body clearfix'>");
    // render itemBody
    assessmentItem.getItemBody().getBlocks().forEach(block -> renderBlock(renderer, sb, component, resolvedAssessmentItem, itemSessionState, block, ubu, translator));
    // comment
    renderComment(renderer, sb, component, itemSessionState, translator);
    // end body
    sb.append("</div>");
    // Display active modal feedback (only after responseProcessing)
    if (component.isItemFeedbackAllowed(itemNode, assessmentItem, options)) {
        renderTestItemModalFeedback(renderer, sb, component, resolvedAssessmentItem, itemSessionState, ubu, translator);
    }
    // end wrapper
    sb.append("</div>");
}
Also used : ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) AssessmentRenderFunctions.contentAsString(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.contentAsString) URI(java.net.URI)

Example 39 with ItemSessionState

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

the class AssessmentTestComponentRenderer method renderNavigationAssessmentItem.

private void renderNavigationAssessmentItem(StringOutput sb, AssessmentTestComponent component, TestPlanNode itemNode, Translator translator) {
    String key = itemNode.getKey().toString();
    sb.append("<li class='o_assessmentitem'>");
    sb.append("<button type='button' onclick=\"");
    Form form = component.getQtiItem().getRootForm();
    String dispatchId = component.getQtiItem().getFormDispatchId();
    sb.append(FormJSHelper.getXHRFnCallFor(form, dispatchId, 1, true, true, new NameValuePair("cid", Event.selectItem.name()), new NameValuePair("item", key)));
    sb.append(";\" class='btn btn-default'><span class='questionTitle'>").append(StringHelper.escapeHtml(itemNode.getSectionPartTitle())).append("</span>");
    ItemSessionState itemSessionState = component.getItemSessionState(itemNode.getKey());
    if (itemSessionState.getEndTime() != null) {
        renderItemStatusMessage("ended", "assessment.item.status.finished", sb, translator);
    } else if (itemSessionState.getUnboundResponseIdentifiers().size() > 0 || itemSessionState.getInvalidResponseIdentifiers().size() > 0) {
        renderItemStatusMessage("invalid", "assessment.item.status.needsAttention", sb, translator);
    } else if (itemSessionState.isResponded() || itemSessionState.hasUncommittedResponseValues()) {
        renderItemStatusMessage("answered", "assessment.item.status.answered", sb, translator);
    } else if (itemSessionState.getEntryTime() != null) {
        renderItemStatusMessage("notAnswered", "assessment.item.status.notAnswered", sb, translator);
    } else {
        renderItemStatusMessage("notPresented", "assessment.item.status.notSeen", sb, translator);
    }
    sb.append("</button>");
    sb.append("</li>");
}
Also used : NameValuePair(org.olat.core.gui.components.form.flexible.impl.NameValuePair) Form(org.olat.core.gui.components.form.flexible.impl.Form) ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) AssessmentRenderFunctions.contentAsString(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.contentAsString)

Example 40 with ItemSessionState

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

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

ItemSessionState (uk.ac.ed.ph.jqtiplus.state.ItemSessionState)88 ResolvedAssessmentItem (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem)30 Date (java.util.Date)28 HashMap (java.util.HashMap)28 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)28 TestPlanNodeKey (uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey)26 TestSessionState (uk.ac.ed.ph.jqtiplus.state.TestSessionState)24 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)24 TestPlanNode (uk.ac.ed.ph.jqtiplus.state.TestPlanNode)22 AssessmentTestSession (org.olat.ims.qti21.AssessmentTestSession)20 CandidateEvent (org.olat.ims.qti21.model.audit.CandidateEvent)20 NotificationRecorder (uk.ac.ed.ph.jqtiplus.notification.NotificationRecorder)20 ItemSessionController (uk.ac.ed.ph.jqtiplus.running.ItemSessionController)20 ArrayList (java.util.ArrayList)18 Map (java.util.Map)18 ResponseData (uk.ac.ed.ph.jqtiplus.types.ResponseData)18 Interaction (uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction)16 List (java.util.List)14 Block (uk.ac.ed.ph.jqtiplus.node.content.basic.Block)12 Flow (uk.ac.ed.ph.jqtiplus.node.content.basic.Flow)12