use of org.olat.modules.qpool.QuestionItem2Resource 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.QuestionItem2Resource 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());
}
use of org.olat.modules.qpool.QuestionItem2Resource in project openolat by klemens.
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());
}
use of org.olat.modules.qpool.QuestionItem2Resource 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