Search in sources :

Example 21 with QTI21QuestionType

use of org.olat.ims.qti21.model.QTI21QuestionType in project openolat by klemens.

the class AssessmentItemEditorController method initItemEditor.

private QTI21QuestionType initItemEditor(UserRequest ureq) {
    AssessmentItem item = resolvedAssessmentItem.getItemLookup().getRootNodeHolder().getRootNode();
    QTI21QuestionType type = QTI21QuestionType.getType(item);
    switch(type) {
        case sc:
            itemBuilder = initSingleChoiceEditors(ureq, item);
            break;
        case mc:
            itemBuilder = initMultipleChoiceEditors(ureq, item);
            break;
        case fib:
            itemBuilder = initFIBEditors(ureq, type, item);
            break;
        case numerical:
            itemBuilder = initFIBEditors(ureq, type, item);
            break;
        case kprim:
            itemBuilder = initKPrimChoiceEditors(ureq, item);
            break;
        case match:
            itemBuilder = initMatchChoiceEditors(ureq, item);
            break;
        case matchdraganddrop:
            itemBuilder = initMatchDragAndDropEditors(ureq, item);
            break;
        case matchtruefalse:
            itemBuilder = initMatchTrueFalseEditors(ureq, item);
            break;
        case hotspot:
            itemBuilder = initHotspotEditors(ureq, item);
            break;
        case essay:
            itemBuilder = initEssayEditors(ureq, item);
            break;
        case upload:
            itemBuilder = initUploadEditors(ureq, item);
            break;
        case drawing:
            itemBuilder = initDrawingEditors(ureq, item);
            break;
        case hottext:
            itemBuilder = initHottextEditors(ureq, item);
            break;
        default:
            initItemCreatedByUnkownEditor(ureq, item);
            break;
    }
    return type;
}
Also used : QTI21QuestionType(org.olat.ims.qti21.model.QTI21QuestionType) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)

Example 22 with QTI21QuestionType

use of org.olat.ims.qti21.model.QTI21QuestionType in project openolat by klemens.

the class QuestionTypeFlexiCellRenderer method render.

@Override
public void render(Renderer renderer, StringOutput target, Object cellValue, int row, FlexiTableComponent source, URLBuilder ubu, Translator trans) {
    if (cellValue instanceof QTI21QuestionType) {
        QTI21QuestionType type = (QTI21QuestionType) cellValue;
        target.append("<i class='o_icon o_icon-fw ").append(type.getCssClass()).append("'> </i> ").append(translator.translate("new." + type));
    }
}
Also used : QTI21QuestionType(org.olat.ims.qti21.model.QTI21QuestionType)

Example 23 with QTI21QuestionType

use of org.olat.ims.qti21.model.QTI21QuestionType in project openolat by klemens.

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 24 with QTI21QuestionType

use of org.olat.ims.qti21.model.QTI21QuestionType in project openolat by klemens.

the class AssessmentTestEditorAndComposerTreeModel method buildRecursively.

private TreeNode buildRecursively(AssessmentItemRef itemRef, TreeNode parentNode) {
    GenericTreeNode itemNode = new GenericTreeNode(itemRef.getIdentifier().toString());
    ResolvedAssessmentItem resolvedAssessmentItem = resolvedAssessmentTest.getResolvedAssessmentItem(itemRef);
    if (resolvedAssessmentItem == null || resolvedAssessmentItem.getItemLookup() == null || resolvedAssessmentItem.getItemLookup().getRootNodeHolder() == null) {
        itemNode.setTitle("ERROR - Not found");
        itemNode.setIconCssClass("o_icon o_icon_error");
        itemNode.setUserObject(itemRef);
        parentNode.addChild(itemNode);
    } else {
        BadResourceException ex = resolvedAssessmentItem.getItemLookup().getBadResourceException();
        if (ex != null) {
            itemNode.setTitle("ERROR");
            itemNode.setIconCssClass("o_icon o_icon_error");
            itemNode.setUserObject(itemRef);
            parentNode.addChild(itemNode);
        } else {
            AssessmentItem assessmentItem = resolvedAssessmentItem.getItemLookup().getRootNodeHolder().getRootNode();
            itemNode.setTitle(assessmentItem.getTitle());
            QTI21QuestionType type = QTI21QuestionType.getType(assessmentItem);
            if (type != null) {
                itemNode.setIconCssClass("o_icon ".concat(type.getCssClass()));
            } else {
                itemNode.setIconCssClass("o_icon o_mi_qtiunkown");
            }
            itemNode.setUserObject(itemRef);
            parentNode.addChild(itemNode);
        }
    }
    return itemNode;
}
Also used : BadResourceException(uk.ac.ed.ph.jqtiplus.provision.BadResourceException) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) QTI21QuestionType(org.olat.ims.qti21.model.QTI21QuestionType) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)

Example 25 with QTI21QuestionType

use of org.olat.ims.qti21.model.QTI21QuestionType in project openolat by klemens.

the class QTI21StatisticResourceResult method buildRecursively.

private TreeNode buildRecursively(AssessmentItemRef itemRef, TreeNode parentNode) {
    GenericTreeNode itemNode = new GenericTreeNode();
    ResolvedAssessmentItem resolvedAssessmentItem = resolvedAssessmentTest.getResolvedAssessmentItem(itemRef);
    BadResourceException ex = resolvedAssessmentItem.getItemLookup().getBadResourceException();
    if (ex == null) {
        AssessmentItem assessmentItem = resolvedAssessmentItem.getItemLookup().getRootNodeHolder().getRootNode();
        itemNode.setTitle(assessmentItem.getTitle());
        QTI21QuestionType type = QTI21QuestionType.getTypeRelax(assessmentItem);
        if (type != null) {
            itemNode.setIconCssClass("o_icon ".concat(type.getCssClass()));
        } else {
            itemNode.setIconCssClass("o_icon o_mi_qtiunkown");
        }
        itemNode.setUserObject(itemRef);
        parentNode.addChild(itemNode);
    }
    return itemNode;
}
Also used : BadResourceException(uk.ac.ed.ph.jqtiplus.provision.BadResourceException) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) QTI21QuestionType(org.olat.ims.qti21.model.QTI21QuestionType) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)

Aggregations

QTI21QuestionType (org.olat.ims.qti21.model.QTI21QuestionType)20 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)12 ResolvedAssessmentItem (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem)12 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)6 File (java.io.File)4 FIBAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder)4 AssessmentItemRef (uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef)4 BadResourceException (uk.ac.ed.ph.jqtiplus.provision.BadResourceException)4 FileOutputStream (java.io.FileOutputStream)2 IOException (java.io.IOException)2 OutputStream (java.io.OutputStream)2 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)2 TreeNode (org.olat.core.gui.components.tree.TreeNode)2 Translator (org.olat.core.gui.translator.Translator)2 AssertException (org.olat.core.logging.AssertException)2 LocalImpl (org.olat.core.util.vfs.LocalImpl)2 VFSContainer (org.olat.core.util.vfs.VFSContainer)2 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)2