Search in sources :

Example 6 with QtiNode

use of uk.ac.ed.ph.jqtiplus.node.QtiNode 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 7 with QtiNode

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

the class AssessmentObjectComponentRenderer method renderGap.

/*
	  <xsl:template match="qti:gap">
	    <xsl:variable name="gmi" select="ancestor::qti:gapMatchInteraction" as="element(qti:gapMatchInteraction)"/>
	    <xsl:variable name="gaps" select="$gmi//qti:gap" as="element(qti:gap)+"/>
	    <xsl:variable name="thisGap" select="." as="element(qti:gap)"/>
	    <span class="gap" id="qtiworks_id_{$gmi/@responseIdentifier}_{@identifier}">
	      <!-- (Print index of this gap wrt all gaps in the interaction) -->
	      GAP <xsl:value-of select="for $i in 1 to count($gaps) return
	        if ($gaps[$i]/@identifier = $thisGap/@identifier) then $i else ()"/>
	    </span>
	  </xsl:template>
	 */
private void renderGap(StringOutput sb, Gap gap, ItemSessionState itemSessionState, AssessmentObjectComponent component) {
    GapMatchInteraction interaction = null;
    for (QtiNode parentNode = gap.getParent(); parentNode.getParent() != null; parentNode = parentNode.getParent()) {
        if (parentNode instanceof GapMatchInteraction) {
            interaction = (GapMatchInteraction) parentNode;
            break;
        }
    }
    if (interaction != null) {
        List<Gap> gaps = QueryUtils.search(Gap.class, interaction.getBlockStatics());
        String responseUniqueId = component.getResponseUniqueIdentifier(itemSessionState, interaction);
        sb.append("<span class='gap' id=\"qtiworks_id_").append(responseUniqueId).append("_").append(gap.getIdentifier().toString()).append("\">");
        sb.append("GAP ").append(gaps.indexOf(gap));
        sb.append("</span>");
    }
}
Also used : GraphicGapMatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicGapMatchInteraction) GapMatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GapMatchInteraction) Gap(uk.ac.ed.ph.jqtiplus.node.item.interaction.content.Gap) AssessmentRenderFunctions.contentAsString(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.contentAsString) QtiNode(uk.ac.ed.ph.jqtiplus.node.QtiNode)

Example 8 with QtiNode

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

the class AssessmentTestComposerController method doExportPool.

private void doExportPool() {
    TreeNode selectedNode = menuTree.getSelectedNode();
    if (selectedNode == null)
        return;
    AtomicInteger counter = new AtomicInteger();
    Object uobject = selectedNode.getUserObject();
    if (uobject instanceof AssessmentItemRef) {
        doExportPool((AssessmentItemRef) uobject);
        counter.incrementAndGet();
    } else if (uobject instanceof QtiNode) {
        QtiNode qtiNode = (QtiNode) uobject;
        QueryUtils.walkTree(new TreeWalkNodeHandler() {

            @Override
            public boolean handleNode(QtiNode node) {
                if (node instanceof AssessmentItemRef) {
                    doExportPool((AssessmentItemRef) node);
                    counter.incrementAndGet();
                }
                return true;
            }
        }, qtiNode);
    }
    if (counter.get() > 0) {
        showInfo("export.qpool.successful", counter.toString());
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TreeNode(org.olat.core.gui.components.tree.TreeNode) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef) TreeWalkNodeHandler(uk.ac.ed.ph.jqtiplus.utils.TreeWalkNodeHandler) QtiNode(uk.ac.ed.ph.jqtiplus.node.QtiNode)

Aggregations

QtiNode (uk.ac.ed.ph.jqtiplus.node.QtiNode)8 AssessmentRenderFunctions.contentAsString (org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.contentAsString)4 AssessmentItemRef (uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)2 TreeNode (org.olat.core.gui.components.tree.TreeNode)2 ParentPartItemRefs (org.olat.ims.qti21.model.ParentPartItemRefs)2 AssessmentRenderFunctions.extractRecordFieldValue (org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.extractRecordFieldValue)2 AssessmentRenderFunctions.getHtmlAttributeValue (org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.getHtmlAttributeValue)2 AssessmentRenderFunctions.getOutcomeValue (org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.getOutcomeValue)2 AssessmentRenderFunctions.getResponseValue (org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.getResponseValue)2 AssessmentRenderFunctions.getTemplateValue (org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.getTemplateValue)2 AssessmentRenderFunctions.isMathsContentValue (org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isMathsContentValue)2 AssessmentRenderFunctions.isMultipleCardinalityValue (org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isMultipleCardinalityValue)2 AssessmentRenderFunctions.isNullValue (org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isNullValue)2 AssessmentRenderFunctions.isOrderedCardinalityValue (org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isOrderedCardinalityValue)2 AssessmentRenderFunctions.isRecordCardinalityValue (org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isRecordCardinalityValue)2 AssessmentRenderFunctions.isSingleCardinalityValue (org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isSingleCardinalityValue)2 AssessmentRenderFunctions.renderMultipleCardinalityValue (org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.renderMultipleCardinalityValue)2 AssessmentRenderFunctions.renderOrderedCardinalityValue (org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.renderOrderedCardinalityValue)2