use of org.olat.modules.qpool.model.SearchQuestionItemParams in project openolat by klemens.
the class SharedItemsSource method getItems.
@Override
public List<QuestionItemView> getItems(Collection<Long> keys) {
SearchQuestionItemParams params = new SearchQuestionItemParams(identity, roles);
params.setItemKeys(keys);
if (StringHelper.containsNonWhitespace(restrictToFormat)) {
params.setFormat(restrictToFormat);
}
ResultInfos<QuestionItemView> items = qpoolService.getSharedItemByResource(group.getResource(), params, 0, -1);
return items.getObjects();
}
use of org.olat.modules.qpool.model.SearchQuestionItemParams in project OpenOLAT by OpenOLAT.
the class DefaultItemsSource method getItems.
@Override
public ResultInfos<QuestionItemView> getItems(String query, List<String> condQueries, int firstResult, int maxResults, SortKey... orderBy) {
SearchQuestionItemParams params = defaultParams.clone();
params.setSearchString(query);
params.setCondQueries(condQueries);
return doSearch(params, firstResult, maxResults, orderBy);
}
use of org.olat.modules.qpool.model.SearchQuestionItemParams in project OpenOLAT by OpenOLAT.
the class PoolDAOTest method removeItemFromPool.
@Test
public void removeItemFromPool() {
// create a pool
String poolName = "NGC-" + UUID.randomUUID().toString();
Pool pool = poolDao.createPool(null, poolName, true);
Assert.assertNotNull(pool);
QItemType mcType = qItemTypeDao.loadByType(QuestionType.MC.name());
QuestionItem item = questionItemDao.createAndPersist(null, "Galaxy", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, mcType);
Assert.assertNotNull(item);
dbInstance.commitAndCloseSession();
// get pools
poolDao.addItemToPool(item, Collections.singletonList(pool), false);
dbInstance.commit();
SearchQuestionItemParams params = new SearchQuestionItemParams(null, null);
params.setPoolKey(pool.getKey());
// check
int numOfItems = poolDao.countItemsInPool(params);
Assert.assertEquals(1, numOfItems);
// remove
poolDao.removeFromPool(Collections.<QuestionItemShort>singletonList(item), pool);
dbInstance.commit();
// check empty pool
int numOfStayingItems = poolDao.countItemsInPool(params);
Assert.assertEquals(0, numOfStayingItems);
// but item exists
QuestionItem reloadedItem = questionItemDao.loadById(item.getKey());
Assert.assertNotNull(reloadedItem);
}
use of org.olat.modules.qpool.model.SearchQuestionItemParams in project OpenOLAT by OpenOLAT.
the class QItemQueriesDAOTest method shouldGetItemsIsEditableInAPool.
@Test
public void shouldGetItemsIsEditableInAPool() {
Identity owner1 = createRandomIdentity();
QuestionItem item11 = createRandomItem(owner1);
QuestionItem item12 = createRandomItem(owner1);
QuestionItem item13 = createRandomItem(owner1);
Pool pool = poolDao.createPool(null, "Pool", true);
poolDao.addItemToPool(item11, Collections.singletonList(pool), true);
poolDao.addItemToPool(item12, Collections.singletonList(pool), false);
dbInstance.commitAndCloseSession();
SearchQuestionItemParams params = new SearchQuestionItemParams(createRandomIdentity(), null);
List<QuestionItemView> loadedItems = qItemQueriesDao.getItems(params, null, 0, -1);
assertThat(filterByKey(loadedItems, item11).isEditableInPool()).isTrue();
assertThat(filterByKey(loadedItems, item12).isEditableInPool()).isFalse();
assertThat(filterByKey(loadedItems, item13).isEditableInPool()).isFalse();
}
use of org.olat.modules.qpool.model.SearchQuestionItemParams in project OpenOLAT by OpenOLAT.
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();
}
Aggregations