use of uk.ac.ed.ph.jqtiplus.node.QtiNode in project OpenOLAT by OpenOLAT.
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;
}
use of uk.ac.ed.ph.jqtiplus.node.QtiNode in project OpenOLAT by OpenOLAT.
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());
}
}
use of uk.ac.ed.ph.jqtiplus.node.QtiNode in project OpenOLAT by OpenOLAT.
the class AssessmentObjectComponentRenderer method renderHottext.
/*
<xsl:template match="qti:hottext">
<xsl:if test="qw:is-visible(.)">
<xsl:variable name="hottextInteraction" select="ancestor::qti:hottextInteraction" as="element(qti:hottextInteraction)"/>
<xsl:variable name="responseIdentifier" select="$hottextInteraction/@responseIdentifier" as="xs:string"/>
<span class="hottext">
<input type="{if ($hottextInteraction/@maxChoices=1) then 'radio' else 'checkbox'}"
name="qtiworks_response_{$responseIdentifier}"
value="{@identifier}">
<xsl:if test="$isItemSessionEnded">
<xsl:attribute name="disabled">disabled</xsl:attribute>
</xsl:if>
<xsl:if test="qw:value-contains(qw:get-response-value(/, $responseIdentifier), @identifier)">
<xsl:attribute name="checked" select="'checked'"/>
</xsl:if>
</input>
<xsl:apply-templates/>
</span>
</xsl:if>
</xsl:template>
*/
private void renderHottext(AssessmentRenderer renderer, StringOutput sb, ResolvedAssessmentItem resolvedAssessmentItem, ItemSessionState itemSessionState, Hottext hottext, AssessmentObjectComponent component, URLBuilder ubu, Translator translator) {
if (!isVisible(hottext, itemSessionState))
return;
HottextInteraction interaction = null;
for (QtiNode parentNode = hottext.getParent(); parentNode.getParent() != null; parentNode = parentNode.getParent()) {
if (parentNode instanceof HottextInteraction) {
interaction = (HottextInteraction) parentNode;
break;
}
}
if (interaction != null) {
sb.append("<span class='hottext'><input type='");
if (interaction.getMaxChoices() == 1) {
sb.append("radio");
} else {
sb.append("checkbox");
}
String guid = "oo_" + CodeHelper.getRAMUniqueID();
String responseUniqueId = component.getResponseUniqueIdentifier(itemSessionState, interaction);
sb.append("' id='").append(guid).append("' name='qtiworks_response_").append(responseUniqueId).append("'").append(" value='").append(hottext.getIdentifier().toString()).append("'");
if (component.isItemSessionEnded(itemSessionState, renderer.isSolutionMode())) {
sb.append(" disabled");
}
AssessmentItem assessmentItem = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
Value responseValue = getResponseValue(assessmentItem, itemSessionState, interaction.getResponseIdentifier(), renderer.isSolutionMode());
if (valueContains(responseValue, hottext.getIdentifier())) {
sb.append(" checked");
}
sb.append(" />");
sb.append("<label for='").append(guid).append("'>");
hottext.getInlineStatics().forEach((inline) -> renderInline(renderer, sb, component, resolvedAssessmentItem, itemSessionState, inline, ubu, translator));
FormJSHelper.appendFlexiFormDirtyOn(sb, component.getQtiItem().getRootForm(), "change click", guid);
sb.append("</label></span>");
}
}
use of uk.ac.ed.ph.jqtiplus.node.QtiNode in project openolat by klemens.
the class AssessmentObjectComponentRenderer method renderHottext.
/*
<xsl:template match="qti:hottext">
<xsl:if test="qw:is-visible(.)">
<xsl:variable name="hottextInteraction" select="ancestor::qti:hottextInteraction" as="element(qti:hottextInteraction)"/>
<xsl:variable name="responseIdentifier" select="$hottextInteraction/@responseIdentifier" as="xs:string"/>
<span class="hottext">
<input type="{if ($hottextInteraction/@maxChoices=1) then 'radio' else 'checkbox'}"
name="qtiworks_response_{$responseIdentifier}"
value="{@identifier}">
<xsl:if test="$isItemSessionEnded">
<xsl:attribute name="disabled">disabled</xsl:attribute>
</xsl:if>
<xsl:if test="qw:value-contains(qw:get-response-value(/, $responseIdentifier), @identifier)">
<xsl:attribute name="checked" select="'checked'"/>
</xsl:if>
</input>
<xsl:apply-templates/>
</span>
</xsl:if>
</xsl:template>
*/
private void renderHottext(AssessmentRenderer renderer, StringOutput sb, ResolvedAssessmentItem resolvedAssessmentItem, ItemSessionState itemSessionState, Hottext hottext, AssessmentObjectComponent component, URLBuilder ubu, Translator translator) {
if (!isVisible(hottext, itemSessionState))
return;
HottextInteraction interaction = null;
for (QtiNode parentNode = hottext.getParent(); parentNode.getParent() != null; parentNode = parentNode.getParent()) {
if (parentNode instanceof HottextInteraction) {
interaction = (HottextInteraction) parentNode;
break;
}
}
if (interaction != null) {
sb.append("<span class='hottext'><input type='");
if (interaction.getMaxChoices() == 1) {
sb.append("radio");
} else {
sb.append("checkbox");
}
String guid = "oo_" + CodeHelper.getRAMUniqueID();
String responseUniqueId = component.getResponseUniqueIdentifier(itemSessionState, interaction);
sb.append("' id='").append(guid).append("' name='qtiworks_response_").append(responseUniqueId).append("'").append(" value='").append(hottext.getIdentifier().toString()).append("'");
if (component.isItemSessionEnded(itemSessionState, renderer.isSolutionMode())) {
sb.append(" disabled");
}
AssessmentItem assessmentItem = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
Value responseValue = getResponseValue(assessmentItem, itemSessionState, interaction.getResponseIdentifier(), renderer.isSolutionMode());
if (valueContains(responseValue, hottext.getIdentifier())) {
sb.append(" checked");
}
sb.append(" />");
sb.append("<label for='").append(guid).append("'>");
hottext.getInlineStatics().forEach((inline) -> renderInline(renderer, sb, component, resolvedAssessmentItem, itemSessionState, inline, ubu, translator));
FormJSHelper.appendFlexiFormDirtyOn(sb, component.getQtiItem().getRootForm(), "change click", guid);
sb.append("</label></span>");
}
}
use of uk.ac.ed.ph.jqtiplus.node.QtiNode in project OpenOLAT by OpenOLAT.
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>");
}
}
Aggregations