use of org.olat.modules.qpool.QuestionItem2Pool in project OpenOLAT by OpenOLAT.
the class QuestionPoolMainEditorController method activateQuestionItem.
private void activateQuestionItem(UserRequest ureq, Long itemKey, List<ContextEntry> entries) {
QuestionItem item = qpoolService.loadItemById(itemKey);
if (item == null)
return;
List<Identity> authors = qpoolService.getAuthors(item);
if (authors.contains(getIdentity())) {
activateNode(ureq, treeModel.getMyQuestionsNode(), entries);
return;
}
if (item.getTaxonomyLevel() != null && item.getQuestionStatus() != null && QuestionStatus.finalVersion.equals(item.getQuestionStatus()) && treeModel.getFinalNode() != null) {
TreeNode levelNode = treeModel.getFinalTanonomyLevelNode(item.getTaxonomyLevel());
if (levelNode != null) {
activateNode(ureq, levelNode, entries);
return;
}
}
if (treeModel.getSharesNode() != null) {
List<QuestionItem2Resource> shares = qpoolService.getSharedResourceInfosByItem(item);
for (QuestionItem2Resource share : shares) {
TreeNode levelNode = treeModel.getShareNode(share);
if (levelNode != null) {
activateNode(ureq, levelNode, entries);
return;
}
}
List<QuestionItem2Pool> pools = qpoolService.getPoolInfosByItem(item);
for (QuestionItem2Pool pool : pools) {
TreeNode levelNode = treeModel.getShareNode(pool);
if (levelNode != null) {
activateNode(ureq, levelNode, entries);
return;
}
}
}
}
use of org.olat.modules.qpool.QuestionItem2Pool in project openolat by klemens.
the class PoolDAOTest method getPoolInfos_byItem.
@Test
public void getPoolInfos_byItem() {
// create a pool
String poolName = "NGC-" + UUID.randomUUID().toString();
Pool pool1 = poolDao.createPool(null, poolName, true);
Pool pool2 = poolDao.createPool(null, poolName, true);
QItemType mcType = qItemTypeDao.loadByType(QuestionType.MC.name());
QuestionItem item = questionItemDao.createAndPersist(null, "Galaxy", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, mcType);
List<Pool> pools = new ArrayList<Pool>(2);
pools.add(pool1);
pools.add(pool2);
poolDao.addItemToPool(item, pools, false);
dbInstance.commitAndCloseSession();
// retrieve
List<QuestionItem2Pool> infos = poolDao.getQuestionItem2Pool(item);
Assert.assertNotNull(infos);
Assert.assertEquals(2, infos.size());
}
use of org.olat.modules.qpool.QuestionItem2Pool in project OpenOLAT by OpenOLAT.
the class PoolDAOTest method getPoolInfos_byItem.
@Test
public void getPoolInfos_byItem() {
// create a pool
String poolName = "NGC-" + UUID.randomUUID().toString();
Pool pool1 = poolDao.createPool(null, poolName, true);
Pool pool2 = poolDao.createPool(null, poolName, true);
QItemType mcType = qItemTypeDao.loadByType(QuestionType.MC.name());
QuestionItem item = questionItemDao.createAndPersist(null, "Galaxy", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, mcType);
List<Pool> pools = new ArrayList<Pool>(2);
pools.add(pool1);
pools.add(pool2);
poolDao.addItemToPool(item, pools, false);
dbInstance.commitAndCloseSession();
// retrieve
List<QuestionItem2Pool> infos = poolDao.getQuestionItem2Pool(item);
Assert.assertNotNull(infos);
Assert.assertEquals(2, infos.size());
}
use of org.olat.modules.qpool.QuestionItem2Pool in project openolat by klemens.
the class QuestionPoolMainEditorController method activateQuestionItem.
private void activateQuestionItem(UserRequest ureq, Long itemKey, List<ContextEntry> entries) {
QuestionItem item = qpoolService.loadItemById(itemKey);
if (item == null)
return;
List<Identity> authors = qpoolService.getAuthors(item);
if (authors.contains(getIdentity())) {
activateNode(ureq, treeModel.getMyQuestionsNode(), entries);
return;
}
if (item.getTaxonomyLevel() != null && item.getQuestionStatus() != null && QuestionStatus.finalVersion.equals(item.getQuestionStatus()) && treeModel.getFinalNode() != null) {
TreeNode levelNode = treeModel.getFinalTanonomyLevelNode(item.getTaxonomyLevel());
if (levelNode != null) {
activateNode(ureq, levelNode, entries);
return;
}
}
if (treeModel.getSharesNode() != null) {
List<QuestionItem2Resource> shares = qpoolService.getSharedResourceInfosByItem(item);
for (QuestionItem2Resource share : shares) {
TreeNode levelNode = treeModel.getShareNode(share);
if (levelNode != null) {
activateNode(ureq, levelNode, entries);
return;
}
}
List<QuestionItem2Pool> pools = qpoolService.getPoolInfosByItem(item);
for (QuestionItem2Pool pool : pools) {
TreeNode levelNode = treeModel.getShareNode(pool);
if (levelNode != null) {
activateNode(ureq, levelNode, entries);
return;
}
}
}
}
Aggregations