Search in sources :

Example 16 with QTI21QuestionType

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

the class QTI21WordExport method renderAssessmentItem.

public static void renderAssessmentItem(AssessmentItem item, File itemFile, File mediaDir, OpenXMLDocument document, boolean withResponses, Translator translator, AssessmentHtmlBuilder htmlBuilder) {
    StringBuilder addText = new StringBuilder();
    QTI21QuestionType type = QTI21QuestionType.getType(item);
    String typeDescription = "";
    switch(type) {
        case sc:
            typeDescription = translator.translate("form.choice");
            break;
        case mc:
            typeDescription = translator.translate("form.choice");
            break;
        case fib:
            typeDescription = translator.translate("form.fib");
            break;
        case numerical:
            typeDescription = translator.translate("form.fib");
            break;
        case kprim:
            typeDescription = translator.translate("form.kprim");
            break;
        case hotspot:
            typeDescription = translator.translate("form.hotspot");
            break;
        case essay:
            typeDescription = translator.translate("form.essay");
            break;
        case upload:
            typeDescription = translator.translate("form.upload");
            break;
        case drawing:
            typeDescription = translator.translate("form.drawing");
            break;
        case match:
            typeDescription = translator.translate("form.match");
            break;
        default:
            typeDescription = null;
            break;
    }
    Double maxScore = QtiNodesExtractor.extractMaxScore(item);
    if (StringHelper.containsNonWhitespace(typeDescription) || maxScore != null) {
        if (StringHelper.containsNonWhitespace(typeDescription)) {
            addText.append("(").append(typeDescription).append(")");
        }
        if (maxScore != null) {
            addText.append(" - ").append(AssessmentHelper.getRoundedScore(maxScore));
        }
    }
    String title = item.getTitle();
    document.appendHeading1(title, addText.toString());
    List<Block> itemBodyBlocks = item.getItemBody().getBlocks();
    String html = htmlBuilder.blocksString(itemBodyBlocks);
    document.appendHtmlText(html, true, new QTI21AndHTMLToOpenXMLHandler(document, item, itemFile, mediaDir, withResponses, htmlBuilder, translator));
    if (withResponses && (type == QTI21QuestionType.essay || type == QTI21QuestionType.upload || type == QTI21QuestionType.drawing)) {
        renderCorrectSolutionForWord(item, document, translator, htmlBuilder);
    }
}
Also used : QTI21QuestionType(org.olat.ims.qti21.model.QTI21QuestionType) RubricBlock(uk.ac.ed.ph.jqtiplus.node.content.variable.RubricBlock) Block(uk.ac.ed.ph.jqtiplus.node.content.basic.Block)

Example 17 with QTI21QuestionType

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

the class QTI21ImportProcessor method processItemMetadata.

// additionalInformations, assessmentType
protected void processItemMetadata(QuestionItemImpl poolItem, AssessmentItemMetadata metadata) {
    // non heuristic set of question type
    String typeStr = null;
    QTI21QuestionType questionType = metadata.getQuestionType();
    if (questionType != null && questionType.getPoolQuestionType() != null) {
        typeStr = questionType.getPoolQuestionType().name();
    }
    if (typeStr != null) {
        QItemType type = qItemTypeDao.loadByType(typeStr);
        if (type != null) {
            poolItem.setType(type);
        }
    }
    String coverage = metadata.getCoverage();
    if (StringHelper.containsNonWhitespace(coverage)) {
        poolItem.setCoverage(coverage);
    }
    String language = metadata.getLanguage();
    if (StringHelper.containsNonWhitespace(language)) {
        poolItem.setLanguage(language);
    }
    String keywords = metadata.getKeywords();
    if (StringHelper.containsNonWhitespace(keywords)) {
        poolItem.setKeywords(keywords);
    }
    String taxonomyPath = metadata.getTaxonomyPath();
    if (StringHelper.containsNonWhitespace(taxonomyPath)) {
        QTIMetadataConverter converter = new QTIMetadataConverter(qItemTypeDao, qEduContextDao, qpoolService);
        TaxonomyLevel taxonomyLevel = converter.toTaxonomy(taxonomyPath);
        poolItem.setTaxonomyLevel(taxonomyLevel);
    }
    // educational
    String level = metadata.getLevel();
    if (StringHelper.containsNonWhitespace(level)) {
        QTIMetadataConverter converter = new QTIMetadataConverter(qItemTypeDao, qEduContextDao, qpoolService);
        QEducationalContext educationalContext = converter.toEducationalContext(level);
        poolItem.setEducationalContext(educationalContext);
    }
    String time = metadata.getTypicalLearningTime();
    if (StringHelper.containsNonWhitespace(time)) {
        poolItem.setEducationalLearningTime(time);
    }
    String editor = metadata.getEditor();
    if (StringHelper.containsNonWhitespace(editor)) {
        poolItem.setEditor(editor);
    }
    String editorVersion = metadata.getEditorVersion();
    if (StringHelper.containsNonWhitespace(editorVersion)) {
        poolItem.setEditorVersion(editorVersion);
    }
    // OpenOLAT
    poolItem.setDifficulty(metadata.getDifficulty());
    poolItem.setDifferentiation(metadata.getDifferentiation());
    poolItem.setStdevDifficulty(metadata.getStdevDifficulty());
    int numOfAnswerAlternatives = metadata.getNumOfAnswerAlternatives();
    if (numOfAnswerAlternatives > 0) {
        poolItem.setNumOfAnswerAlternatives(numOfAnswerAlternatives);
    }
    poolItem.setTopic(metadata.getTopic());
    poolItem.setAssessmentType(metadata.getAssessmentType());
    poolItem.setAdditionalInformations(metadata.getAdditionalInformations());
}
Also used : QTIMetadataConverter(org.olat.ims.qti.qpool.QTIMetadataConverter) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) QTI21QuestionType(org.olat.ims.qti21.model.QTI21QuestionType) QEducationalContext(org.olat.modules.qpool.model.QEducationalContext) QItemType(org.olat.modules.qpool.model.QItemType)

Example 18 with QTI21QuestionType

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

the class QTI21QPoolServiceProvider method createItem.

public QuestionItem createItem(Identity identity, QTI21QuestionType type, String title, Locale locale) {
    AssessmentItemBuilder itemBuilder = null;
    Translator translator = Util.createPackageTranslator(AssessmentTestComposerController.class, locale);
    switch(type) {
        case sc:
            itemBuilder = new SingleChoiceAssessmentItemBuilder(translator.translate("new.sc"), translator.translate("new.answer"), qtiService.qtiSerializer());
            break;
        case mc:
            itemBuilder = new MultipleChoiceAssessmentItemBuilder(translator.translate("new.mc"), translator.translate("new.answer"), qtiService.qtiSerializer());
            break;
        case kprim:
            itemBuilder = new KPrimAssessmentItemBuilder(translator.translate("new.kprim"), translator.translate("new.answer"), qtiService.qtiSerializer());
            break;
        case match:
            itemBuilder = new MatchAssessmentItemBuilder(translator.translate("new.match"), QTI21Constants.CSS_MATCH_MATRIX, qtiService.qtiSerializer());
            break;
        case matchdraganddrop:
            itemBuilder = new MatchAssessmentItemBuilder(translator.translate("new.match"), QTI21Constants.CSS_MATCH_DRAG_AND_DROP, qtiService.qtiSerializer());
            break;
        case matchtruefalse:
            itemBuilder = new MatchAssessmentItemBuilder(translator.translate("new.match"), QTI21Constants.CSS_MATCH_TRUE_FALSE, translator.translate("match.unanswered"), translator.translate("match.true"), translator.translate("match.false"), qtiService.qtiSerializer());
            break;
        case fib:
            itemBuilder = new FIBAssessmentItemBuilder(translator.translate("new.fib"), EntryType.text, qtiService.qtiSerializer());
            break;
        case numerical:
            itemBuilder = new FIBAssessmentItemBuilder(translator.translate("new.fib.numerical"), EntryType.numerical, qtiService.qtiSerializer());
            break;
        case essay:
            itemBuilder = new EssayAssessmentItemBuilder(translator.translate("new.essay"), qtiService.qtiSerializer());
            break;
        case upload:
            itemBuilder = new UploadAssessmentItemBuilder(translator.translate("new.upload"), qtiService.qtiSerializer());
            break;
        case drawing:
            itemBuilder = new DrawingAssessmentItemBuilder(translator.translate("new.drawing"), qtiService.qtiSerializer());
            break;
        case hotspot:
            itemBuilder = new HotspotAssessmentItemBuilder(translator.translate("new.hotspot"), qtiService.qtiSerializer());
            break;
        case hottext:
            itemBuilder = new HottextAssessmentItemBuilder(translator.translate("new.hottext"), translator.translate("new.hottext.start"), translator.translate("new.hottext.text"), qtiService.qtiSerializer());
            break;
        default:
            return null;
    }
    AssessmentItem assessmentItem = itemBuilder.getAssessmentItem();
    assessmentItem.setLabel(title);
    assessmentItem.setTitle(title);
    AssessmentItemMetadata itemMetadata = new AssessmentItemMetadata();
    itemMetadata.setQuestionType(type);
    QTI21ImportProcessor processor = new QTI21ImportProcessor(identity, locale);
    QuestionItemImpl qitem = processor.processItem(assessmentItem, "", null, "OpenOLAT", Settings.getVersion(), itemMetadata);
    VFSContainer baseDir = qpoolFileStorage.getContainer(qitem.getDirectory());
    VFSLeaf leaf = baseDir.createChildLeaf(qitem.getRootFilename());
    File itemFile = ((LocalImpl) leaf).getBasefile();
    qtiService.persistAssessmentObject(itemFile, assessmentItem);
    // create imsmanifest
    ManifestBuilder manifest = ManifestBuilder.createAssessmentItemBuilder();
    manifest.appendAssessmentItem(itemFile.getName());
    manifest.write(new File(itemFile.getParentFile(), "imsmanifest.xml"));
    return qitem;
}
Also used : HottextAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.HottextAssessmentItemBuilder) VFSLeaf(org.olat.core.util.vfs.VFSLeaf) ManifestBuilder(org.olat.ims.qti21.model.xml.ManifestBuilder) SingleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.SingleChoiceAssessmentItemBuilder) QuestionItemImpl(org.olat.modules.qpool.model.QuestionItemImpl) VFSContainer(org.olat.core.util.vfs.VFSContainer) EssayAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.EssayAssessmentItemBuilder) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) HotspotAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.HotspotAssessmentItemBuilder) UploadAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.UploadAssessmentItemBuilder) FIBAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder) SingleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.SingleChoiceAssessmentItemBuilder) HottextAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.HottextAssessmentItemBuilder) DrawingAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.DrawingAssessmentItemBuilder) EssayAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.EssayAssessmentItemBuilder) MatchAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.MatchAssessmentItemBuilder) AssessmentItemBuilder(org.olat.ims.qti21.model.xml.AssessmentItemBuilder) KPrimAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.KPrimAssessmentItemBuilder) MultipleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.MultipleChoiceAssessmentItemBuilder) MultipleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.MultipleChoiceAssessmentItemBuilder) MatchAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.MatchAssessmentItemBuilder) FIBAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder) KPrimAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.KPrimAssessmentItemBuilder) Translator(org.olat.core.gui.translator.Translator) AssessmentItemMetadata(org.olat.ims.qti21.model.xml.AssessmentItemMetadata) HotspotAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.HotspotAssessmentItemBuilder) UploadAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.UploadAssessmentItemBuilder) LocalImpl(org.olat.core.util.vfs.LocalImpl) File(java.io.File) DrawingAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.DrawingAssessmentItemBuilder)

Example 19 with QTI21QuestionType

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

the class QTI21WordExport method renderAssessmentItem.

public static void renderAssessmentItem(AssessmentItem item, File itemFile, File mediaDir, OpenXMLDocument document, boolean withResponses, Translator translator, AssessmentHtmlBuilder htmlBuilder) {
    StringBuilder addText = new StringBuilder();
    QTI21QuestionType type = QTI21QuestionType.getType(item);
    String typeDescription = "";
    switch(type) {
        case sc:
            typeDescription = translator.translate("form.choice");
            break;
        case mc:
            typeDescription = translator.translate("form.choice");
            break;
        case fib:
            typeDescription = translator.translate("form.fib");
            break;
        case numerical:
            typeDescription = translator.translate("form.fib");
            break;
        case kprim:
            typeDescription = translator.translate("form.kprim");
            break;
        case hotspot:
            typeDescription = translator.translate("form.hotspot");
            break;
        case essay:
            typeDescription = translator.translate("form.essay");
            break;
        case upload:
            typeDescription = translator.translate("form.upload");
            break;
        case drawing:
            typeDescription = translator.translate("form.drawing");
            break;
        case match:
            typeDescription = translator.translate("form.match");
            break;
        default:
            typeDescription = null;
            break;
    }
    Double maxScore = QtiNodesExtractor.extractMaxScore(item);
    if (StringHelper.containsNonWhitespace(typeDescription) || maxScore != null) {
        if (StringHelper.containsNonWhitespace(typeDescription)) {
            addText.append("(").append(typeDescription).append(")");
        }
        if (maxScore != null) {
            addText.append(" - ").append(AssessmentHelper.getRoundedScore(maxScore));
        }
    }
    String title = item.getTitle();
    document.appendHeading1(title, addText.toString());
    List<Block> itemBodyBlocks = item.getItemBody().getBlocks();
    String html = htmlBuilder.blocksString(itemBodyBlocks);
    document.appendHtmlText(html, true, new QTI21AndHTMLToOpenXMLHandler(document, item, itemFile, mediaDir, withResponses, htmlBuilder, translator));
    if (withResponses && (type == QTI21QuestionType.essay || type == QTI21QuestionType.upload || type == QTI21QuestionType.drawing)) {
        renderCorrectSolutionForWord(item, document, translator, htmlBuilder);
    }
}
Also used : QTI21QuestionType(org.olat.ims.qti21.model.QTI21QuestionType) RubricBlock(uk.ac.ed.ph.jqtiplus.node.content.variable.RubricBlock) Block(uk.ac.ed.ph.jqtiplus.node.content.basic.Block)

Example 20 with QTI21QuestionType

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

the class AlienItemAnalyzer method analyze.

public Report analyze() {
    try {
        // processing are quiet large.
        if (item.getToolName() != null && "TAO".equalsIgnoreCase(item.getToolName())) {
            return new Report(QTI21QuestionType.unkown, true);
        }
        QTI21QuestionType type = QTI21QuestionType.getTypeRelax(item);
        Report report = new Report(type);
        checkTemplateProcessing(report);
        checkFeedback(report);
        checkItemBody(report);
        checkCustomOperator(report);
        checkKprim(report);
        return report;
    } catch (Exception e) {
        log.error("", e);
        return new Report(QTI21QuestionType.unkown, true);
    }
}
Also used : QTI21QuestionType(org.olat.ims.qti21.model.QTI21QuestionType)

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