Search in sources :

Example 11 with QItemType

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();
}
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 12 with QItemType

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()));
}
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 13 with QItemType

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

Example 14 with QItemType

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

Example 15 with QItemType

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