Search in sources :

Example 61 with SearchQuestionItemParams

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

the class QItemQueriesDAOTest method shouldGetItemsFilteredByExcludeRater.

@Test
public void shouldGetItemsFilteredByExcludeRater() {
    QuestionItem item11 = createRandomItem(createRandomIdentity());
    QuestionItem item12 = createRandomItem(createRandomIdentity());
    QuestionItem item21 = createRandomItem(createRandomIdentity());
    QuestionItem item22 = createRandomItem(createRandomIdentity());
    QuestionItem item23 = createRandomItem(createRandomIdentity());
    Identity rater1 = createRandomIdentity();
    commentAndRatingService.createRating(createRandomIdentity(), item21, null, 2);
    commentAndRatingService.createRating(rater1, item21, null, 2);
    commentAndRatingService.createRating(rater1, item22, null, 2);
    commentAndRatingService.createRating(rater1, item23, null, 2);
    dbInstance.commitAndCloseSession();
    SearchQuestionItemParams params = new SearchQuestionItemParams(createRandomIdentity(), null);
    params.setExcludeRated(rater1);
    ;
    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 : Identity(org.olat.core.id.Identity) SearchQuestionItemParams(org.olat.modules.qpool.model.SearchQuestionItemParams) QuestionItemView(org.olat.modules.qpool.QuestionItemView) QuestionItem(org.olat.modules.qpool.QuestionItem) Test(org.junit.Test)

Example 62 with SearchQuestionItemParams

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

the class QItemQueriesDAOTest method shouldGetItemsIsRater.

@Test
public void shouldGetItemsIsRater() {
    Identity owner1 = createRandomIdentity();
    QuestionItem item11 = createRandomItem(owner1);
    QuestionItem item12 = createRandomItem(owner1);
    commentAndRatingService.createRating(owner1, item11, null, 2);
    dbInstance.commitAndCloseSession();
    SearchQuestionItemParams params = new SearchQuestionItemParams(owner1, null);
    List<QuestionItemView> loadedItems = qItemQueriesDao.getItems(params, null, 0, -1);
    assertThat(filterByKey(loadedItems, item11).isRater()).isTrue();
    assertThat(filterByKey(loadedItems, item12).isRater()).isFalse();
}
Also used : Identity(org.olat.core.id.Identity) SearchQuestionItemParams(org.olat.modules.qpool.model.SearchQuestionItemParams) QuestionItemView(org.olat.modules.qpool.QuestionItemView) QuestionItem(org.olat.modules.qpool.QuestionItem) Test(org.junit.Test)

Example 63 with SearchQuestionItemParams

use of org.olat.modules.qpool.model.SearchQuestionItemParams 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 64 with SearchQuestionItemParams

use of org.olat.modules.qpool.model.SearchQuestionItemParams 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 65 with SearchQuestionItemParams

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

the class QItemQueriesDAOTest method shouldCountAllItemsWithFilter.

@Test
public void shouldCountAllItemsWithFilter() {
    Identity owner1 = createRandomIdentity();
    questionDao.createAndPersist(owner1, "QPool 1", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, qItemType);
    questionDao.createAndPersist(owner1, "QPool 2", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, qItemType);
    createRandomItem(owner1);
    dbInstance.commitAndCloseSession();
    SearchQuestionItemParams params = new SearchQuestionItemParams(createRandomIdentity(), null);
    params.setFormat(QTIConstants.QTI_12_FORMAT);
    int countItems = qItemQueriesDao.countItems(params);
    assertThat(countItems).isEqualTo(2);
}
Also used : Identity(org.olat.core.id.Identity) SearchQuestionItemParams(org.olat.modules.qpool.model.SearchQuestionItemParams) Test(org.junit.Test)

Aggregations

SearchQuestionItemParams (org.olat.modules.qpool.model.SearchQuestionItemParams)72 QuestionItemView (org.olat.modules.qpool.QuestionItemView)62 Test (org.junit.Test)60 QuestionItem (org.olat.modules.qpool.QuestionItem)54 Identity (org.olat.core.id.Identity)50 Pool (org.olat.modules.qpool.Pool)12 QuestionItemImpl (org.olat.modules.qpool.model.QuestionItemImpl)10 QItemType (org.olat.modules.qpool.model.QItemType)8 Taxonomy (org.olat.modules.taxonomy.Taxonomy)8 TaxonomyLevel (org.olat.modules.taxonomy.TaxonomyLevel)8 ArrayList (java.util.ArrayList)6 SortKey (org.olat.core.commons.persistence.SortKey)6 QuestionItem2Pool (org.olat.modules.qpool.QuestionItem2Pool)6 QuestionItemShort (org.olat.modules.qpool.QuestionItemShort)4 BusinessGroup (org.olat.group.BusinessGroup)2 QuestionItemCollection (org.olat.modules.qpool.QuestionItemCollection)2 QuestionStatus (org.olat.modules.qpool.QuestionStatus)2 OLATResource (org.olat.resource.OLATResource)2