use of uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem in project OpenOLAT by OpenOLAT.
the class FIBAssessmentItemBuilder method createAssessmentItem.
private static AssessmentItem createAssessmentItem(String title, EntryType type) {
AssessmentItem assessmentItem = AssessmentItemFactory.createAssessmentItem(QTI21QuestionType.fib, title);
// define the response
Identifier responseDeclarationId = Identifier.assumedLegal("RESPONSE_1");
if (type == EntryType.numerical) {
ResponseDeclaration responseDeclaration = createNumericalEntryResponseDeclaration(assessmentItem, responseDeclarationId, 42);
assessmentItem.getNodeGroups().getResponseDeclarationGroup().getResponseDeclarations().add(responseDeclaration);
} else {
ResponseDeclaration responseDeclaration = createTextEntryResponseDeclaration(assessmentItem, responseDeclarationId, "gap", Collections.emptyList());
assessmentItem.getNodeGroups().getResponseDeclarationGroup().getResponseDeclarations().add(responseDeclaration);
}
// outcomes
appendDefaultOutcomeDeclarations(assessmentItem, 1.0d);
ItemBody itemBody = appendDefaultItemBody(assessmentItem);
appendTextEntryInteraction(itemBody, responseDeclarationId);
// response processing
ResponseProcessing responseProcessing = createResponseProcessing(assessmentItem, responseDeclarationId);
assessmentItem.getNodeGroups().getResponseProcessingGroup().setResponseProcessing(responseProcessing);
return assessmentItem;
}
use of uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem 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.item.AssessmentItem in project OpenOLAT by OpenOLAT.
the class MultipleChoiceAssessmentItemBuilder method createAssessmentItem.
private static AssessmentItem createAssessmentItem(String title, String defaultAnswer) {
AssessmentItem assessmentItem = AssessmentItemFactory.createAssessmentItem(QTI21QuestionType.mc, title);
NodeGroupList nodeGroups = assessmentItem.getNodeGroups();
Identifier responseDeclarationId = Identifier.assumedLegal("RESPONSE_1");
Identifier correctResponseId = IdentifierGenerator.newAsIdentifier("mc");
// define correct answer
ResponseDeclaration responseDeclaration = createMultipleChoiceCorrectResponseDeclaration(assessmentItem, responseDeclarationId, Collections.singletonList(correctResponseId));
nodeGroups.getResponseDeclarationGroup().getResponseDeclarations().add(responseDeclaration);
// outcomes
appendDefaultOutcomeDeclarations(assessmentItem, 1.0d);
// the single choice interaction
ItemBody itemBody = appendDefaultItemBody(assessmentItem);
ChoiceInteraction choiceInteraction = appendChoiceInteraction(itemBody, responseDeclarationId, 0, true);
appendSimpleChoice(choiceInteraction, defaultAnswer, correctResponseId);
// response processing
ResponseProcessing responseProcessing = createResponseProcessing(assessmentItem, responseDeclarationId);
assessmentItem.getNodeGroups().getResponseProcessingGroup().setResponseProcessing(responseProcessing);
return assessmentItem;
}
use of uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem in project OpenOLAT by OpenOLAT.
the class SingleChoiceAssessmentItemBuilder method createAssessmentItem.
private static AssessmentItem createAssessmentItem(String title, String defaultAnswer) {
AssessmentItem assessmentItem = AssessmentItemFactory.createAssessmentItem(QTI21QuestionType.sc, title);
// define correct answer
Identifier responseDeclarationId = Identifier.assumedLegal("RESPONSE_1");
Identifier correctResponseId = IdentifierGenerator.newAsIdentifier("sc");
ResponseDeclaration responseDeclaration = createSingleChoiceCorrectResponseDeclaration(assessmentItem, responseDeclarationId, correctResponseId);
assessmentItem.getNodeGroups().getResponseDeclarationGroup().getResponseDeclarations().add(responseDeclaration);
// outcomes
appendDefaultOutcomeDeclarations(assessmentItem, 1.0d);
// the single choice interaction
ItemBody itemBody = appendDefaultItemBody(assessmentItem);
ChoiceInteraction choiceInteraction = appendChoiceInteraction(itemBody, responseDeclarationId, 1, true);
appendSimpleChoice(choiceInteraction, defaultAnswer, correctResponseId);
// response processing
ResponseProcessing responseProcessing = createResponseProcessing(assessmentItem, responseDeclarationId);
assessmentItem.getNodeGroups().getResponseProcessingGroup().setResponseProcessing(responseProcessing);
return assessmentItem;
}
use of uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem in project OpenOLAT by OpenOLAT.
the class QTI21QPoolServiceProvider method copyItem.
@Override
public void copyItem(QuestionItemFull original, QuestionItemFull copy) {
VFSContainer originalDir = qpoolFileStorage.getContainer(original.getDirectory());
VFSContainer copyDir = qpoolFileStorage.getContainer(copy.getDirectory());
VFSManager.copyContent(originalDir, copyDir);
File file = qpoolService.getRootFile(copy);
File resourceDirectory = qpoolService.getRootDirectory(copy);
URI assessmentItemUri = file.toURI();
File itemFile = qpoolService.getRootFile(copy);
ResolvedAssessmentItem resolvedAssessmentItem = qtiService.loadAndResolveAssessmentItem(assessmentItemUri, resourceDirectory);
AssessmentItem assessmentItem = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
assessmentItem.setTitle(copy.getTitle());
qtiService.persistAssessmentObject(itemFile, assessmentItem);
}
Aggregations