use of org.olat.modules.qpool.QuestionItemCollection in project openolat by klemens.
the class QItemQueriesDAOTest method getItemsOfCollection_orderBy.
@Test
public void getItemsOfCollection_orderBy() {
// create a collection with 2 items
Identity id = JunitTestHelper.createAndPersistIdentityAsUser("Coll-Onwer-3-" + UUID.randomUUID().toString());
QuestionItemCollection coll = collectionDao.createCollection("NGC collection 3", id);
QuestionItem item = questionDao.createAndPersist(null, "NGC 92", QTIConstants.QTI_12_FORMAT, Locale.GERMAN.getLanguage(), null, null, null, qItemType);
collectionDao.addItemToCollection(item, singletonList(coll));
// check if it's alright
dbInstance.commit();
// test order by
for (QuestionItemView.OrderBy order : QuestionItemView.OrderBy.values()) {
SortKey sortAsc = new SortKey(order.name(), true);
List<QuestionItemView> ascOrderedItems = qItemQueriesDao.getItemsOfCollection(id, coll, null, null, 0, -1, sortAsc);
Assert.assertNotNull(ascOrderedItems);
SortKey sortDesc = new SortKey(order.name(), false);
List<QuestionItemView> descOrderedItems = qItemQueriesDao.getItemsOfCollection(id, coll, null, null, 0, -1, sortDesc);
Assert.assertNotNull(descOrderedItems);
}
}
use of org.olat.modules.qpool.QuestionItemCollection in project openolat by klemens.
the class CollectionDAOTest method getItemKeysOfCollection.
@Test
public void getItemKeysOfCollection() {
// create a collection with 2 items
QItemType fibType = qItemTypeDao.loadByType(QuestionType.FIB.name());
Identity id = JunitTestHelper.createAndPersistIdentityAsUser("Coll-Onwer-4-" + UUID.randomUUID().toString());
QuestionItemCollection coll = collectionDao.createCollection("NGC collection 4", id);
QuestionItem item1 = questionDao.createAndPersist(null, "NGC 99", QTIConstants.QTI_12_FORMAT, Locale.GERMAN.getLanguage(), null, null, null, fibType);
QuestionItem item2 = questionDao.createAndPersist(null, "NGC 101", QTIConstants.QTI_12_FORMAT, Locale.GERMAN.getLanguage(), null, null, null, fibType);
collectionDao.addItemToCollection(item1, singletonList(coll));
collectionDao.addItemToCollection(item2, singletonList(coll));
// check if it's alright
dbInstance.commit();
// load the items of the collection
List<Long> items = collectionDao.getItemKeysOfCollection(coll);
Assert.assertNotNull(items);
Assert.assertEquals(2, items.size());
Assert.assertTrue(items.contains(item1.getKey()));
Assert.assertTrue(items.contains(item2.getKey()));
}
use of org.olat.modules.qpool.QuestionItemCollection in project openolat by klemens.
the class CollectionDAOTest method getCollections_myOhMy.
@Test
public void getCollections_myOhMy() {
Identity id = JunitTestHelper.createAndPersistIdentityAsUser("Coll-Onwer-5-" + UUID.randomUUID().toString());
QuestionItemCollection coll1 = collectionDao.createCollection("NGC collection part. 6", id);
QuestionItemCollection coll2 = collectionDao.createCollection("NGC collection part. 7", id);
// check if it's alright
dbInstance.commit();
// load the items of the collection
List<QuestionItemCollection> items = collectionDao.getCollections(id);
Assert.assertNotNull(items);
Assert.assertEquals(2, items.size());
Assert.assertTrue(items.contains(coll1));
Assert.assertTrue(items.contains(coll2));
}
use of org.olat.modules.qpool.QuestionItemCollection in project openolat by klemens.
the class CollectionDAOTest method countItemsOfCollection.
@Test
public void countItemsOfCollection() {
// create 2 collections with 2 items
QItemType fibType = qItemTypeDao.loadByType(QuestionType.FIB.name());
Identity id = JunitTestHelper.createAndPersistIdentityAsUser("Coll-Onwer-4-" + UUID.randomUUID().toString());
QuestionItemCollection coll = collectionDao.createCollection("NGC collection 8", id);
QuestionItem item1 = questionDao.createAndPersist(null, "NGC 103", QTIConstants.QTI_12_FORMAT, Locale.GERMAN.getLanguage(), null, null, null, fibType);
QuestionItem item2 = questionDao.createAndPersist(null, "NGC 104", QTI21Constants.QTI_21_FORMAT, Locale.GERMAN.getLanguage(), null, null, null, fibType);
collectionDao.addItemToCollection(item1, singletonList(coll));
collectionDao.addItemToCollection(item2, singletonList(coll));
dbInstance.commit();
// check if it's alright
int numOfItems = collectionDao.countItemsOfCollection(coll, null);
Assert.assertEquals(2, numOfItems);
int numOfItems_21 = collectionDao.countItemsOfCollection(coll, QTI21Constants.QTI_21_FORMAT);
Assert.assertEquals(1, numOfItems_21);
}
use of org.olat.modules.qpool.QuestionItemCollection in project openolat by klemens.
the class CollectionDAOTest method loadCollectionById.
@Test
public void loadCollectionById() {
// create an owner and its collection
Identity id = JunitTestHelper.createAndPersistIdentityAsUser("Coll-Onwer-" + UUID.randomUUID());
QuestionItemCollection coll = collectionDao.createCollection("NGC collection", id);
dbInstance.commitAndCloseSession();
// load the collection
QuestionItemCollection loadedColl = collectionDao.loadCollectionById(coll.getKey());
Assert.assertNotNull(loadedColl);
Assert.assertNotNull(loadedColl.getKey());
Assert.assertNotNull(loadedColl.getCreationDate());
Assert.assertNotNull(loadedColl.getLastModified());
Assert.assertEquals(coll, loadedColl);
Assert.assertEquals("NGC collection", loadedColl.getName());
Assert.assertEquals(id, loadedColl.getOwner());
}
Aggregations