Search in sources :

Example 36 with Pool

use of org.olat.modules.qpool.Pool in project OpenOLAT by OpenOLAT.

the class PoolDAOTest method isMemberOfPrivatePools_poolOnly.

@Test
public void isMemberOfPrivatePools_poolOnly() {
    Identity id = JunitTestHelper.createAndPersistIdentityAsUser("Pool-owner-" + UUID.randomUUID().toString());
    Pool pool = poolDao.createPool(id, "NGC owned", false);
    Assert.assertNotNull(pool);
    dbInstance.commitAndCloseSession();
    boolean isMember = poolDao.isMemberOfPrivatePools(id);
    Assert.assertTrue(isMember);
}
Also used : QuestionItem2Pool(org.olat.modules.qpool.QuestionItem2Pool) Pool(org.olat.modules.qpool.Pool) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 37 with Pool

use of org.olat.modules.qpool.Pool in project OpenOLAT by OpenOLAT.

the class PoolDAOTest method getPoolsAndGetNumOfPools.

@Test
public void getPoolsAndGetNumOfPools() {
    // create a pool
    String poolName = "NGC-" + UUID.randomUUID().toString();
    Pool pool = poolDao.createPool(null, poolName, true);
    Assert.assertNotNull(pool);
    Assert.assertNotNull(pool.getKey());
    Assert.assertEquals(poolName, pool.getName());
    Assert.assertTrue(pool.isPublicPool());
    dbInstance.commitAndCloseSession();
    // get pools
    List<Pool> pools = poolDao.getPools(0, -1);
    Assert.assertNotNull(pools);
    Assert.assertTrue(pools.size() >= 1);
    // count
    int numOfPools = poolDao.countPools();
    Assert.assertEquals(pools.size(), numOfPools);
    // retrieve our pool
    boolean foundIt = false;
    for (Pool retrievedPool : pools) {
        if (poolName.equals(retrievedPool.getName())) {
            foundIt = true;
        }
    }
    Assert.assertTrue(foundIt);
    dbInstance.commitAndCloseSession();
}
Also used : QuestionItem2Pool(org.olat.modules.qpool.QuestionItem2Pool) Pool(org.olat.modules.qpool.Pool) Test(org.junit.Test)

Example 38 with Pool

use of org.olat.modules.qpool.Pool in project OpenOLAT by OpenOLAT.

the class QItemQueriesDAOTest method shouldGetItemsIsEditableInAPool.

@Test
public void shouldGetItemsIsEditableInAPool() {
    Identity owner1 = createRandomIdentity();
    QuestionItem item11 = createRandomItem(owner1);
    QuestionItem item12 = createRandomItem(owner1);
    QuestionItem item13 = createRandomItem(owner1);
    Pool pool = poolDao.createPool(null, "Pool", true);
    poolDao.addItemToPool(item11, Collections.singletonList(pool), true);
    poolDao.addItemToPool(item12, Collections.singletonList(pool), false);
    dbInstance.commitAndCloseSession();
    SearchQuestionItemParams params = new SearchQuestionItemParams(createRandomIdentity(), null);
    List<QuestionItemView> loadedItems = qItemQueriesDao.getItems(params, null, 0, -1);
    assertThat(filterByKey(loadedItems, item11).isEditableInPool()).isTrue();
    assertThat(filterByKey(loadedItems, item12).isEditableInPool()).isFalse();
    assertThat(filterByKey(loadedItems, item13).isEditableInPool()).isFalse();
}
Also used : Pool(org.olat.modules.qpool.Pool) Identity(org.olat.core.id.Identity) SearchQuestionItemParams(org.olat.modules.qpool.model.SearchQuestionItemParams) QuestionItemView(org.olat.modules.qpool.QuestionItemView) QuestionItem(org.olat.modules.qpool.QuestionItem) Test(org.junit.Test)

Example 39 with Pool

use of org.olat.modules.qpool.Pool in project OpenOLAT by OpenOLAT.

the class QuestionPoolServiceImpl method removeOwners.

@Override
public void removeOwners(List<Identity> owners, List<Pool> pools) {
    if (owners == null || owners.isEmpty() || pools == null || pools.isEmpty()) {
        // nothing to do
        return;
    }
    List<SecurityGroup> secGroups = new ArrayList<SecurityGroup>(pools.size());
    for (Pool pool : pools) {
        SecurityGroup secGroup = ((PoolImpl) pool).getOwnerGroup();
        secGroups.add(secGroup);
    }
    securityManager.removeIdentityFromSecurityGroups(owners, secGroups);
}
Also used : ArrayList(java.util.ArrayList) QuestionItem2Pool(org.olat.modules.qpool.QuestionItem2Pool) Pool(org.olat.modules.qpool.Pool) SecurityGroup(org.olat.basesecurity.SecurityGroup) PoolImpl(org.olat.modules.qpool.model.PoolImpl)

Example 40 with Pool

use of org.olat.modules.qpool.Pool in project OpenOLAT by OpenOLAT.

the class PoolsAdminController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (source == createPool) {
        doEditPool(ureq, null);
    } else if (source == poolTable) {
        if (event instanceof SelectionEvent) {
            SelectionEvent se = (SelectionEvent) event;
            if ("edit-pool".equals(se.getCommand())) {
                Pool row = model.getObject(se.getIndex());
                doEditPool(ureq, row);
            } else if ("delete-pool".equals(se.getCommand())) {
                Pool row = model.getObject(se.getIndex());
                doConfirmDelete(ureq, row);
            } else if ("owners-pool".equals(se.getCommand())) {
                Pool row = model.getObject(se.getIndex());
                doManageOwners(ureq, row);
            }
        }
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : SelectionEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent) Pool(org.olat.modules.qpool.Pool)

Aggregations

Pool (org.olat.modules.qpool.Pool)52 QuestionItem2Pool (org.olat.modules.qpool.QuestionItem2Pool)32 Test (org.junit.Test)30 Identity (org.olat.core.id.Identity)22 QuestionItem (org.olat.modules.qpool.QuestionItem)20 QItemType (org.olat.modules.qpool.model.QItemType)12 SearchQuestionItemParams (org.olat.modules.qpool.model.SearchQuestionItemParams)12 QuestionItemView (org.olat.modules.qpool.QuestionItemView)10 BusinessGroup (org.olat.group.BusinessGroup)8 ArrayList (java.util.ArrayList)6 List (java.util.List)4 SelectionEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent)4 TreeNode (org.olat.core.gui.components.tree.TreeNode)4 QuestionItemShort (org.olat.modules.qpool.QuestionItemShort)4 PoolItemsSource (org.olat.modules.qpool.ui.datasource.PoolItemsSource)4 Date (java.util.Date)2 Set (java.util.Set)2 StringTokenizer (java.util.StringTokenizer)2 Document (org.apache.lucene.document.Document)2 StringField (org.apache.lucene.document.StringField)2