Search in sources :

Example 31 with QEducationalContext

use of org.olat.modules.qpool.model.QEducationalContext in project openolat by klemens.

the class GeneralMetadataEditController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    if (item instanceof QuestionItemImpl) {
        QuestionItemImpl itemImpl = (QuestionItemImpl) item;
        QuestionItemAuditLogBuilder builder = qpoolService.createAuditLogBuilder(getIdentity(), Action.UPDATE_QUESTION_ITEM_METADATA);
        builder.withBefore(itemImpl);
        itemImpl.setTopic(topicEl.getValue());
        if (taxonomyLevelEl.isOneSelected()) {
            String selectedKey = taxonomyLevelEl.getSelectedKey();
            TaxonomyLevel taxonomyLevel = qpoolTaxonomyTreeBuilder.getTaxonomyLevel(selectedKey);
            itemImpl.setTaxonomyLevel(taxonomyLevel);
        } else {
            itemImpl.setTaxonomyLevel(null);
        }
        QEducationalContext context = contextEl.isOneSelected() ? qpoolService.getEducationlContextByLevel(contextEl.getSelectedKey()) : null;
        itemImpl.setEducationalContext(context);
        if (StringHelper.containsNonWhitespace(keywordsEl.getValue())) {
            itemImpl.setKeywords(keywordsEl.getValue());
        } else {
            itemImpl.setKeywords("");
        }
        if (StringHelper.containsNonWhitespace(coverageEl.getValue())) {
            itemImpl.setCoverage(coverageEl.getValue());
        } else {
            itemImpl.setCoverage("");
        }
        if (StringHelper.containsNonWhitespace(addInfosEl.getValue())) {
            itemImpl.setAdditionalInformations(addInfosEl.getValue());
        } else {
            itemImpl.setAdditionalInformations(null);
        }
        itemImpl.setLanguage(languageEl.getValue());
        String assessmentType = assessmentTypeEl.isOneSelected() ? assessmentTypeEl.getSelectedKey() : null;
        itemImpl.setAssessmentType(assessmentType);
        item = qpoolService.updateItem(item);
        builder.withAfter(itemImpl);
        qpoolService.persist(builder.create());
        fireEvent(ureq, new QItemEdited(item));
    }
}
Also used : QuestionItemAuditLogBuilder(org.olat.modules.qpool.QuestionItemAuditLogBuilder) QItemEdited(org.olat.modules.qpool.ui.events.QItemEdited) QuestionItemImpl(org.olat.modules.qpool.model.QuestionItemImpl) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) QEducationalContext(org.olat.modules.qpool.model.QEducationalContext)

Example 32 with QEducationalContext

use of org.olat.modules.qpool.model.QEducationalContext in project openolat by klemens.

the class QTIImportProcessorTest method testImport_QTI12_sidecarMetadata.

@Test
public void testImport_QTI12_sidecarMetadata() throws IOException, URISyntaxException {
    URL itemUrl = QTIImportProcessorTest.class.getResource("qitem_metadatas.zip");
    Assert.assertNotNull(itemUrl);
    File itemFile = new File(itemUrl.toURI());
    // get the document informations
    QTIImportProcessor proc = new QTIImportProcessor(owner, Locale.ENGLISH, itemFile.getName(), itemFile);
    List<QuestionItem> items = proc.process();
    Assert.assertNotNull(items);
    Assert.assertEquals(1, items.size());
    dbInstance.commitAndCloseSession();
    // reload and check metadata
    QuestionItem item = questionItemDao.loadById(items.get(0).getKey());
    Assert.assertEquals("Une information en plus", item.getAdditionalInformations());
    Assert.assertEquals("formative", item.getAssessmentType());
    Assert.assertEquals("large", item.getCoverage());
    Assert.assertEquals(0, new BigDecimal("-0.1").compareTo(item.getDifferentiation()));
    Assert.assertEquals(0, new BigDecimal("0.45").compareTo(item.getDifficulty()));
    Assert.assertEquals("OpenOLAT", item.getEditor());
    Assert.assertEquals("9.4", item.getEditorVersion());
    QEducationalContext level = item.getEducationalContext();
    Assert.assertNotNull(level);
    Assert.assertEquals("University", level.getLevel());
    Assert.assertEquals("P5DT4H3M2S", item.getEducationalLearningTime());
    Assert.assertEquals("IMS QTI 1.2", item.getFormat());
    Assert.assertEquals("6bae65ac-f333-40ba-bdd0-13b54d016d59", item.getMasterIdentifier());
    Assert.assertFalse("6bae65ac-f333-40ba-bdd0-13b54d016d59".equals(item.getIdentifier()));
    Assert.assertEquals("sc", item.getItemType());
    Assert.assertEquals("1.01", item.getItemVersion());
    Assert.assertEquals("question export import Pluton", item.getKeywords());
    Assert.assertEquals("de", item.getLanguage());
    Assert.assertEquals(1, item.getNumOfAnswerAlternatives());
    Assert.assertNotNull(item.getQuestionStatus());
    Assert.assertEquals("review", item.getQuestionStatus().name());
    Assert.assertEquals(0, new BigDecimal("0.56").compareTo(item.getStdevDifficulty()));
    Assert.assertEquals("/Physique/Astronomie/Astrophysique/", item.getTaxonomicPath());
    Assert.assertEquals("Une question sur Pluton", item.getTitle());
    Assert.assertEquals(0, item.getUsage());
}
Also used : QEducationalContext(org.olat.modules.qpool.model.QEducationalContext) File(java.io.File) QuestionItem(org.olat.modules.qpool.QuestionItem) URL(java.net.URL) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 33 with QEducationalContext

use of org.olat.modules.qpool.model.QEducationalContext in project openolat by klemens.

the class QTIImportProcessor method processItemMetadata.

private void processItemMetadata(QuestionItemImpl poolItem, ItemAndMetadata metadata) {
    // non heuristic set of question type
    int questionType = metadata.getQuestionType();
    if (questionType >= 0) {
        String typeStr;
        switch(questionType) {
            case Question.TYPE_MC:
                typeStr = QuestionType.MC.name();
                break;
            case Question.TYPE_SC:
                typeStr = QuestionType.SC.name();
                break;
            case Question.TYPE_FIB:
                typeStr = QuestionType.FIB.name();
                break;
            case Question.TYPE_ESSAY:
                typeStr = QuestionType.ESSAY.name();
                break;
            default:
                typeStr = null;
        }
        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);
    }
    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);
    }
    int numOfAnswerAlternatives = metadata.getNumOfAnswerAlternatives();
    if (numOfAnswerAlternatives > 0) {
        poolItem.setNumOfAnswerAlternatives(numOfAnswerAlternatives);
    }
    poolItem.setDifficulty(metadata.getDifficulty());
    poolItem.setDifferentiation(metadata.getDifferentiation());
    poolItem.setStdevDifficulty(metadata.getStdevDifficulty());
}
Also used : TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) QEducationalContext(org.olat.modules.qpool.model.QEducationalContext) QItemType(org.olat.modules.qpool.model.QItemType)

Example 34 with QEducationalContext

use of org.olat.modules.qpool.model.QEducationalContext 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)

Aggregations

QEducationalContext (org.olat.modules.qpool.model.QEducationalContext)34 Test (org.junit.Test)18 QItemType (org.olat.modules.qpool.model.QItemType)8 TaxonomyLevel (org.olat.modules.taxonomy.TaxonomyLevel)8 File (java.io.File)4 BigDecimal (java.math.BigDecimal)4 URL (java.net.URL)4 QuestionItem (org.olat.modules.qpool.QuestionItem)4 QuestionItemImpl (org.olat.modules.qpool.model.QuestionItemImpl)4 Date (java.util.Date)2 SelectionEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent)2 Identity (org.olat.core.id.Identity)2 QTIMetadataConverter (org.olat.ims.qti.qpool.QTIMetadataConverter)2 QTI21QuestionType (org.olat.ims.qti21.model.QTI21QuestionType)2 QuestionItemAuditLogBuilder (org.olat.modules.qpool.QuestionItemAuditLogBuilder)2 QItemEdited (org.olat.modules.qpool.ui.events.QItemEdited)2 Taxonomy (org.olat.modules.taxonomy.Taxonomy)2