Search in sources :

Example 1 with QuestionItem2Resource

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;
            }
        }
    }
}
Also used : MyQuestionsTreeNode(org.olat.modules.qpool.ui.tree.MyQuestionsTreeNode) ControllerTreeNode(org.olat.modules.qpool.ui.tree.ControllerTreeNode) CollectionTreeNode(org.olat.modules.qpool.ui.tree.CollectionTreeNode) TreeNode(org.olat.core.gui.components.tree.TreeNode) MarkedQuestionsTreeNode(org.olat.modules.qpool.ui.tree.MarkedQuestionsTreeNode) Identity(org.olat.core.id.Identity) QuestionItem(org.olat.modules.qpool.QuestionItem) QuestionItem2Pool(org.olat.modules.qpool.QuestionItem2Pool) QuestionItem2Resource(org.olat.modules.qpool.QuestionItem2Resource)

Example 2 with QuestionItem2Resource

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());
}
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 3 with QuestionItem2Resource

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());
}
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 4 with QuestionItem2Resource

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;
            }
        }
    }
}
Also used : MyQuestionsTreeNode(org.olat.modules.qpool.ui.tree.MyQuestionsTreeNode) ControllerTreeNode(org.olat.modules.qpool.ui.tree.ControllerTreeNode) CollectionTreeNode(org.olat.modules.qpool.ui.tree.CollectionTreeNode) TreeNode(org.olat.core.gui.components.tree.TreeNode) MarkedQuestionsTreeNode(org.olat.modules.qpool.ui.tree.MarkedQuestionsTreeNode) Identity(org.olat.core.id.Identity) QuestionItem(org.olat.modules.qpool.QuestionItem) QuestionItem2Pool(org.olat.modules.qpool.QuestionItem2Pool) QuestionItem2Resource(org.olat.modules.qpool.QuestionItem2Resource)

Aggregations

Identity (org.olat.core.id.Identity)4 QuestionItem (org.olat.modules.qpool.QuestionItem)4 QuestionItem2Resource (org.olat.modules.qpool.QuestionItem2Resource)4 Test (org.junit.Test)2 TreeNode (org.olat.core.gui.components.tree.TreeNode)2 BusinessGroup (org.olat.group.BusinessGroup)2 QuestionItem2Pool (org.olat.modules.qpool.QuestionItem2Pool)2 QItemType (org.olat.modules.qpool.model.QItemType)2 CollectionTreeNode (org.olat.modules.qpool.ui.tree.CollectionTreeNode)2 ControllerTreeNode (org.olat.modules.qpool.ui.tree.ControllerTreeNode)2 MarkedQuestionsTreeNode (org.olat.modules.qpool.ui.tree.MarkedQuestionsTreeNode)2 MyQuestionsTreeNode (org.olat.modules.qpool.ui.tree.MyQuestionsTreeNode)2