Search in sources :

Example 11 with QEducationalContext

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

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

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

the class QEducationalContextDAOTest method testCreate.

@Test
public void testCreate() {
    String levelStr = "lowLevel-" + UUID.randomUUID().toString();
    QEducationalContext level = qEduContextDao.create(levelStr, true);
    dbInstance.commit();
    // check
    Assert.assertNotNull(level);
    Assert.assertNotNull(level.getKey());
    Assert.assertNotNull(level.getCreationDate());
    Assert.assertEquals(levelStr, level.getLevel());
    Assert.assertTrue(level.isDeletable());
}
Also used : QEducationalContext(org.olat.modules.qpool.model.QEducationalContext) Test(org.junit.Test)

Example 13 with QEducationalContext

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

the class QEducationalContextDAOTest method testCreateAndGet.

@Test
public void testCreateAndGet() {
    String levelStr = "highLevel-" + UUID.randomUUID().toString();
    QEducationalContext level = qEduContextDao.create(levelStr, true);
    dbInstance.commit();
    // load it
    QEducationalContext reloadedLevel = qEduContextDao.loadById(level.getKey());
    // check the values
    Assert.assertNotNull(reloadedLevel);
    Assert.assertEquals(level.getKey(), reloadedLevel.getKey());
    Assert.assertNotNull(reloadedLevel.getCreationDate());
    Assert.assertEquals(levelStr, reloadedLevel.getLevel());
    Assert.assertTrue(reloadedLevel.isDeletable());
}
Also used : QEducationalContext(org.olat.modules.qpool.model.QEducationalContext) Test(org.junit.Test)

Example 14 with QEducationalContext

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

the class QEducationalContextDAOTest method testDelete_notDeletable.

@Test
public void testDelete_notDeletable() {
    String levelStr = "uni-" + UUID.randomUUID().toString();
    QEducationalContext level = qEduContextDao.create(levelStr, false);
    dbInstance.commitAndCloseSession();
    // delete it
    boolean deleted = qEduContextDao.delete(level);
    dbInstance.commitAndCloseSession();
    Assert.assertFalse(deleted);
    // check that the type is really, really deleted
    QEducationalContext reloadedLevel = qEduContextDao.loadById(level.getKey());
    Assert.assertNotNull(reloadedLevel);
    List<QEducationalContext> allLevels = qEduContextDao.getEducationalContexts();
    Assert.assertTrue(allLevels.contains(level));
}
Also used : QEducationalContext(org.olat.modules.qpool.model.QEducationalContext) Test(org.junit.Test)

Example 15 with QEducationalContext

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

the class QuestionDAOTest method copyQuestion.

@Test
public void copyQuestion() {
    // create an item and fill it
    Taxonomy taxonomy = taxonomyDao.createTaxonomy("ID-QP", "QPool taxonomy", null, null);
    TaxonomyLevel taxonomyLevel = taxonomyLevelDao.createTaxonomyLevel("QP-L-1", "QLevel 1", "For testing only", null, null, null, null, taxonomy);
    QEducationalContext eduContext = qEduContextDao.create("primary.school", true);
    QItemType fibType = qItemTypeDao.loadByType(QuestionType.FIB.name());
    QItemType essayType = qItemTypeDao.loadByType(QuestionType.ESSAY.name());
    Identity author = JunitTestHelper.createAndPersistIdentityAsUser("QClone-1-" + UUID.randomUUID().toString());
    Identity cloner = JunitTestHelper.createAndPersistIdentityAsUser("QClone-2-" + UUID.randomUUID().toString());
    QuestionItemImpl original = questionDao.createAndPersist(author, "To copy", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), taxonomyLevel, null, "root.xml", fibType);
    dbInstance.commit();
    Assert.assertNotNull(original);
    Assert.assertNotNull(original.getIdentifier());
    Assert.assertNull(original.getMasterIdentifier());
    // general
    original.setTitle("Original");
    original.setTopic("Topic");
    original.setDescription("Original description");
    original.setKeywords("original copy to");
    original.setCoverage("New coverage");
    original.setAdditionalInformations("Additional informations before copy");
    original.setLanguage("en");
    // educational
    original.setEducationalContext(eduContext);
    original.setEducationalLearningTime("PT1H30M");
    // question
    original.setType(essayType);
    original.setDifficulty(new BigDecimal("0.1"));
    original.setStdevDifficulty(new BigDecimal("0.2"));
    original.setDifferentiation(new BigDecimal("-0.5"));
    original.setNumOfAnswerAlternatives(4);
    original.setUsage(5);
    original.setAssessmentType("formative");
    // lifecycle
    original.setItemVersion("1.0");
    original.setStatus(QuestionStatus.review.name());
    // technical
    original.setEditor("OpenOLAT");
    original.setEditorVersion("9.0a");
    original = questionDao.merge(original);
    dbInstance.commitAndCloseSession();
    // clone it
    QuestionItemImpl clone = questionDao.copy(original);
    questionDao.persist(cloner, clone);
    // compare
    Assert.assertEquals(1, questionDao.countItems(cloner));
    // general
    Assert.assertNotNull(clone.getIdentifier());
    Assert.assertFalse(clone.getIdentifier().equals(original.getIdentifier()));
    Assert.assertEquals(original.getIdentifier(), clone.getMasterIdentifier());
    Assert.assertNotNull(clone.getTitle());
    Assert.assertEquals("(Copy) " + original.getTitle(), clone.getTitle());
    Assert.assertEquals(original.getTopic(), clone.getTopic());
    Assert.assertEquals(original.getDescription(), clone.getDescription());
    Assert.assertEquals(original.getKeywords(), clone.getKeywords());
    Assert.assertEquals(original.getCoverage(), clone.getCoverage());
    Assert.assertEquals(original.getAdditionalInformations(), clone.getAdditionalInformations());
    Assert.assertEquals(original.getLanguage(), clone.getLanguage());
    // classification
    Assert.assertEquals(original.getTaxonomyLevelName(), clone.getTaxonomyLevelName());
    // educational
    Assert.assertEquals(original.getEducationalContext(), clone.getEducationalContext());
    Assert.assertEquals(original.getEducationalLearningTime(), clone.getEducationalLearningTime());
    // question
    Assert.assertEquals(original.getType(), clone.getType());
    Assert.assertNotNull(clone.getDifficulty());
    Assert.assertEquals(original.getDifficulty().doubleValue(), clone.getDifficulty().doubleValue(), 0.000001);
    Assert.assertNotNull(clone.getStdevDifficulty());
    Assert.assertEquals(original.getStdevDifficulty().doubleValue(), clone.getStdevDifficulty().doubleValue(), 0.000001);
    Assert.assertNotNull(clone.getDifferentiation());
    Assert.assertEquals(original.getDifferentiation().doubleValue(), clone.getDifferentiation().doubleValue(), 0.000001);
    Assert.assertEquals(original.getNumOfAnswerAlternatives(), clone.getNumOfAnswerAlternatives());
    Assert.assertEquals(0, clone.getUsage());
    Assert.assertEquals(original.getAssessmentType(), clone.getAssessmentType());
    // lifecycle
    Assert.assertEquals(QuestionStatus.draft.name(), clone.getStatus());
    Assert.assertNotNull(clone.getQuestionStatusLastModified());
    Assert.assertEquals(original.getItemVersion(), clone.getItemVersion());
    // technical
    Assert.assertEquals(original.getEditor(), clone.getEditor());
    Assert.assertEquals(original.getEditorVersion(), clone.getEditorVersion());
    Assert.assertEquals(original.getFormat(), clone.getFormat());
    Assert.assertNotNull(clone.getCreationDate());
    Assert.assertNotNull(clone.getLastModified());
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) QuestionItemImpl(org.olat.modules.qpool.model.QuestionItemImpl) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) QEducationalContext(org.olat.modules.qpool.model.QEducationalContext) Identity(org.olat.core.id.Identity) BigDecimal(java.math.BigDecimal) QItemType(org.olat.modules.qpool.model.QItemType) Test(org.junit.Test)

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