use of org.olat.modules.qpool.model.QItemType in project OpenOLAT by OpenOLAT.
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.model.QItemType in project OpenOLAT by OpenOLAT.
the class MetadataConverterHelperTest method serializeQuestionItem.
@Test
public void serializeQuestionItem() {
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);
}
use of org.olat.modules.qpool.model.QItemType in project OpenOLAT by OpenOLAT.
the class QItemTypeDAOTest method testCreate.
@Test
public void testCreate() {
String typeStr = "interessantType-" + UUID.randomUUID().toString();
QItemType type = qpoolItemTypeDao.create(typeStr, true);
dbInstance.commit();
// check
Assert.assertNotNull(type);
Assert.assertNotNull(type.getKey());
Assert.assertNotNull(type.getCreationDate());
Assert.assertNotNull(type.getType());
// lower case always
Assert.assertEquals(typeStr.toLowerCase(), type.getType());
Assert.assertTrue(type.isDeletable());
}
use of org.olat.modules.qpool.model.QItemType in project OpenOLAT by OpenOLAT.
the class QItemTypeDAOTest method testCreateAndGet.
@Test
public void testCreateAndGet() {
String typeStr = "veryInteressantType-" + UUID.randomUUID().toString();
QItemType type = qpoolItemTypeDao.create(typeStr, true);
dbInstance.commit();
// load it
QItemType reloadedType = qpoolItemTypeDao.loadById(type.getKey());
// check the values
Assert.assertNotNull(reloadedType);
Assert.assertEquals(type.getKey(), reloadedType.getKey());
Assert.assertNotNull(reloadedType.getCreationDate());
Assert.assertEquals(typeStr.toLowerCase(), reloadedType.getType());
Assert.assertTrue(reloadedType.isDeletable());
}
use of org.olat.modules.qpool.model.QItemType in project OpenOLAT by OpenOLAT.
the class QItemTypeDAOTest method testGetItemTypes.
@Test
public void testGetItemTypes() {
String typeStr = "cute-" + UUID.randomUUID().toString();
QItemType type = qpoolItemTypeDao.create(typeStr, true);
dbInstance.commit();
// load it
List<QItemType> allTypes = qpoolItemTypeDao.getItemTypes();
// check the values
Assert.assertNotNull(allTypes);
Assert.assertTrue(allTypes.contains(type));
}
Aggregations