Search in sources :

Example 66 with ResolvedAssessmentItem

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

the class AssessmentTestComposerController method doCopy.

private void doCopy(UserRequest ureq) {
    TreeNode selectedNode = menuTree.getSelectedNode();
    if (selectedNode == null || !(selectedNode.getUserObject() instanceof AssessmentItemRef))
        return;
    AssessmentItemRef itemRefToCopy = (AssessmentItemRef) selectedNode.getUserObject();
    AssessmentSection section = itemRefToCopy.getParentSection();
    ResolvedAssessmentItem resolvedAssessmentItem = resolvedAssessmentTest.getResolvedAssessmentItem(itemRefToCopy);
    AssessmentItem originalAssessmentItem = resolvedAssessmentItem.getItemLookup().extractIfSuccessful();
    if (originalAssessmentItem == null) {
        showError("error.assessment.item");
        return;
    }
    QTI21QuestionType type = QTI21QuestionType.getType(originalAssessmentItem);
    File itemFile = null;
    try {
        AssessmentItemRef itemRef = new AssessmentItemRef(section);
        String itemId = IdentifierGenerator.newAsString(getTypePrefix(type));
        itemRef.setIdentifier(Identifier.parseString(itemId));
        itemFile = new File(unzippedDirRoot, itemId + ".xml");
        itemRef.setHref(new URI(itemFile.getName()));
        try (OutputStream out = new FileOutputStream(itemFile)) {
            // make the copy
            qtiService.qtiSerializer().serializeJqtiObject(originalAssessmentItem, out);
            // change identifier and title
            ResolvedAssessmentItem resolvedCopyItem = qtiService.loadAndResolveAssessmentItemForCopy(itemFile.toURI(), unzippedDirRoot);
            AssessmentItem copiedAssessmentItem = resolvedCopyItem.getRootNodeLookup().extractIfSuccessful();
            copiedAssessmentItem.setIdentifier(IdentifierGenerator.newAsString(getTypePrefix(type)));
            copiedAssessmentItem.setTitle(originalAssessmentItem.getTitle() + " (Copy)");
            qtiService.updateAssesmentObject(itemFile, resolvedCopyItem);
            // add to section
            section.getSectionParts().add(itemRef);
            Map<AssessmentItemRef, AssessmentItem> flyingObjects = Collections.singletonMap(itemRef, copiedAssessmentItem);
            doSaveAssessmentTest(ureq, flyingObjects);
            manifestBuilder.appendAssessmentItem(itemFile.getName());
            doSaveManifest();
        } catch (Exception e) {
            logError("", e);
        }
        updateTreeModel(false);
        TreeNode newItemNode = menuTree.getTreeModel().getNodeById(itemId);
        menuTree.setSelectedNode(newItemNode);
        menuTree.open(newItemNode);
        partEditorFactory(ureq, newItemNode);
    } catch (URISyntaxException e) {
        logError("", e);
    }
}
Also used : FileOutputStream(java.io.FileOutputStream) OutputStream(java.io.OutputStream) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) AssertException(org.olat.core.logging.AssertException) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) TreeNode(org.olat.core.gui.components.tree.TreeNode) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentSection(uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection) FileOutputStream(java.io.FileOutputStream) AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef) QTI21QuestionType(org.olat.ims.qti21.model.QTI21QuestionType) File(java.io.File)

Example 67 with ResolvedAssessmentItem

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

the class AssessmentTestComponent method willShowFeedbacks.

/**
 * Check if the assessment item will show some
 * form of feedback like feedbackElement, modalFeedback
 * or message as invalid or bad response.
 *
 * @param itemNode
 * @return
 */
public boolean willShowFeedbacks(TestPlanNode itemNode) {
    if (isHideFeedbacks()) {
        return false;
    }
    try {
        URI itemSystemId = itemNode.getItemSystemId();
        ResolvedAssessmentItem resolvedAssessmentItem = getResolvedAssessmentTest().getResolvedAssessmentItemBySystemIdMap().get(itemSystemId);
        AssessmentItem assessmentItem = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
        if (assessmentItem.getAdaptive()) {
            return true;
        }
        ItemSessionState itemSessionState = getItemSessionState(itemNode.getKey());
        if (!itemSessionState.isResponded()) {
            return true;
        }
        ItemProcessingContext itemContext = getTestSessionController().getItemProcessingContext(itemNode);
        if (itemContext instanceof ItemSessionController) {
            ItemSessionController itemSessionController = (ItemSessionController) itemContext;
            List<Interaction> interactions = itemSessionController.getInteractions();
            for (Interaction interaction : interactions) {
                if (AssessmentRenderFunctions.isBadResponse(itemSessionState, interaction.getResponseIdentifier())) {
                    return true;
                }
                if (AssessmentRenderFunctions.isInvalidResponse(itemSessionState, interaction.getResponseIdentifier())) {
                    return true;
                }
            }
        }
        if (assessmentItem.getItemBody().willShowFeedback(itemContext)) {
            return true;
        }
        List<ModalFeedback> modalFeedbacks = assessmentItem.getModalFeedbacks();
        for (ModalFeedback modalFeedback : modalFeedbacks) {
            if (isFeedback(modalFeedback, itemSessionState)) {
                return true;
            }
        }
    } catch (Exception e) {
        log.error("", e);
    }
    return false;
}
Also used : ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) Interaction(uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction) ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) ModalFeedback(uk.ac.ed.ph.jqtiplus.node.item.ModalFeedback) ItemSessionController(uk.ac.ed.ph.jqtiplus.running.ItemSessionController) URI(java.net.URI) ItemProcessingContext(uk.ac.ed.ph.jqtiplus.running.ItemProcessingContext)

Example 68 with ResolvedAssessmentItem

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

the class FeedbackResultComponentRenderer method render.

@Override
public void render(Renderer renderer, StringOutput sb, Component source, URLBuilder ubu, Translator translator, RenderResult renderResult, String[] args) {
    FeedbackResultComponent cmp = (FeedbackResultComponent) source;
    ResolvedAssessmentItem resolvedAssessmentItem = cmp.getResolvedAssessmentItem();
    ItemSessionState itemSessionState = cmp.getItemSessionState();
    AssessmentRenderer assessmentRenderer = new AssessmentRenderer(renderer);
    AssessmentItem assessmentItem = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
    for (ModalFeedback modalFeedback : assessmentItem.getModalFeedbacks()) {
        Identifier outcomeIdentifier = modalFeedback.getOutcomeIdentifier();
        if (QTI21Constants.CORRECT_SOLUTION_IDENTIFIER.equals(outcomeIdentifier)) {
            sb.append("<div class='modalFeedback'>");
            renderAssessmentItemCorrectSolutionModalFeedback(assessmentRenderer, sb, modalFeedback, cmp, resolvedAssessmentItem, itemSessionState, ubu, translator);
            sb.append("</div>");
        }
    }
}
Also used : Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) ModalFeedback(uk.ac.ed.ph.jqtiplus.node.item.ModalFeedback)

Example 69 with ResolvedAssessmentItem

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

the class QTI21StatisticResourceResult method createAssessmentItemController.

private Controller createAssessmentItemController(UserRequest ureq, WindowControl wControl, AssessmentItemRef assessmentItemRef, String sectionTitle, boolean printMode) {
    ResolvedAssessmentItem resolvedAssessmentItem = resolvedAssessmentTest.getResolvedAssessmentItem(assessmentItemRef);
    Controller ctrl = new QTI21AssessmentItemStatisticsController(ureq, wControl, assessmentItemRef, resolvedAssessmentItem, sectionTitle, this, withFilter, printMode);
    String iconCssClass = "o_mi_qtisc";
    if (courseNode != null) {
        ctrl = TitledWrapperHelper.getWrapper(ureq, wControl, ctrl, courseNode, iconCssClass);
    }
    return ctrl;
}
Also used : ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) Controller(org.olat.core.gui.control.Controller)

Example 70 with ResolvedAssessmentItem

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

the class ItemBodyResultComponentRenderer method render.

@Override
public void render(Renderer renderer, StringOutput sb, Component source, URLBuilder ubu, Translator translator, RenderResult renderResult, String[] args) {
    ItemBodyResultComponent cmp = (ItemBodyResultComponent) source;
    ResolvedAssessmentItem resolvedAssessmentItem = cmp.getResolvedAssessmentItem();
    AssessmentItem assessmentItem = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
    ItemSessionState itemSessionState = cmp.getItemSessionState();
    AssessmentRenderer assessmentRenderer = new AssessmentRenderer(renderer);
    if (cmp.isShowSolution()) {
        assessmentRenderer.setSolutionAllowed(true);
        assessmentRenderer.setSolutionMode(true);
    } else {
        assessmentRenderer.setReviewMode(true);
    }
    assessmentItem.getItemBody().getBlocks().forEach((block) -> renderBlock(assessmentRenderer, sb, cmp, resolvedAssessmentItem, itemSessionState, block, ubu, translator));
}
Also used : ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)

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