Search in sources :

Example 11 with TestSessionController

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

use of uk.ac.ed.ph.jqtiplus.running.TestSessionController 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)

Example 13 with TestSessionController

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

the class AssessmentTreeComponentRenderer method render.

@Override
public void render(Renderer renderer, StringOutput sb, Component source, URLBuilder ubu, Translator translator, RenderResult renderResult, String[] args) {
    AssessmentTreeComponent component = (AssessmentTreeComponent) source;
    TestSessionController testSessionController = component.getTestSessionController();
    if (!testSessionController.getTestSessionState().isEnded()) {
        CandidateSessionContext candidateSessionContext = component.getCandidateSessionContext();
        final AssessmentTestSession candidateSession = candidateSessionContext.getCandidateSession();
        if (!candidateSession.isExploded() && !candidateSessionContext.isTerminated()) {
            CandidateEvent candidateEvent = candidateSessionContext.getLastEvent();
            CandidateTestEventType testEventType = candidateEvent.getTestEventType();
            RenderingRequest options;
            if (testEventType == CandidateTestEventType.REVIEW_ITEM) {
                options = RenderingRequest.getItemReview();
            } else if (testEventType == CandidateTestEventType.SOLUTION_ITEM) {
                options = RenderingRequest.getItemSolution();
            } else {
                options = RenderingRequest.getItem(testSessionController);
            }
            AssessmentRenderer renderHints = new AssessmentRenderer(renderer);
            renderTestEvent(testSessionController, renderHints, sb, component, ubu, translator, options);
        }
    }
}
Also used : CandidateSessionContext(org.olat.ims.qti21.ui.CandidateSessionContext) AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) CandidateTestEventType(org.olat.ims.qti21.model.audit.CandidateTestEventType) TestSessionController(uk.ac.ed.ph.jqtiplus.running.TestSessionController) CandidateEvent(org.olat.ims.qti21.model.audit.CandidateEvent)

Example 14 with TestSessionController

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

the class AssessmentTreeComponentRenderer method renderNavigationAssessmentItem.

private void renderNavigationAssessmentItem(StringOutput sb, AssessmentTreeComponent component, TestPlanNode itemNode, Translator translator, RenderingRequest options) {
    // check if currently rendered item is the active item
    boolean active = false;
    TestSessionController sessionCtr = component.getTestSessionController();
    if (sessionCtr != null && itemNode != null) {
        TestSessionState sessionState = sessionCtr.getTestSessionState();
        if (sessionState != null && sessionState.getCurrentItemKey() != null) {
            TestPlanNodeKey testPlanNodeKey = sessionState.getCurrentItemKey();
            active = (testPlanNodeKey.getIdentifier().equals(itemNode.getIdentifier()));
        }
    }
    sb.append("<li class='o_assessmentitem").append(" active", active).append("'>");
    try {
        renderAssessmentItemMark(sb, component, itemNode, translator);
        renderAssessmentItemAttempts(sb, component, itemNode, translator);
        renderItemStatus(sb, component, itemNode, translator, options);
        renderAssessmentItemLink(sb, component, itemNode, translator);
    } catch (IllegalStateException ex) {
        log.error("", ex);
        sb.append("<span class='o_danger'>ERROR</span>");
    }
    sb.append("</li>");
}
Also used : TestSessionState(uk.ac.ed.ph.jqtiplus.state.TestSessionState) TestSessionController(uk.ac.ed.ph.jqtiplus.running.TestSessionController) TestPlanNodeKey(uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey)

Example 15 with TestSessionController

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

the class AssessmentTestDisplayController method createNewTestSessionStateAndController.

private TestSessionController createNewTestSessionStateAndController(NotificationRecorder notificationRecorder) {
    TestProcessingMap testProcessingMap = getTestProcessingMap();
    /* Generate a test plan for this session */
    final TestPlanner testPlanner = new TestPlanner(testProcessingMap);
    if (notificationRecorder != null) {
        testPlanner.addNotificationListener(notificationRecorder);
    }
    final TestPlan testPlan = testPlanner.generateTestPlan();
    final TestSessionState testSessionState = new TestSessionState(testPlan);
    final TestSessionControllerSettings testSessionControllerSettings = new TestSessionControllerSettings();
    testSessionControllerSettings.setTemplateProcessingLimit(computeTemplateProcessingLimit());
    testProcessingMap.reduceItemProcessingMapMap(testPlan.getTestPlanNodeList());
    /* Create controller and wire up notification recorder */
    final TestSessionController result = new TestSessionController(qtiService.jqtiExtensionManager(), testSessionControllerSettings, testProcessingMap, testSessionState);
    if (notificationRecorder != null) {
        result.addNotificationListener(notificationRecorder);
    }
    return result;
}
Also used : TestSessionControllerSettings(uk.ac.ed.ph.jqtiplus.running.TestSessionControllerSettings) TestProcessingMap(uk.ac.ed.ph.jqtiplus.state.TestProcessingMap) TestPlanner(uk.ac.ed.ph.jqtiplus.running.TestPlanner) TestSessionState(uk.ac.ed.ph.jqtiplus.state.TestSessionState) TestPlan(uk.ac.ed.ph.jqtiplus.state.TestPlan) TestSessionController(uk.ac.ed.ph.jqtiplus.running.TestSessionController)

Aggregations

TestSessionController (uk.ac.ed.ph.jqtiplus.running.TestSessionController)18 TestSessionState (uk.ac.ed.ph.jqtiplus.state.TestSessionState)12 NameValuePair (org.olat.core.gui.components.form.flexible.impl.NameValuePair)6 TestPlanNodeKey (uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey)6 Date (java.util.Date)4 Form (org.olat.core.gui.components.form.flexible.impl.Form)4 AssessmentTestSession (org.olat.ims.qti21.AssessmentTestSession)4 CandidateEvent (org.olat.ims.qti21.model.audit.CandidateEvent)4 CandidateSessionContext (org.olat.ims.qti21.ui.CandidateSessionContext)4 AssessmentRenderFunctions.contentAsString (org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.contentAsString)4 TestSessionControllerSettings (uk.ac.ed.ph.jqtiplus.running.TestSessionControllerSettings)4 ItemSessionState (uk.ac.ed.ph.jqtiplus.state.ItemSessionState)4 TestPlanNode (uk.ac.ed.ph.jqtiplus.state.TestPlanNode)4 TestProcessingMap (uk.ac.ed.ph.jqtiplus.state.TestProcessingMap)4 Component (org.olat.core.gui.components.Component)2 RenderResult (org.olat.core.gui.render.RenderResult)2 CandidateTestEventType (org.olat.ims.qti21.model.audit.CandidateTestEventType)2 Event (org.olat.ims.qti21.ui.QTIWorksAssessmentTestEvent.Event)2 TestPart (uk.ac.ed.ph.jqtiplus.node.test.TestPart)2 NotificationRecorder (uk.ac.ed.ph.jqtiplus.notification.NotificationRecorder)2