Search in sources :

Example 46 with TestPlanNode

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

the class AssessmentTestHelper method getParentSection.

public static ParentPartItemRefs getParentSection(TestPlanNodeKey itemKey, TestSessionState testSessionState, ResolvedAssessmentTest resolvedAssessmentTest) {
    ParentPartItemRefs parentParts = new ParentPartItemRefs();
    try {
        TestPlanNode currentItem = testSessionState.getTestPlan().getNode(itemKey);
        List<AssessmentItemRef> itemRefs = resolvedAssessmentTest.getItemRefsBySystemIdMap().get(currentItem.getItemSystemId());
        AssessmentItemRef itemRef = null;
        if (itemRefs.size() == 1) {
            itemRef = itemRefs.get(0);
        } else {
            Identifier itemId = itemKey.getIdentifier();
            for (AssessmentItemRef ref : itemRefs) {
                if (ref.getIdentifier().equals(itemId)) {
                    itemRef = ref;
                    break;
                }
            }
        }
        if (itemRef != null) {
            for (QtiNode parentPart = itemRef.getParent(); parentPart != null; parentPart = parentPart.getParent()) {
                if (parentParts.getSectionIdentifier() == null && parentPart instanceof AssessmentSection) {
                    AssessmentSection section = (AssessmentSection) parentPart;
                    parentParts.setSectionIdentifier(section.getIdentifier().toString());
                } else if (parentParts.getTestPartIdentifier() == null && parentPart instanceof TestPart) {
                    TestPart testPart = (TestPart) parentPart;
                    parentParts.setTestPartIdentifier(testPart.getIdentifier().toString());
                }
            }
        }
    } catch (Exception e) {
        log.error("", e);
    }
    return parentParts;
}
Also used : ParentPartItemRefs(org.olat.ims.qti21.model.ParentPartItemRefs) TestPlanNode(uk.ac.ed.ph.jqtiplus.state.TestPlanNode) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) AssessmentSection(uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection) TestPart(uk.ac.ed.ph.jqtiplus.node.test.TestPart) AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef) QtiNode(uk.ac.ed.ph.jqtiplus.node.QtiNode)

Example 47 with TestPlanNode

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

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 48 with TestPlanNode

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

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 49 with TestPlanNode

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

the class AssessmentTestDisplayController method processSelectItem.

private void processSelectItem(UserRequest ureq, String key) {
    if (checkConcurrentExit(ureq)) {
        return;
    }
    TestPlanNodeKey nodeKey = TestPlanNodeKey.fromString(key);
    Date requestTimestamp = ureq.getRequestTimestamp();
    TestPlanNode selectedNode = testSessionController.selectItemNonlinear(requestTimestamp, nodeKey);
    /* Record and log event */
    TestPlanNodeKey selectedNodeKey = (selectedNode == null ? null : selectedNode.getKey());
    NotificationRecorder notificationRecorder = new NotificationRecorder(NotificationLevel.INFO);
    TestSessionState testSessionState = testSessionController.getTestSessionState();
    CandidateEvent candidateEvent = qtiService.recordCandidateTestEvent(candidateSession, testEntry, entry, CandidateTestEventType.SELECT_MENU, null, selectedNodeKey, testSessionState, notificationRecorder);
    candidateAuditLogger.logCandidateEvent(candidateEvent);
}
Also used : TestPlanNode(uk.ac.ed.ph.jqtiplus.state.TestPlanNode) TestSessionState(uk.ac.ed.ph.jqtiplus.state.TestSessionState) NotificationRecorder(uk.ac.ed.ph.jqtiplus.notification.NotificationRecorder) Date(java.util.Date) TestPlanNodeKey(uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey) CandidateEvent(org.olat.ims.qti21.model.audit.CandidateEvent)

Example 50 with TestPlanNode

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

the class AssessmentTestComponentRenderer method renderSectionRubrics.

private void renderSectionRubrics(AssessmentRenderer renderer, StringOutput sb, AssessmentTestComponent component, TestPlanNode itemRefNode, URLBuilder ubu, Translator translator) {
    boolean writeRubrics = false;
    boolean writeTitles = false;
    List<AssessmentSection> sectionParentLine = new ArrayList<>();
    for (TestPlanNode parentNode = itemRefNode.getParent(); parentNode.getParent() != null; parentNode = parentNode.getParent()) {
        AssessmentSection selectedSection = component.getAssessmentSection(parentNode.getIdentifier());
        if (selectedSection != null && selectedSection.getVisible()) {
            sectionParentLine.add(selectedSection);
            if (selectedSection.getRubricBlocks().size() > 0) {
                for (RubricBlock rubric : selectedSection.getRubricBlocks()) {
                    if (rubric.getBlocks().size() > 0) {
                        writeRubrics = true;
                    }
                }
            }
            if (StringHelper.containsNonWhitespace(selectedSection.getTitle())) {
                writeTitles = true;
            }
        }
    }
    if (writeRubrics) {
        boolean show = true;
        for (int i = sectionParentLine.size(); i-- > 0; ) {
            AssessmentSection selectedSection = sectionParentLine.get(i);
            if (component.getCandidateSessionContext().isRubricHidden(selectedSection.getIdentifier())) {
                show = false;
            }
        }
        String key = sectionParentLine.get(0).getIdentifier().toString();
        Form form = component.getQtiItem().getRootForm();
        String dispatchId = component.getQtiItem().getFormDispatchId();
        sb.append("<a href='javascript:;' onclick=\"").append(FormJSHelper.getXHRNFFnCallFor(form, dispatchId, 1, new NameValuePair("cid", Event.rubric.name()), new NameValuePair("section", key))).append("; return false;\" class='o_toogle_rubrics translated'><i class='o_icon o_icon-fw ");
        if (show) {
            sb.append("o_icon_close_togglebox'> </i> <span>").append(translator.translate("hide.rubric"));
        } else {
            sb.append("o_icon_open_togglebox'> </i> <span>").append(translator.translate("show.rubric"));
        }
        sb.append("</span></a>");
        sb.append("<div class='o_info o_assessmentsection_rubrics clearfix");
        if (show) {
            sb.append(" o_show");
        } else {
            sb.append(" o_hide");
        }
        sb.append("'>");
        // write the titles first
        if (writeTitles) {
            sb.append("<h4>");
            for (int i = 0; i < sectionParentLine.size(); i++) {
                if (i == 1) {
                    sb.append("<small>");
                } else if (i > 1) {
                    sb.append(" / ");
                }
                sb.append(sectionParentLine.get(i).getTitle());
            }
            if (sectionParentLine.size() > 1) {
                sb.append("</small>");
            }
            sb.append("</h4>");
        }
        for (int i = sectionParentLine.size(); i-- > 0; ) {
            AssessmentSection selectedSection = sectionParentLine.get(i);
            for (RubricBlock rubricBlock : selectedSection.getRubricBlocks()) {
                // @view (candidate)
                sb.append("<div class='rubric'>");
                rubricBlock.getBlocks().forEach(block -> renderBlock(renderer, sb, component, null, null, block, ubu, translator));
                sb.append("</div>");
            }
        }
        sb.append("<a href='javascript:;' onclick=\"").append(FormJSHelper.getXHRNFFnCallFor(form, dispatchId, 1, new NameValuePair("cid", Event.rubric.name()), new NameValuePair("section", key))).append("; return false;\" class='o_toogle_rubrics o_hide'><span>").append(translator.translate("hide.rubric.short")).append("</span></a>");
        // script to show/hide the rubrics with the translated linked
        sb.append("<script type=\"text/javascript\">\n").append("/* <![CDATA[ */ \n").append("jQuery(function() {\n").append(" jQuery('.o_toogle_rubrics').on('click', function() {\n").append("   jQuery('.o_assessmentsection_rubrics').each(function(index, el) {\n").append("     var current = jQuery(el).attr('class');\n").append("     if(current.indexOf('o_hide') >= 0) {\n").append("       jQuery(el).removeClass('o_hide').addClass('o_show');\n").append("       jQuery('a.o_toogle_rubrics.translated i').removeClass('o_icon_open_togglebox').addClass('o_icon_close_togglebox');\n").append("       jQuery('a.o_toogle_rubrics.translated span').html('").append(translator.translate("hide.rubric")).append("');").append("     } else {\n").append("   	  jQuery(el).removeClass('o_show').addClass('o_hide');\n").append("       jQuery('a.o_toogle_rubrics.translated i').removeClass('o_icon_close_togglebox').addClass('o_icon_open_togglebox');\n").append("       jQuery('a.o_toogle_rubrics.translated span').html('").append(translator.translate("show.rubric")).append("');").append("     }\n").append("   });").append(" });").append("});\n /* ]]> */").append("</script>").append("</div>");
    }
}
Also used : TestPlanNode(uk.ac.ed.ph.jqtiplus.state.TestPlanNode) NameValuePair(org.olat.core.gui.components.form.flexible.impl.NameValuePair) Form(org.olat.core.gui.components.form.flexible.impl.Form) AssessmentSection(uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection) ArrayList(java.util.ArrayList) AssessmentRenderFunctions.contentAsString(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.contentAsString) RubricBlock(uk.ac.ed.ph.jqtiplus.node.content.variable.RubricBlock)

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