Search in sources :

Example 21 with QItemType

use of org.olat.modules.qpool.model.QItemType in project OpenOLAT by OpenOLAT.

the class QuestionDAOTest method getNumOfQuestions.

@Test
public void getNumOfQuestions() {
    QItemType mcType = qItemTypeDao.loadByType(QuestionType.MC.name());
    QuestionItem item = questionDao.createAndPersist(null, "NGC 1277", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, mcType);
    Assert.assertNotNull(item);
    dbInstance.commitAndCloseSession();
    int numOfQuestions = questionDao.getNumOfQuestions();
    Assert.assertTrue(numOfQuestions >= 1);
    dbInstance.commitAndCloseSession();
}
Also used : QuestionItem(org.olat.modules.qpool.QuestionItem) QItemType(org.olat.modules.qpool.model.QItemType) Test(org.junit.Test)

Example 22 with QItemType

use of org.olat.modules.qpool.model.QItemType in project OpenOLAT by OpenOLAT.

the class QuestionDAOTest method shareItems_avoidDuplicates.

@Test
public void shareItems_avoidDuplicates() {
    // create a group to share 2 items
    QItemType mcType = qItemTypeDao.loadByType(QuestionType.MC.name());
    Identity id = JunitTestHelper.createAndPersistIdentityAsUser("QShare-3-" + UUID.randomUUID());
    BusinessGroup group = businessGroupDao.createAndPersist(id, "gdao", "gdao-desc", -1, -1, false, false, false, false, false);
    QuestionItem item = questionDao.createAndPersist(id, "Share-Item-Dup-1", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, mcType);
    dbInstance.commit();
    // share them
    questionDao.share(item, group.getResource());
    questionDao.share(item, group.getResource());
    questionDao.share(item, group.getResource());
    // retrieve them
    List<QuestionItemView> sharedItems = qItemQueriesDao.getSharedItemByResource(id, group.getResource(), null, null, 0, -1);
    Assert.assertNotNull(sharedItems);
    Assert.assertEquals(1, sharedItems.size());
    Assert.assertEquals(item.getKey(), sharedItems.get(0).getKey());
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) Identity(org.olat.core.id.Identity) QuestionItemView(org.olat.modules.qpool.QuestionItemView) QuestionItem(org.olat.modules.qpool.QuestionItem) QItemType(org.olat.modules.qpool.model.QItemType) Test(org.junit.Test)

Example 23 with QItemType

use of org.olat.modules.qpool.model.QItemType in project OpenOLAT by OpenOLAT.

the class QuestionDAOTest method shareInfos_byItems.

@Test
public void shareInfos_byItems() {
    // create a group to share 2 items
    QItemType mcType = qItemTypeDao.loadByType(QuestionType.MC.name());
    Identity id = JunitTestHelper.createAndPersistIdentityAsUser("Share-item-" + UUID.randomUUID().toString());
    BusinessGroup group1 = businessGroupDao.createAndPersist(id, "gdap", "gdao-desc", -1, -1, false, false, false, false, false);
    BusinessGroup group2 = businessGroupDao.createAndPersist(id, "gdaq", "gdao-desc", -1, -1, false, false, false, false, false);
    QuestionItem item = questionDao.createAndPersist(id, "Share-Item-Dup-1", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, mcType);
    questionDao.share(item, group1.getResource());
    questionDao.share(item, group2.getResource());
    dbInstance.commit();
    // retrieve them
    List<QuestionItem2Resource> shared = questionDao.getSharedResourceInfos(item);
    Assert.assertNotNull(shared);
    Assert.assertEquals(2, shared.size());
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) Identity(org.olat.core.id.Identity) QuestionItem(org.olat.modules.qpool.QuestionItem) QuestionItem2Resource(org.olat.modules.qpool.QuestionItem2Resource) QItemType(org.olat.modules.qpool.model.QItemType) Test(org.junit.Test)

Example 24 with QItemType

use of org.olat.modules.qpool.model.QItemType in project OpenOLAT by OpenOLAT.

the class QuestionDAOTest method createQuestion_withOwner.

@Test
public void createQuestion_withOwner() {
    QItemType fibType = qItemTypeDao.loadByType(QuestionType.FIB.name());
    Identity id = JunitTestHelper.createAndPersistIdentityAsUser("QOwn-1-" + UUID.randomUUID().toString());
    QuestionItem item = questionDao.createAndPersist(id, "My fav. stars", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, fibType);
    Assert.assertNotNull(item);
    Assert.assertNotNull(item.getKey());
    Assert.assertNotNull(item.getCreationDate());
    Assert.assertNotNull(item.getLastModified());
    Assert.assertNotNull(item.getType());
    Assert.assertNotNull(item.getQuestionStatus());
    Assert.assertEquals("My fav. stars", item.getTitle());
    dbInstance.commitAndCloseSession();
}
Also used : Identity(org.olat.core.id.Identity) QuestionItem(org.olat.modules.qpool.QuestionItem) QItemType(org.olat.modules.qpool.model.QItemType) Test(org.junit.Test)

Example 25 with QItemType

use of org.olat.modules.qpool.model.QItemType in project OpenOLAT by OpenOLAT.

the class QuestionDAOTest method shareItems_countSharedItemByResource.

@Test
public void shareItems_countSharedItemByResource() {
    // create a group to share 2 items
    QItemType mcType = qItemTypeDao.loadByType(QuestionType.MC.name());
    QItemType fibType = qItemTypeDao.loadByType(QuestionType.FIB.name());
    BusinessGroup group = businessGroupDao.createAndPersist(null, "gdao", "gdao-desc", -1, -1, false, false, false, false, false);
    QuestionItem item1 = questionDao.createAndPersist(null, "Count-shared-Item-1", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, mcType);
    QuestionItem item2 = questionDao.createAndPersist(null, "Count-shared-Item-2", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, mcType);
    QuestionItem item3 = questionDao.createAndPersist(null, "Count-shared-Item-3", QTIConstants.QTI_12_FORMAT, Locale.FRENCH.getLanguage(), null, null, null, fibType);
    dbInstance.commit();
    // share them
    questionDao.share(item1, group.getResource());
    questionDao.share(item2, group.getResource());
    questionDao.share(item3, group.getResource());
    dbInstance.commitAndCloseSession();
    // retrieve them
    int sharedItems = questionDao.countSharedItemByResource(group.getResource(), null);
    Assert.assertEquals(3, sharedItems);
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) 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