Search in sources :

Example 21 with TestPart

use of uk.ac.ed.ph.jqtiplus.node.test.TestPart in project openolat by klemens.

the class AssessmentTestComponentRenderer method renderReviewAssessmentSection.

private void renderReviewAssessmentSection(AssessmentRenderer renderer, StringOutput sb, AssessmentTestComponent component, TestPlanNode sectionNode, URLBuilder ubu, Translator translator) {
    AssessmentSectionSessionState assessmentSessionSessionState = component.getTestSessionController().getTestSessionState().getAssessmentSectionSessionStates().get(sectionNode.getKey());
    TestPart currentTestPart = component.getTestPart(component.getCurrentTestPartNode().getIdentifier());
    // <xsl:if test="$currentTestPart/@navigationMode='nonlinear' or exists($assessmentSessionSessionState/@entryTime)">
    if (currentTestPart.getNavigationMode() == NavigationMode.NONLINEAR || assessmentSessionSessionState.getEntryTime() != null) {
        sb.append("<li class='o_assessmentsection'>").append("<header><h2>").append(StringHelper.escapeHtml(sectionNode.getSectionPartTitle())).append("</h2>");
        renderAssessmentSectionRubrickBlock(renderer, sb, component, sectionNode, ubu, translator);
        sb.append("</header>");
        sb.append("<ul class='o_testpartnavigation_inner list-unstyled'>");
        sectionNode.getChildren().forEach((childNode) -> renderReview(renderer, sb, component, childNode, ubu, translator));
        sb.append("</ul>");
    }
}
Also used : TestPart(uk.ac.ed.ph.jqtiplus.node.test.TestPart) AssessmentSectionSessionState(uk.ac.ed.ph.jqtiplus.state.AssessmentSectionSessionState)

Example 22 with TestPart

use of uk.ac.ed.ph.jqtiplus.node.test.TestPart in project openolat by klemens.

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 23 with TestPart

use of uk.ac.ed.ph.jqtiplus.node.test.TestPart in project openolat by klemens.

the class AssessmentTestComposerController method doDelete.

private void doDelete(UserRequest ureq, TreeNode selectedNode) {
    Object uobject = selectedNode.getUserObject();
    if (uobject instanceof TestPart) {
        doDeleteTestPart(ureq, (TestPart) uobject);
    } else if (uobject instanceof AssessmentSection) {
        AssessmentSection section = (AssessmentSection) uobject;
        if (checkAtLeastOneSection(section)) {
            doDeleteAssessmentSection(ureq, section);
        } else {
            showWarning("warning.atleastonesection");
        }
    } else if (uobject instanceof AssessmentItemRef) {
        doDeleteAssessmentItemRef(ureq, (AssessmentItemRef) uobject);
    } else {
        // cannot delete test or test part
        return;
    }
    doSaveAssessmentTest(ureq, null);
    doSaveManifest();
    updateTreeModel(false);
    if (selectedNode != null && selectedNode.getParent() != null) {
        TreeNode parentNode = (TreeNode) selectedNode.getParent();
        menuTree.setSelectedNode(parentNode);
        menuTree.open(parentNode);
        partEditorFactory(ureq, parentNode);
    }
}
Also used : TreeNode(org.olat.core.gui.components.tree.TreeNode) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) 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)

Example 24 with TestPart

use of uk.ac.ed.ph.jqtiplus.node.test.TestPart in project openolat by klemens.

the class AssessmentTestComposerController method doDrop.

private void doDrop(UserRequest ureq, String droppedNodeId, String targetnodeId, boolean asChild) {
    TreeNode droppedNode = menuTree.getTreeModel().getNodeById(droppedNodeId);
    TreeNode targetNode = menuTree.getTreeModel().getNodeById(targetnodeId);
    if (droppedNode == null || targetNode == null)
        return;
    Object droppedObject = droppedNode.getUserObject();
    Object targetObject = targetNode.getUserObject();
    if (droppedObject == null || targetObject == null || droppedObject == targetObject)
        return;
    if (asChild) {
        if (droppedObject instanceof AssessmentItemRef && (targetObject instanceof AssessmentSection || targetObject instanceof AssessmentItemRef)) {
            AssessmentItemRef droppedItemRef = (AssessmentItemRef) droppedObject;
            droppedItemRef.getParentSection().getSectionParts().remove(droppedItemRef);
            if (targetObject instanceof AssessmentSection) {
                AssessmentSection targetSection = (AssessmentSection) targetObject;
                targetSection.getSectionParts().add(droppedItemRef);
            } else if (targetObject instanceof AssessmentItemRef) {
                AssessmentItemRef targetItemRef = (AssessmentItemRef) targetObject;
                AssessmentSection targetSection = targetItemRef.getParentSection();
                int pos = targetSection.getChildAbstractParts().indexOf(targetItemRef);
                targetSection.getChildAbstractParts().add(pos, droppedItemRef);
            }
        } else if (droppedObject instanceof AssessmentSection && (targetObject instanceof AssessmentSection || targetObject instanceof TestPart || (targetObject instanceof AssessmentTest && ((AssessmentTest) targetObject).getTestParts().size() == 1))) {
            AssessmentSection droppedSection = (AssessmentSection) droppedObject;
            if (droppedSection.getParentSection() != null) {
                droppedSection.getParentSection().getSectionParts().remove(droppedSection);
            } else {
                droppedSection.getParent().getChildAbstractParts().remove(droppedSection);
            }
            if (targetObject instanceof AssessmentSection) {
                AssessmentSection targetSection = (AssessmentSection) targetObject;
                targetSection.getChildAbstractParts().add(droppedSection);
            } else if (targetObject instanceof TestPart) {
                TestPart targetTestPart = (TestPart) targetObject;
                targetTestPart.getAssessmentSections().add(droppedSection);
            } else if (targetObject instanceof AssessmentTest) {
                TestPart targetTestPart = ((AssessmentTest) targetObject).getTestParts().get(0);
                targetTestPart.getAssessmentSections().add(droppedSection);
            }
        }
    } else {
        if (droppedObject instanceof AssessmentItemRef && targetObject instanceof AssessmentItemRef) {
            AssessmentItemRef droppedItemRef = (AssessmentItemRef) droppedObject;
            droppedItemRef.getParentSection().getSectionParts().remove(droppedItemRef);
            AssessmentItemRef targetItemRef = (AssessmentItemRef) targetObject;
            AssessmentSection targetSection = targetItemRef.getParentSection();
            int pos = targetSection.getChildAbstractParts().indexOf(targetItemRef) + 1;
            if (pos < 0) {
                targetSection.getChildAbstractParts().add(droppedItemRef);
            } else if (pos >= targetSection.getChildAbstractParts().size()) {
                targetSection.getChildAbstractParts().add(droppedItemRef);
            } else {
                targetSection.getChildAbstractParts().add(pos, droppedItemRef);
            }
        } else if (droppedObject instanceof AssessmentSection && targetObject instanceof AssessmentSection) {
            AssessmentSection droppedSection = (AssessmentSection) droppedObject;
            if (droppedSection.getParentSection() != null) {
                droppedSection.getParentSection().getSectionParts().remove(droppedSection);
            } else {
                droppedSection.getParent().getChildAbstractParts().remove(droppedSection);
            }
            AssessmentSection targetSection = (AssessmentSection) targetObject;
            if (targetSection.getParentSection() != null) {
                AssessmentSection targetParentSection = targetSection.getParentSection();
                int pos = targetParentSection.getChildAbstractParts().indexOf(targetSection) + 1;
                if (pos >= targetParentSection.getChildAbstractParts().size()) {
                    targetParentSection.getChildAbstractParts().add(droppedSection);
                } else {
                    targetParentSection.getChildAbstractParts().add(pos, droppedSection);
                }
            } else if (targetSection.getParent() instanceof TestPart) {
                TestPart targetTestPart = (TestPart) targetSection.getParent();
                int pos = targetTestPart.getChildAbstractParts().indexOf(targetSection) + 1;
                if (pos >= targetTestPart.getChildAbstractParts().size()) {
                    targetTestPart.getChildAbstractParts().add(droppedSection);
                } else {
                    targetTestPart.getChildAbstractParts().add(pos, droppedSection);
                }
            }
        }
    }
    // quickly saved the assessment test with wrong parent
    doSaveAssessmentTest(ureq, null);
    // reload a clean instance
    updateTreeModel(false);
    TreeNode droppedItemNode = menuTree.getTreeModel().getNodeById(droppedNode.getIdent());
    if (droppedItemNode != null) {
        menuTree.setSelectedNode(droppedItemNode);
        menuTree.open(droppedItemNode);
        partEditorFactory(ureq, droppedItemNode);
    }
}
Also used : AssessmentTest(uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest) ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) TreeNode(org.olat.core.gui.components.tree.TreeNode) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) 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)

Example 25 with TestPart

use of uk.ac.ed.ph.jqtiplus.node.test.TestPart in project openolat by klemens.

the class AssessmentTestComposerController method recalculateMaxScoreAssessmentTest.

private void recalculateMaxScoreAssessmentTest(Map<AssessmentItemRef, AssessmentItem> flyingObjects) {
    DoubleAdder atomicMaxScore = new DoubleAdder();
    AssessmentTest assessmentTest = (AssessmentTest) menuTree.getTreeModel().getRootNode().getUserObject();
    AssessmentTestHelper.visit(assessmentTest, new AssessmentTestVisitor() {

        @Override
        public void visit(TestPart testPart) {
        /* */
        }

        @Override
        public void visit(SectionPart sectionPart) {
            if (sectionPart instanceof AssessmentItemRef) {
                AssessmentItemRef itemRef = (AssessmentItemRef) sectionPart;
                ResolvedAssessmentItem resolvedAssessmentItem = resolvedAssessmentTest.getResolvedAssessmentItem(itemRef);
                checkAndFixAbsolutePath(itemRef);
                AssessmentItem assessmentItem = null;
                if (resolvedAssessmentItem != null) {
                    assessmentItem = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
                }
                if (assessmentItem == null && flyingObjects != null && flyingObjects.containsKey(itemRef)) {
                    assessmentItem = flyingObjects.get(itemRef);
                }
                if (assessmentItem != null) {
                    Double maxScore = QtiNodesExtractor.extractMaxScore(assessmentItem);
                    if (maxScore != null) {
                        atomicMaxScore.add(maxScore.doubleValue());
                    }
                }
            }
        }
    });
    double sumMaxScore = atomicMaxScore.sum();
    if (sumMaxScore > 0.0d) {
        assessmentTestBuilder.setMaxScore(sumMaxScore);
    } else {
        assessmentTestBuilder.setMaxScore(null);
    }
}
Also used : AssessmentTest(uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest) ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) DoubleAdder(java.util.concurrent.atomic.DoubleAdder) SectionPart(uk.ac.ed.ph.jqtiplus.node.test.SectionPart) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) TestPart(uk.ac.ed.ph.jqtiplus.node.test.TestPart) AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) AssessmentTestVisitor(org.olat.ims.qti21.AssessmentTestHelper.AssessmentTestVisitor)

Aggregations

TestPart (uk.ac.ed.ph.jqtiplus.node.test.TestPart)50 AssessmentSection (uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection)28 AssessmentTest (uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest)20 ResolvedAssessmentTest (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest)16 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)12 TreeNode (org.olat.core.gui.components.tree.TreeNode)12 AssessmentItemRef (uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef)12 File (java.io.File)8 ItemSessionControl (uk.ac.ed.ph.jqtiplus.node.test.ItemSessionControl)8 TestPlanNode (uk.ac.ed.ph.jqtiplus.state.TestPlanNode)8 ResolvedAssessmentItem (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem)6 URI (java.net.URI)4 Date (java.util.Date)4 NameValuePair (org.olat.core.gui.components.form.flexible.impl.NameValuePair)4 CandidateEvent (org.olat.ims.qti21.model.audit.CandidateEvent)4 RubricBlock (uk.ac.ed.ph.jqtiplus.node.content.variable.RubricBlock)4 Ordering (uk.ac.ed.ph.jqtiplus.node.test.Ordering)4 TestSessionState (uk.ac.ed.ph.jqtiplus.state.TestSessionState)4 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)3 FileOutputStream (java.io.FileOutputStream)2