Search in sources :

Example 21 with ResolvedAssessmentItem

use of uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem in project OpenOLAT by OpenOLAT.

the class ManifestMetadataBuilder method appendMetadataFrom.

public void appendMetadataFrom(QuestionItem item, ResolvedAssessmentItem resolvedAssessmentItem, Locale locale) {
    AssessmentItem assessmentItem = null;
    if (resolvedAssessmentItem != null) {
        assessmentItem = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
    }
    appendMetadataFrom(item, assessmentItem, locale);
}
Also used : ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)

Example 22 with ResolvedAssessmentItem

use of uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem 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>");
    }
}
Also used : AssessmentRenderFunctions.getOutcomeValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.getOutcomeValue) AssessmentRenderFunctions.extractRecordFieldValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.extractRecordFieldValue) Value(uk.ac.ed.ph.jqtiplus.value.Value) AssessmentRenderFunctions.getHtmlAttributeValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.getHtmlAttributeValue) AssessmentRenderFunctions.renderOrderedCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.renderOrderedCardinalityValue) AssessmentRenderFunctions.isMultipleCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isMultipleCardinalityValue) AssessmentRenderFunctions.renderSingleCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.renderSingleCardinalityValue) AssessmentRenderFunctions.renderMultipleCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.renderMultipleCardinalityValue) IdentifierValue(uk.ac.ed.ph.jqtiplus.value.IdentifierValue) AssessmentRenderFunctions.getTemplateValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.getTemplateValue) AssessmentRenderFunctions.renderRecordCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.renderRecordCardinalityValue) AssessmentRenderFunctions.getResponseValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.getResponseValue) AssessmentRenderFunctions.isNullValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isNullValue) AssessmentRenderFunctions.isSingleCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isSingleCardinalityValue) AssessmentRenderFunctions.isRecordCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isRecordCardinalityValue) AssessmentRenderFunctions.isOrderedCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isOrderedCardinalityValue) AssessmentRenderFunctions.isMathsContentValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isMathsContentValue) SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) HottextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HottextInteraction) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) AssessmentRenderFunctions.contentAsString(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.contentAsString) QtiNode(uk.ac.ed.ph.jqtiplus.node.QtiNode)

Example 23 with ResolvedAssessmentItem

use of uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem in project OpenOLAT by OpenOLAT.

the class AssessmentObjectComponentRenderer method renderBlock.

public void renderBlock(AssessmentRenderer renderer, StringOutput sb, AssessmentObjectComponent component, ResolvedAssessmentItem resolvedAssessmentItem, ItemSessionState itemSessionState, Block block, URLBuilder ubu, Translator translator) {
    switch(block.getQtiClassName()) {
        case AssociateInteraction.QTI_CLASS_NAME:
        case ChoiceInteraction.QTI_CLASS_NAME:
        case DrawingInteraction.QTI_CLASS_NAME:
        case ExtendedTextInteraction.QTI_CLASS_NAME:
        case GapMatchInteraction.QTI_CLASS_NAME:
        case GraphicAssociateInteraction.QTI_CLASS_NAME:
        case GraphicGapMatchInteraction.QTI_CLASS_NAME:
        case GraphicOrderInteraction.QTI_CLASS_NAME:
        case HotspotInteraction.QTI_CLASS_NAME:
        case SelectPointInteraction.QTI_CLASS_NAME:
        case HottextInteraction.QTI_CLASS_NAME:
        case MatchInteraction.QTI_CLASS_NAME:
        case MediaInteraction.QTI_CLASS_NAME:
        case OrderInteraction.QTI_CLASS_NAME:
        case PositionObjectInteraction.QTI_CLASS_NAME:
        case SliderInteraction.QTI_CLASS_NAME:
        case UploadInteraction.QTI_CLASS_NAME:
            {
                renderInteraction(renderer, sb, (FlowInteraction) block, resolvedAssessmentItem, itemSessionState, component, ubu, translator);
                break;
            }
        case CustomInteraction.QTI_CLASS_NAME:
            {
                renderCustomInteraction(renderer, sb, (CustomInteraction<?>) block, resolvedAssessmentItem, itemSessionState, component, ubu, translator);
                break;
            }
        case PositionObjectStage.QTI_CLASS_NAME:
            {
                renderPositionObjectStage(renderer, sb, (PositionObjectStage) block, resolvedAssessmentItem, itemSessionState, component, ubu, translator);
                break;
            }
        // never rendered
        case TemplateBlock.QTI_CLASS_NAME:
            break;
        case InfoControl.QTI_CLASS_NAME:
            {
                renderInfoControl(renderer, sb, component, resolvedAssessmentItem, itemSessionState, (InfoControl) block, ubu, translator);
                break;
            }
        case FeedbackBlock.QTI_CLASS_NAME:
            {
                FeedbackBlock feedbackBlock = (FeedbackBlock) block;
                if (component.isFeedback(feedbackBlock, itemSessionState)) {
                    sb.append("<div class='o_info feedbackBlock '").append(getAtClass(feedbackBlock)).append(">");
                    feedbackBlock.getBlocks().forEach((child) -> renderBlock(renderer, sb, component, resolvedAssessmentItem, itemSessionState, child, ubu, translator));
                    sb.append("</div>");
                }
                break;
            }
        // never rendered automatically
        case RubricBlock.QTI_CLASS_NAME:
            break;
        case Math.QTI_CLASS_NAME:
            {
                renderMath(renderer, sb, component, resolvedAssessmentItem, itemSessionState, (Math) block);
                break;
            }
        case Div.QTI_CLASS_NAME:
            renderStartHtmlTag(sb, component, resolvedAssessmentItem, block, null);
            ((Div) block).getFlows().forEach((flow) -> renderFlow(renderer, sb, component, resolvedAssessmentItem, itemSessionState, flow, ubu, translator));
            renderEndTag(sb, block);
            break;
        case Ul.QTI_CLASS_NAME:
            renderStartHtmlTag(sb, component, resolvedAssessmentItem, block, null);
            ((Ul) block).getLis().forEach((li) -> renderLi(renderer, sb, component, resolvedAssessmentItem, itemSessionState, li, ubu, translator));
            renderEndTag(sb, block);
            break;
        case Ol.QTI_CLASS_NAME:
            renderStartHtmlTag(sb, component, resolvedAssessmentItem, block, null);
            ((Ol) block).getLis().forEach((li) -> renderLi(renderer, sb, component, resolvedAssessmentItem, itemSessionState, li, ubu, translator));
            renderEndTag(sb, block);
            break;
        case Dl.QTI_CLASS_NAME:
            renderStartHtmlTag(sb, component, resolvedAssessmentItem, block, null);
            ((Dl) block).getDlElements().forEach((dlElement) -> renderDlElement(renderer, sb, component, resolvedAssessmentItem, itemSessionState, dlElement, ubu, translator));
            renderEndTag(sb, block);
            break;
        case Table.QTI_CLASS_NAME:
            renderTable(renderer, sb, component, resolvedAssessmentItem, itemSessionState, (Table) block, ubu, translator);
            break;
        case Object.QTI_CLASS_NAME:
            System.out.println("1");
            break;
        default:
            {
                renderStartHtmlTag(sb, component, resolvedAssessmentItem, block, null);
                if (block instanceof AtomicBlock) {
                    AtomicBlock atomicBlock = (AtomicBlock) block;
                    atomicBlock.getInlines().forEach((child) -> renderInline(renderer, sb, component, resolvedAssessmentItem, itemSessionState, child, ubu, translator));
                } else if (block instanceof SimpleBlock) {
                    SimpleBlock simpleBlock = (SimpleBlock) block;
                    simpleBlock.getBlocks().forEach((child) -> renderBlock(renderer, sb, component, resolvedAssessmentItem, itemSessionState, child, ubu, translator));
                }
                renderEndTag(sb, block);
            }
    }
}
Also used : Util(org.olat.core.util.Util) AtomicBlock(uk.ac.ed.ph.jqtiplus.node.content.basic.AtomicBlock) AssessmentRenderFunctions.extractMathsContentPmathml(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.extractMathsContentPmathml) Colgroup(uk.ac.ed.ph.jqtiplus.node.content.xhtml.table.Colgroup) AssessmentRenderFunctions.getAtClass(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.getAtClass) AssessmentRenderFunctions.getOutcomeValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.getOutcomeValue) StreamResult(javax.xml.transform.stream.StreamResult) RubricBlock(uk.ac.ed.ph.jqtiplus.node.content.variable.RubricBlock) CoreSpringFactory(org.olat.core.CoreSpringFactory) IntegerAttribute(uk.ac.ed.ph.jqtiplus.attribute.value.IntegerAttribute) Context(org.apache.velocity.context.Context) Flow(uk.ac.ed.ph.jqtiplus.node.content.basic.Flow) DrawingInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.DrawingInteraction) AssessmentRenderFunctions.isInvalidResponse(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isInvalidResponse) QTI21Module(org.olat.ims.qti21.QTI21Module) InfoControl(uk.ac.ed.ph.jqtiplus.node.content.InfoControl) TableCell(uk.ac.ed.ph.jqtiplus.node.content.xhtml.table.TableCell) OLog(org.olat.core.logging.OLog) AssessmentRenderFunctions.extractRecordFieldValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.extractRecordFieldValue) Translator(org.olat.core.gui.translator.Translator) FormJSHelper(org.olat.core.gui.components.form.flexible.impl.FormJSHelper) Tfoot(uk.ac.ed.ph.jqtiplus.node.content.xhtml.table.Tfoot) AssessmentRenderFunctions.getCardinalitySize(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.getCardinalitySize) TextRun(uk.ac.ed.ph.jqtiplus.node.content.basic.TextRun) Reader(java.io.Reader) Value(uk.ac.ed.ph.jqtiplus.value.Value) VelocityContext(org.apache.velocity.VelocityContext) QTI21Service(org.olat.ims.qti21.QTI21Service) EndAttemptInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.EndAttemptInteraction) AssessmentRenderFunctions.getHtmlAttributeValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.getHtmlAttributeValue) StringOutputPool(org.olat.core.gui.render.StringOutputPool) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) TemplateBlock(uk.ac.ed.ph.jqtiplus.node.content.template.TemplateBlock) XsltStylesheetManager(uk.ac.ed.ph.jqtiplus.xmlutils.xslt.XsltStylesheetManager) ForeignAttribute(uk.ac.ed.ph.jqtiplus.attribute.ForeignAttribute) GraphicOrderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicOrderInteraction) Block(uk.ac.ed.ph.jqtiplus.node.content.basic.Block) Hottext(uk.ac.ed.ph.jqtiplus.node.item.interaction.content.Hottext) VariableDeclaration(uk.ac.ed.ph.jqtiplus.node.shared.VariableDeclaration) AssessmentRenderFunctions.checkJavaScript(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.checkJavaScript) TextEntryInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction) QueryUtils(uk.ac.ed.ph.jqtiplus.utils.QueryUtils) AssessmentRenderFunctions.isTemplateDeclarationAMathVariable(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isTemplateDeclarationAMathVariable) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) QTI21Constants(org.olat.ims.qti21.QTI21Constants) StringMultipleAttribute(uk.ac.ed.ph.jqtiplus.attribute.value.StringMultipleAttribute) ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) FlowInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.FlowInteraction) MathEntryInteraction(uk.ac.ed.ph.qtiworks.mathassess.MathEntryInteraction) Attribute(uk.ac.ed.ph.jqtiplus.attribute.Attribute) Table(uk.ac.ed.ph.jqtiplus.node.content.xhtml.table.Table) ArrayList(java.util.ArrayList) XMLReader(org.xml.sax.XMLReader) Gap(uk.ac.ed.ph.jqtiplus.node.item.interaction.content.Gap) Cardinality(uk.ac.ed.ph.jqtiplus.value.Cardinality) AssessmentRenderFunctions.renderOrderedCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.renderOrderedCardinalityValue) ExtendedTextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ExtendedTextInteraction) OrderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.OrderInteraction) StringHelper(org.olat.core.util.StringHelper) RenderResult(org.olat.core.gui.render.RenderResult) Img(uk.ac.ed.ph.jqtiplus.node.content.xhtml.image.Img) AssessmentRenderFunctions.isMultipleCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isMultipleCardinalityValue) PrintedVariable(uk.ac.ed.ph.jqtiplus.node.content.variable.PrintedVariable) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) AssessmentRenderFunctions.isVisible(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isVisible) AssessmentRenderFunctions.renderSingleCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.renderSingleCardinalityValue) Inline(uk.ac.ed.ph.jqtiplus.node.content.basic.Inline) Br(uk.ac.ed.ph.jqtiplus.node.content.xhtml.text.Br) Interaction(uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction) IOException(java.io.IOException) ForeignElement(uk.ac.ed.ph.jqtiplus.node.ForeignElement) CodeHelper(org.olat.core.util.CodeHelper) AssessmentRenderFunctions.renderMultipleCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.renderMultipleCardinalityValue) StringReader(java.io.StringReader) SimpleBlock(uk.ac.ed.ph.jqtiplus.node.content.basic.SimpleBlock) AssessmentRenderFunctions.isBadResponse(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isBadResponse) NavigationMode(uk.ac.ed.ph.jqtiplus.node.test.NavigationMode) TransformerHandler(javax.xml.transform.sax.TransformerHandler) AssessmentRenderFunctions.exists(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.exists) AssessmentRenderFunctions.valueContains(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.valueContains) AssessmentRenderFunctions.extractSingleCardinalityResponseInput(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.extractSingleCardinalityResponseInput) URLBuilder(org.olat.core.gui.render.URLBuilder) TestPart(uk.ac.ed.ph.jqtiplus.node.test.TestPart) HottextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HottextInteraction) Form(org.olat.core.gui.components.form.flexible.impl.Form) GraphicAssociateInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicAssociateInteraction) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) AssessmentRenderFunctions.extractResponseInputAt(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.extractResponseInputAt) AssessmentRenderFunctions.contentAsString(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.contentAsString) XmlUtilities(org.olat.ims.qti21.XmlUtilities) A(uk.ac.ed.ph.jqtiplus.node.content.xhtml.hypertext.A) CustomInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.CustomInteraction) Object(uk.ac.ed.ph.jqtiplus.node.content.xhtml.object.Object) IdentifierValue(uk.ac.ed.ph.jqtiplus.value.IdentifierValue) AssessmentRenderFunctions.getTemplateValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.getTemplateValue) FormUIFactory(org.olat.core.gui.components.form.flexible.FormUIFactory) InlineChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.InlineChoiceInteraction) StringOutput(org.olat.core.gui.render.StringOutput) AssessmentRenderFunctions.extractIterableElement(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.extractIterableElement) Renderer(org.olat.core.gui.render.Renderer) SimpleInline(uk.ac.ed.ph.jqtiplus.node.content.basic.SimpleInline) URI(java.net.URI) AssessmentRenderFunctions.renderRecordCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.renderRecordCardinalityValue) AssessmentItemFactory(org.olat.ims.qti21.model.xml.AssessmentItemFactory) Col(uk.ac.ed.ph.jqtiplus.node.content.xhtml.table.Col) HotspotInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration) UploadInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.UploadInteraction) AssociateInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.AssociateInteraction) AssessmentRenderFunctions.getResponseValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.getResponseValue) AssessmentRenderFunctions.isNullValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isNullValue) ChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction) AssessmentRenderFunctions.isSingleCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isSingleCardinalityValue) FeedbackInline(uk.ac.ed.ph.jqtiplus.node.content.variable.FeedbackInline) Thead(uk.ac.ed.ph.jqtiplus.node.content.xhtml.table.Thead) List(java.util.List) MatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction) TextOrVariable(uk.ac.ed.ph.jqtiplus.node.content.variable.TextOrVariable) PositionObjectStage(uk.ac.ed.ph.jqtiplus.node.item.interaction.content.PositionObjectStage) BaseType(uk.ac.ed.ph.jqtiplus.value.BaseType) DefaultComponentRenderer(org.olat.core.gui.components.DefaultComponentRenderer) Ol(uk.ac.ed.ph.jqtiplus.node.content.xhtml.list.Ol) ModalFeedback(uk.ac.ed.ph.jqtiplus.node.item.ModalFeedback) Settings(org.olat.core.helpers.Settings) TestSessionController(uk.ac.ed.ph.jqtiplus.running.TestSessionController) QtiNode(uk.ac.ed.ph.jqtiplus.node.QtiNode) TemplateInline(uk.ac.ed.ph.jqtiplus.node.content.template.TemplateInline) AssessmentRenderFunctions.isRecordCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isRecordCardinalityValue) ResponseData(uk.ac.ed.ph.jqtiplus.types.ResponseData) FormItem(org.olat.core.gui.components.form.flexible.FormItem) Math(uk.ac.ed.ph.jqtiplus.node.content.mathml.Math) SelectPointInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.SelectPointInteraction) Span(uk.ac.ed.ph.jqtiplus.node.content.xhtml.text.Span) AssessmentRenderFunctions.isOrderedCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isOrderedCardinalityValue) AssessmentRenderFunctions.isMathsContentValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isMathsContentValue) SliderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.SliderInteraction) DlElement(uk.ac.ed.ph.jqtiplus.node.content.xhtml.list.DlElement) VelocityHelper(org.olat.core.gui.render.velocity.VelocityHelper) Li(uk.ac.ed.ph.jqtiplus.node.content.xhtml.list.Li) Tr(uk.ac.ed.ph.jqtiplus.node.content.xhtml.table.Tr) AssessmentRenderFunctions.getResponseDeclaration(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.getResponseDeclaration) InputSource(org.xml.sax.InputSource) Dd(uk.ac.ed.ph.jqtiplus.node.content.xhtml.list.Dd) Link(org.olat.core.gui.components.link.Link) PositionObjectInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.PositionObjectInteraction) Dl(uk.ac.ed.ph.jqtiplus.node.content.xhtml.list.Dl) FeedbackBlock(uk.ac.ed.ph.jqtiplus.node.content.variable.FeedbackBlock) SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) AttributeList(uk.ac.ed.ph.jqtiplus.attribute.AttributeList) Div(uk.ac.ed.ph.jqtiplus.node.content.xhtml.text.Div) Dt(uk.ac.ed.ph.jqtiplus.node.content.xhtml.list.Dt) Tbody(uk.ac.ed.ph.jqtiplus.node.content.xhtml.table.Tbody) GraphicGapMatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicGapMatchInteraction) MediaInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.MediaInteraction) GapMatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GapMatchInteraction) AssessmentRenderFunctions.getResponseInput(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.getResponseInput) Tracing(org.olat.core.logging.Tracing) Ul(uk.ac.ed.ph.jqtiplus.node.content.xhtml.list.Ul) StringEscapeUtils(org.apache.commons.lang.StringEscapeUtils) SimpleBlock(uk.ac.ed.ph.jqtiplus.node.content.basic.SimpleBlock) InfoControl(uk.ac.ed.ph.jqtiplus.node.content.InfoControl) FeedbackBlock(uk.ac.ed.ph.jqtiplus.node.content.variable.FeedbackBlock) AtomicBlock(uk.ac.ed.ph.jqtiplus.node.content.basic.AtomicBlock) CustomInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.CustomInteraction) FlowInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.FlowInteraction) Math(uk.ac.ed.ph.jqtiplus.node.content.mathml.Math) PositionObjectStage(uk.ac.ed.ph.jqtiplus.node.item.interaction.content.PositionObjectStage)

Example 24 with ResolvedAssessmentItem

use of uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem 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);
}
Also used : ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) VFSContainer(org.olat.core.util.vfs.VFSContainer) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) File(java.io.File) URI(java.net.URI)

Example 25 with ResolvedAssessmentItem

use of uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem in project OpenOLAT by OpenOLAT.

the class QTI21QPoolServiceProvider method importRepositoryEntry.

public List<QuestionItem> importRepositoryEntry(Identity owner, RepositoryEntry repositoryEntry, Locale defaultLocale) {
    FileResourceManager frm = FileResourceManager.getInstance();
    File unzippedDirRoot = frm.unzipFileResource(repositoryEntry.getOlatResource());
    ResolvedAssessmentTest resolvedAssessmentTest = qtiService.loadAndResolveAssessmentTest(unzippedDirRoot, false, true);
    ManifestBuilder clonedManifestBuilder = ManifestBuilder.read(new File(unzippedDirRoot, "imsmanifest.xml"));
    List<AssessmentItemRef> itemRefs = resolvedAssessmentTest.getAssessmentItemRefs();
    List<QuestionItem> importedItems = new ArrayList<>(itemRefs.size());
    for (AssessmentItemRef itemRef : itemRefs) {
        ResolvedAssessmentItem resolvedAssessmentItem = resolvedAssessmentTest.getResolvedAssessmentItem(itemRef);
        RootNodeLookup<AssessmentItem> rootNode = resolvedAssessmentItem.getItemLookup();
        URI itemUri = rootNode.getSystemId();
        File itemFile = new File(itemUri);
        String relativePathToManifest = unzippedDirRoot.toPath().relativize(itemFile.toPath()).toString();
        AssessmentItem assessmentItem = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
        ResourceType resource = clonedManifestBuilder.getResourceTypeByHref(relativePathToManifest);
        ManifestMetadataBuilder metadata = clonedManifestBuilder.getMetadataBuilder(resource, true);
        QuestionItem qitem = importAssessmentItemRef(owner, assessmentItem, itemFile, metadata, defaultLocale);
        importedItems.add(qitem);
    }
    return importedItems;
}
Also used : ManifestBuilder(org.olat.ims.qti21.model.xml.ManifestBuilder) ArrayList(java.util.ArrayList) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) ResourceType(org.olat.imscp.xml.manifest.ResourceType) ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) URI(java.net.URI) ManifestMetadataBuilder(org.olat.ims.qti21.model.xml.ManifestMetadataBuilder) FileResourceManager(org.olat.fileresource.FileResourceManager) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef) File(java.io.File) QuestionItem(org.olat.modules.qpool.QuestionItem)

Aggregations

ResolvedAssessmentItem (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem)106 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)76 File (java.io.File)38 URI (java.net.URI)32 AssessmentItemRef (uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef)26 AssessmentObjectXmlLoader (uk.ac.ed.ph.jqtiplus.reading.AssessmentObjectXmlLoader)26 QtiXmlReader (uk.ac.ed.ph.jqtiplus.reading.QtiXmlReader)26 ResourceLocator (uk.ac.ed.ph.jqtiplus.xmlutils.locators.ResourceLocator)26 PathResourceLocator (org.olat.fileresource.types.ImsQTI21Resource.PathResourceLocator)22 ItemSessionState (uk.ac.ed.ph.jqtiplus.state.ItemSessionState)22 IOException (java.io.IOException)20 JqtiExtensionManager (uk.ac.ed.ph.jqtiplus.JqtiExtensionManager)20 URISyntaxException (java.net.URISyntaxException)16 ManifestMetadataBuilder (org.olat.ims.qti21.model.xml.ManifestMetadataBuilder)16 ResolvedAssessmentTest (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest)14 ArrayList (java.util.ArrayList)12 ManifestBuilder (org.olat.ims.qti21.model.xml.ManifestBuilder)12 AssessmentSection (uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection)12 BadResourceException (uk.ac.ed.ph.jqtiplus.provision.BadResourceException)12 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)12