Search in sources :

Example 56 with NameValuePair

use of org.olat.core.gui.components.form.flexible.impl.NameValuePair in project OpenOLAT by OpenOLAT.

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 57 with NameValuePair

use of org.olat.core.gui.components.form.flexible.impl.NameValuePair in project OpenOLAT by OpenOLAT.

the class AssessmentTestComponentRenderer method renderTestEntry.

private void renderTestEntry(StringOutput sb, AssessmentTestComponent component, Translator translator) {
    int numOfParts = component.getAssessmentTest().getTestParts().size();
    sb.append("<h4>").append(translator.translate("test.entry.page.title")).append("</h4>").append("<div class='o_info'>").append(translator.translate("test.entry.page.text", new String[] { Integer.toString(numOfParts) })).append("</div><div class='o_button_group'>");
    // precondition -> up to
    String title = translator.translate("assessment.test.enter.test");
    renderControl(sb, component, title, true, "o_sel_enter_test", new NameValuePair("cid", Event.advanceTestPart.name()));
    sb.append("</div>");
}
Also used : NameValuePair(org.olat.core.gui.components.form.flexible.impl.NameValuePair) AssessmentRenderFunctions.contentAsString(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.contentAsString)

Example 58 with NameValuePair

use of org.olat.core.gui.components.form.flexible.impl.NameValuePair in project OpenOLAT by OpenOLAT.

the class AssessmentTestComponentRenderer method renderReviewAssessmentItem.

private void renderReviewAssessmentItem(StringOutput sb, AssessmentTestComponent component, TestPlanNode itemNode, Translator translator) {
    EffectiveItemSessionControl itemSessionControl = itemNode.getEffectiveItemSessionControl();
    // <xsl:variable name="reviewable" select="@allowReview='true' or @showFeedback='true'" as="xs:boolean"/>
    boolean reviewable = itemSessionControl.isAllowReview() || itemSessionControl.isShowFeedback();
    // <xsl:variable name="itemSessionState" select="$testSessionState/qw:item[@key=current()/@key]/qw:itemSessionState" as="element(qw:itemSessionState)"/>
    ItemSessionState itemSessionState = component.getTestSessionController().getTestSessionState().getItemSessionStates().get(itemNode.getKey());
    // <xsl:if test="$currentTestPart/@navigationMode='nonlinear' or exists($itemSessionState/@entryTime)">
    TestPart currentTestPart = component.getTestPart(component.getCurrentTestPartNode().getIdentifier());
    if (currentTestPart.getNavigationMode() == NavigationMode.NONLINEAR || itemSessionState.getEntryTime() != null) {
        sb.append("<li class='o_assessmentitem'>");
        sb.append("<button type='button' onclick=\"");
        String key = itemNode.getKey().toString();
        sb.append(FormJSHelper.getXHRFnCallFor(component.getQtiItem(), true, true, new NameValuePair("cid", Event.reviewItem.name()), new NameValuePair("item", key)));
        sb.append(";\" class='btn btn-default' ").append(" disabled", !reviewable).append("><span class='questionTitle'>").append(StringHelper.escapeHtml(itemNode.getSectionPartTitle())).append("</span>");
        if (!reviewable) {
            renderItemStatusMessage("reviewNotAllowed", "assessment.item.status.reviewNot", sb, translator);
        } else if (itemSessionState.getUnboundResponseIdentifiers().size() > 0 || itemSessionState.getInvalidResponseIdentifiers().size() > 0) {
            renderItemStatusMessage("reviewInvalid", "assessment.item.status.reviewInvalidAnswer", sb, translator);
        } else if (itemSessionState.isResponded()) {
            renderItemStatusMessage("review", "assessment.item.status.review", sb, translator);
        } else if (itemSessionState.getEntryTime() != null) {
            renderItemStatusMessage("reviewNotAnswered", "assessment.item.status.reviewNotAnswered", sb, translator);
        } else {
            renderItemStatusMessage("reviewNotSeen", "assessment.item.status.reviewNotSeen", sb, translator);
        }
        sb.append("</button></li>");
    }
}
Also used : NameValuePair(org.olat.core.gui.components.form.flexible.impl.NameValuePair) ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) TestPart(uk.ac.ed.ph.jqtiplus.node.test.TestPart) AssessmentRenderFunctions.contentAsString(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.contentAsString) EffectiveItemSessionControl(uk.ac.ed.ph.jqtiplus.state.EffectiveItemSessionControl)

Example 59 with NameValuePair

use of org.olat.core.gui.components.form.flexible.impl.NameValuePair in project OpenOLAT by OpenOLAT.

the class AssessmentTestComponentRenderer method renderNavigation.

private void renderNavigation(AssessmentRenderer renderer, StringOutput sb, AssessmentTestComponent component, URLBuilder ubu, Translator translator) {
    if (component.isRenderNavigation()) {
        sb.append("<div id='o_qti_menu' class='qtiworks o_assessmenttest o_testpartnavigation o_qti_menu_buttonstyle'>");
        // title
        boolean multiPartTest = component.hasMultipleTestParts();
        String title = multiPartTest ? translator.translate("assessment.test.nav.title.multiPartTestMenu") : translator.translate("assessment.test.nav.title.questionMenu");
        sb.append("<h3>").append(title).append("</h3>");
        // part, sections and item refs
        sb.append("<ul class='o_testpartnavigation list-unstyled'>");
        component.getCurrentTestPartNode().getChildren().forEach((node) -> renderNavigation(renderer, sb, component, node, ubu, translator));
        sb.append("</ul>");
        // test controls
        TestSessionController testSessionController = component.getTestSessionController();
        boolean allowedToEndTestPart = testSessionController.getTestSessionState().getCurrentTestPartKey() != null && testSessionController.mayEndCurrentTestPart();
        sb.append("<div class='o_button_group'>");
        sb.append("<button type='button' onclick=\"");
        if (allowedToEndTestPart) {
            Form form = component.getQtiItem().getRootForm();
            String dispatchId = component.getQtiItem().getFormDispatchId();
            sb.append(FormJSHelper.getXHRFnCallFor(form, dispatchId, 1, true, true, new NameValuePair("cid", Event.endTestPart.name())));
        } else {
            sb.append("javascript:");
        }
        String endTestTitle = multiPartTest ? translator.translate("assessment.test.end.testPart") : translator.translate("assessment.test.end.test");
        sb.append(";\" class='btn btn-default o_sel_end_testpart'").append(" disabled", !allowedToEndTestPart).append("><span>").append(endTestTitle).append("</span>");
        sb.append("</button>");
        sb.append("</div></div>");
    }
}
Also used : NameValuePair(org.olat.core.gui.components.form.flexible.impl.NameValuePair) Form(org.olat.core.gui.components.form.flexible.impl.Form) TestSessionController(uk.ac.ed.ph.jqtiplus.running.TestSessionController) AssessmentRenderFunctions.contentAsString(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.contentAsString)

Example 60 with NameValuePair

use of org.olat.core.gui.components.form.flexible.impl.NameValuePair in project OpenOLAT by OpenOLAT.

the class AssessmentTreeComponentRenderer method renderAssessmentItemLink.

/**
 * @param sb
 * @param component
 * @param itemNode
 * @return The event used or null
 */
private Event renderAssessmentItemLink(StringOutput sb, AssessmentTreeComponent component, TestPlanNode itemNode, Translator translator) {
    String key = itemNode.getKey().toString();
    Form form = component.getQtiItem().getRootForm();
    String dispatchId = component.getQtiItem().getFormDispatchId();
    TestSessionController testSessionController = component.getTestSessionController();
    TestSessionState testSessionState = testSessionController.getTestSessionState();
    TestPart testPart = testSessionController.getCurrentTestPart();
    TestPlanNodeKey currentTestPartKey = testSessionState.getCurrentTestPartKey();
    TestPartSessionState currentTestPartSessionState = testSessionState.getTestPartSessionStates().get(currentTestPartKey);
    Event event;
    if (testPart == null || testPart.getNavigationMode() == NavigationMode.NONLINEAR) {
        if (testSessionState.isEnded() || currentTestPartSessionState.isEnded()) {
            if (itemNode.getEffectiveItemSessionControl().isAllowReview() || itemNode.getEffectiveItemSessionControl().isShowFeedback()) {
                event = Event.reviewItem;
            } else {
                event = null;
            }
        } else {
            event = Event.selectItem;
        }
    } else {
        event = null;
    }
    if (event == null) {
        sb.append("<span class='o_assessmentitem_nav_disabled'>");
    } else {
        sb.append("<a href='javascript:;' onclick=\"").append(FormJSHelper.getXHRFnCallFor(form, dispatchId, 1, true, true, new NameValuePair("cid", event.name()), new NameValuePair("item", key))).append(";\" class='o_sel_assessmentitem'>");
    }
    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("<span class='questionTitle'>").append(title).append("</span>");
    if (event == null) {
        sb.append("</span>");
    } else {
        sb.append("</a>");
    }
    return event;
}
Also used : NameValuePair(org.olat.core.gui.components.form.flexible.impl.NameValuePair) TestSessionState(uk.ac.ed.ph.jqtiplus.state.TestSessionState) Form(org.olat.core.gui.components.form.flexible.impl.Form) TestPart(uk.ac.ed.ph.jqtiplus.node.test.TestPart) TestSessionController(uk.ac.ed.ph.jqtiplus.running.TestSessionController) Event(org.olat.ims.qti21.ui.QTIWorksAssessmentTestEvent.Event) CandidateEvent(org.olat.ims.qti21.model.audit.CandidateEvent) TestPartSessionState(uk.ac.ed.ph.jqtiplus.state.TestPartSessionState) TestPlanNodeKey(uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey)

Aggregations

NameValuePair (org.olat.core.gui.components.form.flexible.impl.NameValuePair)80 Form (org.olat.core.gui.components.form.flexible.impl.Form)42 AssessmentRenderFunctions.contentAsString (org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.contentAsString)12 Component (org.olat.core.gui.components.Component)8 TestSessionController (uk.ac.ed.ph.jqtiplus.running.TestSessionController)6 ItemSessionState (uk.ac.ed.ph.jqtiplus.state.ItemSessionState)6 FlexiTableFilter (org.olat.core.gui.components.form.flexible.elements.FlexiTableFilter)4 FlexiTableSort (org.olat.core.gui.components.form.flexible.elements.FlexiTableSort)4 StringOutput (org.olat.core.gui.render.StringOutput)4 Translator (org.olat.core.gui.translator.Translator)4 VFSItem (org.olat.core.util.vfs.VFSItem)4 TestPart (uk.ac.ed.ph.jqtiplus.node.test.TestPart)4 EffectiveItemSessionControl (uk.ac.ed.ph.jqtiplus.state.EffectiveItemSessionControl)3 TestPlanNode (uk.ac.ed.ph.jqtiplus.state.TestPlanNode)3 TestSessionState (uk.ac.ed.ph.jqtiplus.state.TestSessionState)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 Matcher (java.util.regex.Matcher)2 FolderLicenseHandler (org.olat.core.commons.modules.bc.FolderLicenseHandler)2