Search in sources :

Example 86 with QuestionItemImpl

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

the class TaxonomyLevelItemsSource method postImport.

@Override
public int postImport(List<QuestionItem> items, boolean editable) {
    if (items == null || items.isEmpty())
        return 0;
    for (QuestionItemShort item : items) {
        if (item instanceof QuestionItemImpl) {
            QuestionItemImpl itemImpl = (QuestionItemImpl) item;
            itemImpl.setTaxonomyLevel(taxonomyLevel);
        }
    }
    qpoolService.index(items);
    return items.size();
}
Also used : QuestionItemImpl(org.olat.modules.qpool.model.QuestionItemImpl) QuestionItemShort(org.olat.modules.qpool.QuestionItemShort)

Example 87 with QuestionItemImpl

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

the class QItemQueriesDAOTest method shouldGetItemsIsManager.

@Test
public void shouldGetItemsIsManager() {
    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 ownerAndManager = createRandomIdentity();
    taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.manage, taxonomyLevel, ownerAndManager, null);
    Identity manager = createRandomIdentity();
    taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.manage, taxonomyLevel, manager, null);
    Identity noManager = createRandomIdentity();
    QuestionItemImpl item11 = createRandomItem(ownerAndManager);
    item11.setTaxonomyLevel(taxonomyLevel);
    QuestionItemImpl item12 = createRandomItem(ownerAndManager);
    item12.setTaxonomyLevel(taxonomySubLevel);
    dbInstance.commitAndCloseSession();
    SearchQuestionItemParams params = new SearchQuestionItemParams(ownerAndManager, null);
    List<QuestionItemView> loadedItems = qItemQueriesDao.getItems(params, null, 0, -1);
    assertThat(filterByKey(loadedItems, item11).isManager()).isTrue();
    assertThat(filterByKey(loadedItems, item12).isManager()).isTrue();
    params = new SearchQuestionItemParams(ownerAndManager, null);
    loadedItems = qItemQueriesDao.getItems(params, null, 0, -1);
    assertThat(filterByKey(loadedItems, item11).isManager()).isTrue();
    assertThat(filterByKey(loadedItems, item12).isManager()).isTrue();
    params = new SearchQuestionItemParams(noManager, null);
    loadedItems = qItemQueriesDao.getItems(params, null, 0, -1);
    assertThat(filterByKey(loadedItems, item11).isManager()).isFalse();
    assertThat(filterByKey(loadedItems, item12).isManager()).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 88 with QuestionItemImpl

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

the class QItemQueriesDAOTest method shouldGetItemsFilteredByLikeTaxonomyLevel.

@Test
public void shouldGetItemsFilteredByLikeTaxonomyLevel() {
    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);
    TaxonomyLevel otherTaxonomyLevel = taxonomyLevelDao.createTaxonomyLevel("QPool", "QPool", "QPool", null, null, null, null, taxonomy);
    QuestionItemImpl item11 = createRandomItem(createRandomIdentity());
    item11.setTaxonomyLevel(taxonomyLevel);
    QuestionItemImpl item12 = createRandomItem(createRandomIdentity());
    item12.setTaxonomyLevel(taxonomySubLevel);
    QuestionItemImpl item21 = createRandomItem(createRandomIdentity());
    item21.setTaxonomyLevel(otherTaxonomyLevel);
    QuestionItem item22 = createRandomItem(createRandomIdentity());
    QuestionItem item23 = createRandomItem(createRandomIdentity());
    dbInstance.commitAndCloseSession();
    SearchQuestionItemParams params = new SearchQuestionItemParams(createRandomIdentity(), null);
    params.setLikeTaxonomyLevel(taxonomyLevel);
    List<QuestionItemView> loadedItems = qItemQueriesDao.getItems(params, null, 0, -1);
    assertThat(loadedItems).hasSize(2);
    assertThat(keysOf(loadedItems)).containsOnlyElementsOf(keysOf(item11, item12)).doesNotContainAnyElementsOf(keysOf(item21, item22, item23));
    int countItems = qItemQueriesDao.countItems(params);
    assertThat(countItems).isEqualTo(2);
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) QuestionItemImpl(org.olat.modules.qpool.model.QuestionItemImpl) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) SearchQuestionItemParams(org.olat.modules.qpool.model.SearchQuestionItemParams) QuestionItemView(org.olat.modules.qpool.QuestionItemView) QuestionItem(org.olat.modules.qpool.QuestionItem) Test(org.junit.Test)

Example 89 with QuestionItemImpl

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

the class QItemQueriesDAOTest method shouldGetItemsFilteredByWithoutTaxonomyLevel.

@Test
public void shouldGetItemsFilteredByWithoutTaxonomyLevel() {
    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);
    TaxonomyLevel otherTaxonomyLevel = taxonomyLevelDao.createTaxonomyLevel("QPool", "QPool", "QPool", null, null, null, null, taxonomy);
    QuestionItemImpl item11 = createRandomItem(createRandomIdentity());
    item11.setTaxonomyLevel(taxonomyLevel);
    QuestionItemImpl item12 = createRandomItem(createRandomIdentity());
    item12.setTaxonomyLevel(taxonomySubLevel);
    QuestionItemImpl item21 = createRandomItem(createRandomIdentity());
    item21.setTaxonomyLevel(otherTaxonomyLevel);
    QuestionItem item22 = createRandomItem(createRandomIdentity());
    QuestionItem item23 = createRandomItem(createRandomIdentity());
    dbInstance.commitAndCloseSession();
    SearchQuestionItemParams params = new SearchQuestionItemParams(createRandomIdentity(), null);
    params.setWithoutTaxonomyLevelOnly(true);
    List<QuestionItemView> loadedItems = qItemQueriesDao.getItems(params, null, 0, -1);
    assertThat(loadedItems).hasSize(2);
    assertThat(keysOf(loadedItems)).containsOnlyElementsOf(keysOf(item22, item23)).doesNotContainAnyElementsOf(keysOf(item11, item12, item21));
    int countItems = qItemQueriesDao.countItems(params);
    assertThat(countItems).isEqualTo(2);
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) QuestionItemImpl(org.olat.modules.qpool.model.QuestionItemImpl) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) SearchQuestionItemParams(org.olat.modules.qpool.model.SearchQuestionItemParams) QuestionItemView(org.olat.modules.qpool.QuestionItemView) QuestionItem(org.olat.modules.qpool.QuestionItem) Test(org.junit.Test)

Example 90 with QuestionItemImpl

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

the class QuestionDAOTest method resetAllStatesToDraft.

@Test
public void resetAllStatesToDraft() {
    QItemType mcType = qItemTypeDao.loadByType(QuestionType.MC.name());
    QuestionItemImpl item1 = questionDao.createAndPersist(null, "RES DRAFT 1", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, mcType);
    item1.setQuestionStatus(QuestionStatus.endOfLife);
    questionDao.loadForUpdate(item1);
    QuestionItemImpl item2 = questionDao.createAndPersist(null, "RES DRAFT 2", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, mcType);
    item2.setQuestionStatus(QuestionStatus.review);
    questionDao.loadForUpdate(item2);
    QuestionItemImpl item3 = questionDao.createAndPersist(null, "RES DRAFT 3", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, mcType);
    item3.setQuestionStatus(QuestionStatus.revised);
    questionDao.loadForUpdate(item3);
    questionDao.createAndPersist(null, "RES DRAFT 4", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, mcType);
    dbInstance.commitAndCloseSession();
    questionDao.resetAllStatesToDraft();
    dbInstance.commitAndCloseSession();
    List<QuestionItemFull> allItems = questionDao.getAllItems(0, -1);
    for (QuestionItem item : allItems) {
        Assert.assertEquals(QuestionStatus.draft, item.getQuestionStatus());
    }
}
Also used : QuestionItemFull(org.olat.modules.qpool.QuestionItemFull) QuestionItemImpl(org.olat.modules.qpool.model.QuestionItemImpl) QuestionItem(org.olat.modules.qpool.QuestionItem) QItemType(org.olat.modules.qpool.model.QItemType) Test(org.junit.Test)

Aggregations

QuestionItemImpl (org.olat.modules.qpool.model.QuestionItemImpl)108 QuestionItem (org.olat.modules.qpool.QuestionItem)32 Test (org.junit.Test)20 QuestionItemAuditLogBuilder (org.olat.modules.qpool.QuestionItemAuditLogBuilder)16 TaxonomyLevel (org.olat.modules.taxonomy.TaxonomyLevel)16 Identity (org.olat.core.id.Identity)14 VFSContainer (org.olat.core.util.vfs.VFSContainer)14 QuestionItemView (org.olat.modules.qpool.QuestionItemView)14 File (java.io.File)12 VFSItem (org.olat.core.util.vfs.VFSItem)12 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)12 QItemEdited (org.olat.modules.qpool.ui.events.QItemEdited)12 ArrayList (java.util.ArrayList)10 QItemType (org.olat.modules.qpool.model.QItemType)10 SearchQuestionItemParams (org.olat.modules.qpool.model.SearchQuestionItemParams)10 ManifestBuilder (org.olat.ims.qti21.model.xml.ManifestBuilder)8 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)8 ResolvedAssessmentItem (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem)8 QuestionItemShort (org.olat.modules.qpool.QuestionItemShort)7 Taxonomy (org.olat.modules.taxonomy.Taxonomy)7