Search in sources :

Example 1 with QuestionItem2Pool

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;
            }
        }
    }
}
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 QuestionItem2Pool

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());
}
Also used : ArrayList(java.util.ArrayList) QuestionItem2Pool(org.olat.modules.qpool.QuestionItem2Pool) Pool(org.olat.modules.qpool.Pool) QuestionItem(org.olat.modules.qpool.QuestionItem) QuestionItem2Pool(org.olat.modules.qpool.QuestionItem2Pool) QItemType(org.olat.modules.qpool.model.QItemType) Test(org.junit.Test)

Example 3 with QuestionItem2Pool

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());
}
Also used : ArrayList(java.util.ArrayList) QuestionItem2Pool(org.olat.modules.qpool.QuestionItem2Pool) Pool(org.olat.modules.qpool.Pool) QuestionItem(org.olat.modules.qpool.QuestionItem) QuestionItem2Pool(org.olat.modules.qpool.QuestionItem2Pool) QItemType(org.olat.modules.qpool.model.QItemType) Test(org.junit.Test)

Example 4 with QuestionItem2Pool

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;
            }
        }
    }
}
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

QuestionItem (org.olat.modules.qpool.QuestionItem)4 QuestionItem2Pool (org.olat.modules.qpool.QuestionItem2Pool)4 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 TreeNode (org.olat.core.gui.components.tree.TreeNode)2 Identity (org.olat.core.id.Identity)2 Pool (org.olat.modules.qpool.Pool)2 QuestionItem2Resource (org.olat.modules.qpool.QuestionItem2Resource)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