use of org.olat.modules.qpool.model.QItemType in project OpenOLAT by OpenOLAT.
the class CollectionDAOTest method addItemToCollectionById.
@Test
public void addItemToCollectionById() {
QItemType fibType = qItemTypeDao.loadByType(QuestionType.FIB.name());
Identity id = JunitTestHelper.createAndPersistIdentityAsUser("Coll-Onwer-2-" + UUID.randomUUID().toString());
QuestionItemCollection coll = collectionDao.createCollection("NGC collection 2", id);
QuestionItem item = questionDao.createAndPersist(null, "NGC 89", QTIConstants.QTI_12_FORMAT, Locale.GERMAN.getLanguage(), null, null, null, fibType);
dbInstance.commitAndCloseSession();
// add the item to the collection
collectionDao.addItemToCollection(item, singletonList(coll));
// check if it's alright
dbInstance.commit();
}
use of org.olat.modules.qpool.model.QItemType in project OpenOLAT by OpenOLAT.
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.model.QItemType in project OpenOLAT by OpenOLAT.
the class QItemTypeDAOTest method testDelete_deletable.
@Test
public void testDelete_deletable() {
String typeStr = "cute-" + UUID.randomUUID().toString();
QItemType type = qpoolItemTypeDao.create(typeStr, true);
dbInstance.commitAndCloseSession();
// delete it
boolean deleted = qpoolItemTypeDao.delete(type);
dbInstance.commitAndCloseSession();
Assert.assertTrue(deleted);
// check that the type is really, really deleted
QItemType reloadedType = qpoolItemTypeDao.loadById(type.getKey());
Assert.assertNull(reloadedType);
List<QItemType> allTypes = qpoolItemTypeDao.getItemTypes();
Assert.assertFalse(allTypes.contains(type));
}
use of org.olat.modules.qpool.model.QItemType in project OpenOLAT by OpenOLAT.
the class QItemTypeDAOTest method testDelete_notDeletable.
@Test
public void testDelete_notDeletable() {
String typeStr = "titanium-" + UUID.randomUUID().toString();
QItemType type = qpoolItemTypeDao.create(typeStr, false);
dbInstance.commitAndCloseSession();
// delete it
boolean deleted = qpoolItemTypeDao.delete(type);
dbInstance.commitAndCloseSession();
Assert.assertFalse(deleted);
// check that the type is really, really deleted
QItemType reloadedType = qpoolItemTypeDao.loadById(type.getKey());
Assert.assertNotNull(reloadedType);
List<QItemType> allTypes = qpoolItemTypeDao.getItemTypes();
Assert.assertTrue(allTypes.contains(type));
}
use of org.olat.modules.qpool.model.QItemType in project OpenOLAT by OpenOLAT.
the class QuestionDAOTest method createQuestion.
@Test
public void createQuestion() {
QItemType fibType = qItemTypeDao.loadByType(QuestionType.FIB.name());
QuestionItem item = questionDao.createAndPersist(null, "Stars", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, fibType);
Assert.assertNotNull(item);
Assert.assertNotNull(item.getKey());
Assert.assertNotNull(item.getIdentifier());
Assert.assertNotNull(item.getCreationDate());
Assert.assertNotNull(item.getLastModified());
Assert.assertNotNull(item.getType());
Assert.assertNotNull(item.getQuestionStatus());
Assert.assertNotNull(item.getQuestionStatusLastModified());
Assert.assertEquals("Stars", item.getTitle());
dbInstance.commitAndCloseSession();
}
Aggregations