Search in sources :

Example 71 with QItemType

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);
}
Also used : QuestionItemCollection(org.olat.modules.qpool.QuestionItemCollection) Identity(org.olat.core.id.Identity) QuestionItem(org.olat.modules.qpool.QuestionItem) QItemType(org.olat.modules.qpool.model.QItemType) Test(org.junit.Test)

Example 72 with QItemType

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);
}
Also used : QuestionItem(org.olat.modules.qpool.QuestionItem) QItemType(org.olat.modules.qpool.model.QItemType) Test(org.junit.Test)

Example 73 with QItemType

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());
}
Also used : QItemType(org.olat.modules.qpool.model.QItemType) Test(org.junit.Test)

Example 74 with QItemType

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());
}
Also used : QItemType(org.olat.modules.qpool.model.QItemType) Test(org.junit.Test)

Example 75 with QItemType

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));
}
Also used : QItemType(org.olat.modules.qpool.model.QItemType) Test(org.junit.Test)

Aggregations

QItemType (org.olat.modules.qpool.model.QItemType)118 Test (org.junit.Test)94 QuestionItem (org.olat.modules.qpool.QuestionItem)82 Identity (org.olat.core.id.Identity)58 BusinessGroup (org.olat.group.BusinessGroup)22 QuestionItemView (org.olat.modules.qpool.QuestionItemView)18 Pool (org.olat.modules.qpool.Pool)12 QuestionItem2Pool (org.olat.modules.qpool.QuestionItem2Pool)12 QuestionItemCollection (org.olat.modules.qpool.QuestionItemCollection)12 QuestionItemImpl (org.olat.modules.qpool.model.QuestionItemImpl)10 URI (java.net.URI)8 ArrayList (java.util.ArrayList)8 HttpResponse (org.apache.http.HttpResponse)8 QuestionItemShort (org.olat.modules.qpool.QuestionItemShort)8 QEducationalContext (org.olat.modules.qpool.model.QEducationalContext)8 SearchQuestionItemParams (org.olat.modules.qpool.model.SearchQuestionItemParams)8 QuestionItemFull (org.olat.modules.qpool.QuestionItemFull)6 QuestionType (org.olat.modules.qpool.QuestionType)6 TaxonomyLevel (org.olat.modules.taxonomy.TaxonomyLevel)6 InputStream (java.io.InputStream)4