Search in sources :

Example 26 with Item

use of org.olat.ims.qti.editor.beecom.objects.Item in project openolat by klemens.

the class QTI12To21Converter method convert.

private void convert(Section section, TestPart testPart) throws URISyntaxException {
    AssessmentSection assessmentSection = AssessmentTestFactory.appendAssessmentSection("Section", testPart);
    assessmentSection.setTitle(section.getTitle());
    convertDuration(section.getDuration(), assessmentSection);
    RubricBlock rubricBlock = assessmentSection.getRubricBlocks().get(0);
    rubricBlock.getBlocks().clear();
    String objectives = section.getObjectives();
    htmlBuilder.appendHtml(rubricBlock, blockedHtml(objectives));
    boolean shuffle = SelectionOrdering.RANDOM.equals(section.getSelection_ordering().getOrderType());
    assessmentSection.getOrdering().setShuffle(shuffle);
    int selectionNum = section.getSelection_ordering().getSelectionNumber();
    if (selectionNum > 0) {
        Selection selection = new Selection(assessmentSection);
        selection.setSelect(selectionNum);
        assessmentSection.setSelection(selection);
    }
    List<Item> items = section.getItems();
    for (Item item : items) {
        AssessmentItemBuilder itemBuilder = null;
        if (item != null && item.getQuestion() != null) {
            int questionType = item.getQuestion().getType();
            switch(questionType) {
                case Question.TYPE_SC:
                    itemBuilder = convertSingleChoice(item);
                    break;
                case Question.TYPE_MC:
                    itemBuilder = convertMultipleChoice(item);
                    break;
                case Question.TYPE_KPRIM:
                    itemBuilder = convertKPrim(item);
                    break;
                case Question.TYPE_FIB:
                    itemBuilder = convertFIB(item);
                    break;
                case Question.TYPE_ESSAY:
                    itemBuilder = convertEssay(item);
                    break;
            }
        } else {
            errors.add(item.getTitle());
            log.error("Item without question: " + item);
        }
        if (itemBuilder != null) {
            itemBuilder.build();
            AssessmentItem assessmentItem = itemBuilder.getAssessmentItem();
            AssessmentItemRef itemRef = new AssessmentItemRef(assessmentSection);
            String itemId = IdentifierGenerator.newAsString(itemBuilder.getQuestionType().getPrefix());
            itemRef.setIdentifier(Identifier.parseString(itemId));
            convertItemBasics(item, itemRef);
            File itemFile = new File(unzippedDirRoot, itemId + ".xml");
            itemRef.setHref(new URI(itemFile.getName()));
            assessmentSection.getSectionParts().add(itemRef);
            persistAssessmentObject(itemFile, assessmentItem);
            appendResourceAndMetadata(item, itemBuilder, itemFile);
            // collect max score
            Double maxScore = QtiNodesExtractor.extractMaxScore(assessmentItem);
            if (maxScore != null && maxScore.doubleValue() > 0.0d) {
                atomicMaxScore.add(maxScore.doubleValue());
            }
        }
    }
}
Also used : Selection(uk.ac.ed.ph.jqtiplus.node.test.Selection) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) EssayAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.EssayAssessmentItemBuilder) 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) SimpleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.SimpleChoiceAssessmentItemBuilder) FIBAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder) SingleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.SingleChoiceAssessmentItemBuilder) URI(java.net.URI) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) Item(org.olat.ims.qti.editor.beecom.objects.Item) VFSItem(org.olat.core.util.vfs.VFSItem) AssessmentSection(uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection) AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef) RubricBlock(uk.ac.ed.ph.jqtiplus.node.content.variable.RubricBlock) File(java.io.File)

Example 27 with Item

use of org.olat.ims.qti.editor.beecom.objects.Item in project openolat by klemens.

the class QTI21QPoolServiceProvider method convert.

@Override
public QuestionItem convert(Identity owner, QuestionItemShort itemToConvert, Locale locale) {
    if (QTIConstants.QTI_12_FORMAT.equals(itemToConvert.getFormat())) {
        VFSLeaf leaf = qpoolService.getRootLeaf(itemToConvert);
        if (leaf == null) {
            return null;
        } else {
            Item qtiItem = QTIEditHelper.readItemXml(leaf);
            if (qtiItem != null && !qtiItem.isAlient()) {
                QuestionItemImpl original = questionItemDao.loadById(itemToConvert.getKey());
                QuestionItemImpl copy = questionItemDao.copy(original);
                copy.setTitle(original.getTitle());
                copy.setFormat(getFormat());
                VFSContainer originalDir = qpoolFileStorage.getContainer(original.getDirectory());
                File copyDir = qpoolFileStorage.getDirectory(copy.getDirectory());
                QTI12To21Converter converter = new QTI12To21Converter(copyDir, locale);
                if (converter.convert(copy, qtiItem, originalDir)) {
                    questionItemDao.persist(owner, copy);
                    return copy;
                }
            }
        }
    }
    return null;
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) Item(org.olat.ims.qti.editor.beecom.objects.Item) VFSItem(org.olat.core.util.vfs.VFSItem) QuestionItem(org.olat.modules.qpool.QuestionItem) QuestionItemImpl(org.olat.modules.qpool.model.QuestionItemImpl) VFSContainer(org.olat.core.util.vfs.VFSContainer) File(java.io.File)

Example 28 with Item

use of org.olat.ims.qti.editor.beecom.objects.Item in project openolat by klemens.

the class OLATUpgrade_11_0_0 method checkEssay.

private boolean checkEssay(RepositoryEntry testEntry) {
    if (qtiEssayMap.containsKey(testEntry.getKey())) {
        return qtiEssayMap.get(testEntry.getKey()).booleanValue();
    }
    TestFileResource fr = new TestFileResource();
    fr.overrideResourceableId(testEntry.getOlatResource().getResourceableId());
    TransientIdentity pseudoIdentity = new TransientIdentity();
    pseudoIdentity.setName("transient");
    Translator translator = Util.createPackageTranslator(QTIModule.class, Locale.ENGLISH);
    try {
        QTIEditorPackage qtiPackage = new QTIEditorPackageImpl(pseudoIdentity, fr, null, translator);
        if (qtiPackage.getQTIDocument() != null && qtiPackage.getQTIDocument().getAssessment() != null) {
            Assessment ass = qtiPackage.getQTIDocument().getAssessment();
            // Sections with their Items
            List<Section> sections = ass.getSections();
            for (Section section : sections) {
                List<Item> items = section.getItems();
                for (Item item : items) {
                    String ident = item.getIdent();
                    if (ident != null && ident.startsWith("QTIEDIT:ESSAY")) {
                        qtiEssayMap.put(testEntry.getKey(), Boolean.TRUE);
                        return true;
                    }
                }
            }
        }
    } catch (OLATRuntimeException e) {
        log.warn("QTI without content in repository entry: " + testEntry.getKey(), e);
    }
    qtiEssayMap.put(testEntry.getKey(), Boolean.FALSE);
    return false;
}
Also used : TransientIdentity(org.olat.admin.user.imp.TransientIdentity) Item(org.olat.ims.qti.editor.beecom.objects.Item) Translator(org.olat.core.gui.translator.Translator) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) QTIEditorPackageImpl(org.olat.ims.qti.editor.QTIEditorPackageImpl) Assessment(org.olat.ims.qti.editor.beecom.objects.Assessment) TestFileResource(org.olat.ims.qti.fileresource.TestFileResource) QTIEditorPackage(org.olat.ims.qti.editor.QTIEditorPackage) Section(org.olat.ims.qti.editor.beecom.objects.Section)

Example 29 with Item

use of org.olat.ims.qti.editor.beecom.objects.Item in project openolat by klemens.

the class OLATUpgrade_12_3_0 method getTitleQTI12.

private String getTitleQTI12(QuestionItemImpl item) {
    try {
        VFSLeaf leaf = qpoolService.getRootLeaf(item);
        Item xmlItem = QTIEditHelper.readItemXml(leaf);
        return xmlItem.getTitle();
    } catch (NullPointerException e) {
        log.warn("Cannot read files from dir: " + item.getDirectory());
    }
    return null;
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) Item(org.olat.ims.qti.editor.beecom.objects.Item) VFSItem(org.olat.core.util.vfs.VFSItem)

Example 30 with Item

use of org.olat.ims.qti.editor.beecom.objects.Item in project openolat by klemens.

the class QTI12AssessmentStatisticsController method initItemsOverview.

private void initItemsOverview(List<Item> items) {
    List<StatisticSurveyItem> surveyItems = qtiStatisticsManager.getStatisticAnswerOptions(resourceResult.getSearchParams(), items);
    int count = 0;
    List<String> overviewList = new ArrayList<>();
    for (StatisticSurveyItem surveyItem : surveyItems) {
        Item item = surveyItem.getItem();
        Series series = seriesfactory.getSeries(item, null);
        if (series != null) {
            // essay hasn't a series
            String name = "overview_" + count++;
            VelocityContainer vc = createVelocityContainer(name, "hbar_item_overview");
            vc.contextPut("series", series);
            vc.contextPut("question", item.getQuestion().getQuestion().renderAsHtml(mediaBaseURL));
            vc.contextPut("questionType", item.getQuestion().getType());
            vc.contextPut("title", item.getTitle());
            mainVC.put(vc.getDispatchID(), vc);
            overviewList.add(vc.getDispatchID());
        }
    }
    mainVC.contextPut("overviewList", overviewList);
}
Also used : StatisticSurveyItem(org.olat.ims.qti.statistics.model.StatisticSurveyItem) StatisticSurveyItem(org.olat.ims.qti.statistics.model.StatisticSurveyItem) Item(org.olat.ims.qti.editor.beecom.objects.Item) StatisticItem(org.olat.ims.qti.statistics.model.StatisticItem) BarSeries(org.olat.core.gui.components.chart.BarSeries) ArrayList(java.util.ArrayList) StatisticFormatter.getModeString(org.olat.ims.qti.statistics.ui.StatisticFormatter.getModeString) VelocityContainer(org.olat.core.gui.components.velocity.VelocityContainer)

Aggregations

Item (org.olat.ims.qti.editor.beecom.objects.Item)92 VFSItem (org.olat.core.util.vfs.VFSItem)38 Section (org.olat.ims.qti.editor.beecom.objects.Section)28 ArrayList (java.util.ArrayList)24 VFSContainer (org.olat.core.util.vfs.VFSContainer)18 Control (org.olat.ims.qti.editor.beecom.objects.Control)18 Element (org.dom4j.Element)16 Assessment (org.olat.ims.qti.editor.beecom.objects.Assessment)16 ChoiceQuestion (org.olat.ims.qti.editor.beecom.objects.ChoiceQuestion)16 Translator (org.olat.core.gui.translator.Translator)14 FIBResponse (org.olat.ims.qti.editor.beecom.objects.FIBResponse)14 Response (org.olat.ims.qti.editor.beecom.objects.Response)14 ItemNode (org.olat.ims.qti.editor.tree.ItemNode)14 File (java.io.File)12 QuestionItem (org.olat.modules.qpool.QuestionItem)12 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)10 FIBQuestion (org.olat.ims.qti.editor.beecom.objects.FIBQuestion)10 GenericQtiNode (org.olat.ims.qti.editor.tree.GenericQtiNode)10 SectionNode (org.olat.ims.qti.editor.tree.SectionNode)10 StatisticItem (org.olat.ims.qti.statistics.model.StatisticItem)10