Search in sources :

Example 61 with Taxonomy

use of org.olat.modules.taxonomy.Taxonomy in project openolat by klemens.

the class TaxonomyLevelDAOTest method updateTaxonomyLevel_simple.

@Test
public void updateTaxonomyLevel_simple() {
    Taxonomy taxonomy = taxonomyDao.createTaxonomy("ID-105", "Updated taxonomy", null, null);
    String displayName = UUID.randomUUID().toString();
    TaxonomyLevel level1 = taxonomyLevelDao.createTaxonomyLevel("U-1", displayName, "A basic level", null, null, null, null, taxonomy);
    TaxonomyLevel level2 = taxonomyLevelDao.createTaxonomyLevel("U-2", displayName, "A basic level", null, null, level1, null, taxonomy);
    dbInstance.commitAndCloseSession();
    // update the level 2
    TaxonomyLevel reloadedLevel2 = taxonomyLevelDao.loadByKey(level2.getKey());
    reloadedLevel2.setDisplayName("Updated");
    reloadedLevel2.setIdentifier("UU");
    TaxonomyLevel updatedLevel2 = taxonomyLevelDao.updateTaxonomyLevel(reloadedLevel2);
    dbInstance.commitAndCloseSession();
    // check its path
    String identifiersPath = updatedLevel2.getMaterializedPathIdentifiers();
    Assert.assertEquals("/U-1/UU/", identifiersPath);
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) Test(org.junit.Test)

Example 62 with Taxonomy

use of org.olat.modules.taxonomy.Taxonomy in project openolat by klemens.

the class TaxonomyLevelTypeDAOTest method createAndLoadTaxonomyLevelType.

@Test
public void createAndLoadTaxonomyLevelType() {
    Taxonomy taxonomy = taxonomyDao.createTaxonomy("Tax-type", "Typed taxonomy", "A typed taxonomy", "");
    TaxonomyLevelType type = taxonomyLevelTypeDao.createTaxonomyLevelType("Type-reload", "A first reloaded type", "Typed", "TYP-1", taxonomy);
    dbInstance.commitAndCloseSession();
    TaxonomyLevelType reloadedType = taxonomyLevelTypeDao.loadTaxonomyLevelTypeByKey(type.getKey());
    Assert.assertNotNull(reloadedType);
    Assert.assertEquals(type, reloadedType);
    Assert.assertEquals("Type-reload", reloadedType.getIdentifier());
    Assert.assertEquals("A first reloaded type", reloadedType.getDisplayName());
    Assert.assertEquals("Typed", reloadedType.getDescription());
    Assert.assertEquals("TYP-1", reloadedType.getExternalId());
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) TaxonomyLevelType(org.olat.modules.taxonomy.TaxonomyLevelType) Test(org.junit.Test)

Example 63 with Taxonomy

use of org.olat.modules.taxonomy.Taxonomy in project openolat by klemens.

the class TaxonomyLevelTypeDAOTest method loadTaxonomyLevelTypeByTaxonomy.

@Test
public void loadTaxonomyLevelTypeByTaxonomy() {
    Taxonomy taxonomy = taxonomyDao.createTaxonomy("Tax-type", "Typed taxonomy", "A typed taxonomy", "");
    Taxonomy taxonomyMarker = taxonomyDao.createTaxonomy("Tax-marker", "Marker taxonomy", "An unused taxonomy", "");
    TaxonomyLevelType type = taxonomyLevelTypeDao.createTaxonomyLevelType("Type-reload", "A first reloaded type", "Typed", "TYP-1", taxonomy);
    dbInstance.commitAndCloseSession();
    // check the taxonomy with types
    List<TaxonomyLevelType> taxonomyTypes = taxonomyLevelTypeDao.loadTaxonomyLevelTypeByTaxonomy(taxonomy);
    Assert.assertNotNull(taxonomyTypes);
    Assert.assertEquals(1, taxonomyTypes.size());
    Assert.assertEquals(type, taxonomyTypes.get(0));
    // check the marker without
    List<TaxonomyLevelType> taxonomyWithoutTypes = taxonomyLevelTypeDao.loadTaxonomyLevelTypeByTaxonomy(taxonomyMarker);
    Assert.assertNotNull(taxonomyWithoutTypes);
    Assert.assertEquals(0, taxonomyWithoutTypes.size());
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) TaxonomyLevelType(org.olat.modules.taxonomy.TaxonomyLevelType) Test(org.junit.Test)

Example 64 with Taxonomy

use of org.olat.modules.taxonomy.Taxonomy in project openolat by klemens.

the class QItemQueriesDAOTest method shouldGetItemsIsTeacher.

@Test
public void shouldGetItemsIsTeacher() {
    Taxonomy taxonomy = taxonomyDao.createTaxonomy("QPool", "QPool", "", null);
    TaxonomyLevel taxonomyLevel = taxonomyLevelDao.createTaxonomyLevel("QPool", "QPool", "QPool", null, null, null, null, taxonomy);
    TaxonomyLevel taxonomySubLevel = taxonomyLevelDao.createTaxonomyLevel("QPool", "QPool", "QPool", null, null, taxonomyLevel, null, taxonomy);
    Identity ownerAndTeacher = createRandomIdentity();
    taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.teach, taxonomyLevel, ownerAndTeacher, null);
    Identity teacher = createRandomIdentity();
    taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.teach, taxonomyLevel, teacher, null);
    Identity noTeacher = createRandomIdentity();
    QuestionItemImpl item11 = createRandomItem(ownerAndTeacher);
    item11.setTaxonomyLevel(taxonomyLevel);
    QuestionItemImpl item12 = createRandomItem(ownerAndTeacher);
    item12.setTaxonomyLevel(taxonomySubLevel);
    dbInstance.commitAndCloseSession();
    SearchQuestionItemParams params = new SearchQuestionItemParams(ownerAndTeacher, null);
    List<QuestionItemView> loadedItems = qItemQueriesDao.getItems(params, null, 0, -1);
    assertThat(filterByKey(loadedItems, item11).isTeacher()).isTrue();
    assertThat(filterByKey(loadedItems, item12).isTeacher()).isTrue();
    params = new SearchQuestionItemParams(ownerAndTeacher, null);
    loadedItems = qItemQueriesDao.getItems(params, null, 0, -1);
    assertThat(filterByKey(loadedItems, item11).isTeacher()).isTrue();
    assertThat(filterByKey(loadedItems, item12).isTeacher()).isTrue();
    params = new SearchQuestionItemParams(noTeacher, null);
    loadedItems = qItemQueriesDao.getItems(params, null, 0, -1);
    assertThat(filterByKey(loadedItems, item11).isTeacher()).isFalse();
    assertThat(filterByKey(loadedItems, item12).isTeacher()).isFalse();
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) QuestionItemImpl(org.olat.modules.qpool.model.QuestionItemImpl) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) Identity(org.olat.core.id.Identity) SearchQuestionItemParams(org.olat.modules.qpool.model.SearchQuestionItemParams) QuestionItemView(org.olat.modules.qpool.QuestionItemView) Test(org.junit.Test)

Example 65 with Taxonomy

use of org.olat.modules.taxonomy.Taxonomy 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

Taxonomy (org.olat.modules.taxonomy.Taxonomy)194 Test (org.junit.Test)132 TaxonomyLevel (org.olat.modules.taxonomy.TaxonomyLevel)122 Identity (org.olat.core.id.Identity)56 URI (java.net.URI)36 HttpResponse (org.apache.http.HttpResponse)36 TaxonomyCompetence (org.olat.modules.taxonomy.TaxonomyCompetence)36 TaxonomyLevelType (org.olat.modules.taxonomy.TaxonomyLevelType)34 Date (java.util.Date)22 HttpGet (org.apache.http.client.methods.HttpGet)16 ArrayList (java.util.ArrayList)14 TaxonomyService (org.olat.modules.taxonomy.TaxonomyService)14 TaxonomyRefImpl (org.olat.modules.taxonomy.model.TaxonomyRefImpl)14 HttpPut (org.apache.http.client.methods.HttpPut)12 HashMap (java.util.HashMap)10 List (java.util.List)10 VFSContainer (org.olat.core.util.vfs.VFSContainer)10 QuestionItemImpl (org.olat.modules.qpool.model.QuestionItemImpl)10 TaxonomyLevelTypeToType (org.olat.modules.taxonomy.TaxonomyLevelTypeToType)10 TaxonomyLevelRefImpl (org.olat.modules.taxonomy.model.TaxonomyLevelRefImpl)10