use of org.olat.modules.qpool.model.QItemType in project openolat by klemens.
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));
}
use of org.olat.modules.qpool.model.QItemType in project openolat by klemens.
the class QuestionDAOTest method getFavoritItemKeys.
@Test
public void getFavoritItemKeys() {
QItemType mcType = qItemTypeDao.loadByType(QuestionType.MC.name());
Identity id = JunitTestHelper.createAndPersistIdentityAsUser("fav-item-" + UUID.randomUUID().toString());
QuestionItem item1 = questionDao.createAndPersist(id, "NGC 331", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, mcType);
QuestionItem item2 = questionDao.createAndPersist(id, "NGC 332", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, mcType);
QuestionItem item3 = questionDao.createAndPersist(id, "NGC 333", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, mcType);
markManager.setMark(item1, id, null, "[QuestionItem:" + item1.getKey() + "]");
markManager.setMark(item2, id, null, "[QuestionItem:" + item2.getKey() + "]");
dbInstance.commitAndCloseSession();
List<Long> favoritKeys = questionDao.getFavoritKeys(id);
Assert.assertNotNull(favoritKeys);
Assert.assertEquals(2, favoritKeys.size());
Assert.assertTrue(favoritKeys.contains(item1.getKey()));
Assert.assertTrue(favoritKeys.contains(item2.getKey()));
Assert.assertFalse(favoritKeys.contains(item3.getKey()));
}
use of org.olat.modules.qpool.model.QItemType in project openolat by klemens.
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();
}
use of org.olat.modules.qpool.model.QItemType in project openolat by klemens.
the class QuestionDAOTest method getSharedResources.
@Test
public void getSharedResources() {
// 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, "gdao", "gdao-desc", -1, -1, false, false, false, false, false);
BusinessGroup group2 = 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, group1.getResource());
questionDao.share(item, group2.getResource());
dbInstance.commitAndCloseSession();
// retrieve them
List<OLATResource> shared = questionDao.getSharedResources(item);
Assert.assertNotNull(shared);
Assert.assertEquals(2, shared.size());
Assert.assertTrue(shared.contains(group1.getResource()));
Assert.assertTrue(shared.contains(group2.getResource()));
}
use of org.olat.modules.qpool.model.QItemType in project openolat by klemens.
the class QuestionDAOTest method deleteQuestion_alreadyDeletedQuestions.
@Test
public void deleteQuestion_alreadyDeletedQuestions() {
QItemType fibType = qItemTypeDao.loadByType(QuestionType.FIB.name());
QuestionItem item1 = questionDao.createAndPersist(null, "To delete 1", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, fibType);
QuestionItem item2 = questionDao.createAndPersist(null, "To delete 2", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, fibType);
dbInstance.commitAndCloseSession();
// delete item 1
questionDao.delete(Collections.singletonList(item1));
dbInstance.commitAndCloseSession();
List<QuestionItem> itemsToDelete = new ArrayList<>();
itemsToDelete.add(item1);
itemsToDelete.add(item2);
questionDao.delete(itemsToDelete);
dbInstance.commitAndCloseSession();
QuestionItem deletedItem1 = questionDao.loadById(item1.getKey());
Assert.assertNull(deletedItem1);
QuestionItem deletedItem2 = questionDao.loadById(item2.getKey());
Assert.assertNull(deletedItem2);
}
Aggregations