use of org.olat.modules.qpool.model.SearchQuestionItemParams in project OpenOLAT by OpenOLAT.
the class QItemQueriesDAOTest method shouldGetItemsFilteredByOnlyAuthor.
@Test
public void shouldGetItemsFilteredByOnlyAuthor() {
Identity owner1 = createRandomIdentity();
QuestionItem item11 = createRandomItem(owner1);
QuestionItem item12 = createRandomItem(owner1);
QuestionItem item21 = createRandomItem(createRandomIdentity());
QuestionItem item22 = createRandomItem(createRandomIdentity());
QuestionItem item23 = createRandomItem(createRandomIdentity());
dbInstance.commitAndCloseSession();
SearchQuestionItemParams params = new SearchQuestionItemParams(createRandomIdentity(), null);
params.setOnlyAuthor(owner1);
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);
}
use of org.olat.modules.qpool.model.SearchQuestionItemParams in project OpenOLAT by OpenOLAT.
the class QItemQueriesDAOTest method getItemsOfPool.
@Test
public void getItemsOfPool() {
Identity id = JunitTestHelper.createAndPersistIdentityAsUser("Poolman-" + UUID.randomUUID().toString());
// create a pool
String poolTitle = "NGC-" + UUID.randomUUID().toString();
Pool pool = poolDao.createPool(null, poolTitle, true);
QuestionItem item = questionItemDao.createAndPersist(id, "Galaxy", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, qItemType);
poolDao.addItemToPool(item, Collections.singletonList(pool), false);
dbInstance.commitAndCloseSession();
SearchQuestionItemParams params = new SearchQuestionItemParams(id, null);
params.setPoolKey(pool.getKey());
// retrieve
List<QuestionItemView> items = qItemQueriesDao.getItemsOfPool(params, null, 0, -1);
Assert.assertNotNull(items);
Assert.assertEquals(1, items.size());
Assert.assertTrue(items.get(0).getKey().equals(item.getKey()));
// count
int numOfItems = poolDao.countItemsInPool(params);
Assert.assertEquals(1, numOfItems);
}
use of org.olat.modules.qpool.model.SearchQuestionItemParams in project OpenOLAT by OpenOLAT.
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();
}
use of org.olat.modules.qpool.model.SearchQuestionItemParams in project OpenOLAT by OpenOLAT.
the class QItemQueriesDAOTest method shouldGetItemsFilteredByWithoutAuthor.
@Test
public void shouldGetItemsFilteredByWithoutAuthor() {
QuestionItem item11 = createRandomItem(null);
QuestionItem item12 = createRandomItem(createRandomIdentity());
QuestionItem item21 = createRandomItem(null);
QuestionItem item22 = createRandomItem(createRandomIdentity());
QuestionItem item23 = createRandomItem(createRandomIdentity());
dbInstance.commitAndCloseSession();
SearchQuestionItemParams params = new SearchQuestionItemParams(createRandomIdentity(), null);
params.setWithoutAuthorOnly(true);
List<QuestionItemView> loadedItems = qItemQueriesDao.getItems(params, null, 0, -1);
assertThat(loadedItems).hasSize(2);
assertThat(keysOf(loadedItems)).containsOnlyElementsOf(keysOf(item11, item21)).doesNotContainAnyElementsOf(keysOf(item12, item22, item23));
int countItems = qItemQueriesDao.countItems(params);
assertThat(countItems).isEqualTo(2);
}
use of org.olat.modules.qpool.model.SearchQuestionItemParams in project OpenOLAT by OpenOLAT.
the class QItemQueriesDAOTest method shouldGetItemsRating.
@Test
public void shouldGetItemsRating() {
Identity owner1 = createRandomIdentity();
QuestionItem item11 = createRandomItem(owner1);
commentAndRatingService.createRating(createRandomIdentity(), item11, null, 2);
commentAndRatingService.createRating(createRandomIdentity(), item11, null, 3);
commentAndRatingService.createRating(createRandomIdentity(), item11, null, 4);
dbInstance.commitAndCloseSession();
SearchQuestionItemParams params = new SearchQuestionItemParams(createRandomIdentity(), null);
List<QuestionItemView> loadedItems = qItemQueriesDao.getItems(params, null, 0, -1);
assertThat(filterByKey(loadedItems, item11).getRating()).isEqualTo(3);
}
Aggregations