Search in sources :

Example 11 with QTI21QuestionType

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

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

use of org.olat.ims.qti21.model.QTI21QuestionType 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 13 with QTI21QuestionType

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

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

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

the class AssessmentItemEditorController method initFIBEditors.

private AssessmentItemBuilder initFIBEditors(UserRequest ureq, QTI21QuestionType preferedType, AssessmentItem item) {
    FIBAssessmentItemBuilder fibItemBuilder = new FIBAssessmentItemBuilder(item, qtiService.qtiSerializer());
    itemEditor = new FIBEditorController(ureq, getWindowControl(), preferedType, fibItemBuilder, rootDirectory, rootContainer, itemFile, restrictedEdit, readOnly);
    listenTo(itemEditor);
    scoreEditor = new FIBScoreController(ureq, getWindowControl(), fibItemBuilder, itemRef, restrictedEdit, readOnly);
    listenTo(scoreEditor);
    feedbackEditor = new FeedbacksEditorController(ureq, getWindowControl(), fibItemBuilder, rootDirectory, rootContainer, itemFile, FeedbacksEnabler.standardFeedbacks(), restrictedEdit, readOnly);
    listenTo(feedbackEditor);
    tabbedPane.addTab(translate("form.fib"), itemEditor);
    tabbedPane.addTab(translate("form.score"), scoreEditor);
    tabbedPane.addTab(translate("form.feedback"), feedbackEditor);
    return fibItemBuilder;
}
Also used : FIBAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder) FIBScoreController(org.olat.ims.qti21.ui.editor.interactions.FIBScoreController) FIBEditorController(org.olat.ims.qti21.ui.editor.interactions.FIBEditorController)

Example 15 with QTI21QuestionType

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

the class UnkownItemEditorController method doConvertItem.

private void doConvertItem(UserRequest ureq, QTI21QuestionType alternativeType) {
    item.setToolName(QTI21Constants.TOOLNAME);
    item.setToolVersion(Settings.getVersion());
    if (alternativeType == QTI21QuestionType.matchdraganddrop) {
        addClassToInteraction(QTI21Constants.CSS_MATCH_DRAG_AND_DROP);
    }
    qtiService.updateAssesmentObject(itemFileRef, resolvedAssessmentItem);
    fireEvent(ureq, new AssessmentItemEvent(AssessmentItemEvent.ASSESSMENT_ITEM_NEED_RELOAD, item));
}
Also used : AssessmentItemEvent(org.olat.ims.qti21.ui.editor.events.AssessmentItemEvent)

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