Search in sources :

Example 1 with QuestionItemShort

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

the class QTIQPoolServiceProvider method assembleTest.

public void assembleTest(List<QuestionItemShort> items, ZipOutputStream zout) {
    List<Long> itemKeys = new ArrayList<>();
    for (QuestionItemShort item : items) {
        itemKeys.add(item.getKey());
    }
    List<QuestionItemFull> fullItems = questionItemDao.loadByIds(itemKeys);
    QTIExportProcessor processor = new QTIExportProcessor(qpoolFileStorage);
    processor.assembleTest(fullItems, zout);
}
Also used : QuestionItemFull(org.olat.modules.qpool.QuestionItemFull) QuestionItemShort(org.olat.modules.qpool.QuestionItemShort) ArrayList(java.util.ArrayList)

Example 2 with QuestionItemShort

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

the class PoolDAOTest method removeItemFromPools.

@Test
public void removeItemFromPools() {
    Identity id = JunitTestHelper.createAndPersistIdentityAsUser("Poolman-" + UUID.randomUUID().toString());
    // create a pool with an item
    String poolName = "NGC-" + UUID.randomUUID().toString();
    Pool pool = poolDao.createPool(null, poolName, true);
    QItemType mcType = qItemTypeDao.loadByType(QuestionType.MC.name());
    QuestionItem item = questionItemDao.createAndPersist(id, "Galaxy", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, mcType);
    poolDao.addItemToPool(item, Collections.singletonList(pool), false);
    dbInstance.commitAndCloseSession();
    SearchQuestionItemParams params = new SearchQuestionItemParams(id, null);
    params.setPoolKey(pool.getKey());
    // check the pool and remove the items
    List<QuestionItemView> items = qItemQueriesDao.getItemsOfPool(params, null, 0, -1);
    Assert.assertEquals(1, items.size());
    List<QuestionItemShort> toDelete = Collections.<QuestionItemShort>singletonList(items.get(0));
    int count = poolDao.removeFromPools(toDelete);
    Assert.assertEquals(1, count);
    dbInstance.commitAndCloseSession();
    // check if the pool is empty
    List<QuestionItemView> emptyItems = qItemQueriesDao.getItemsOfPool(params, null, 0, -1);
    Assert.assertTrue(emptyItems.isEmpty());
}
Also used : QuestionItemShort(org.olat.modules.qpool.QuestionItemShort) QuestionItem2Pool(org.olat.modules.qpool.QuestionItem2Pool) 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) QItemType(org.olat.modules.qpool.model.QItemType) Test(org.junit.Test)

Example 3 with QuestionItemShort

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

the class QuestionItemDetailsController method doConfirmConversion.

private void doConfirmConversion(UserRequest ureq, QuestionItemShort item) {
    Map<String, List<QuestionItemShort>> formatToItems = new HashMap<>();
    List<QPoolSPI> spies = poolModule.getQuestionPoolProviders();
    for (QPoolSPI sp : spies) {
        if (sp != null && sp.isConversionPossible(item)) {
            List<QuestionItemShort> convertItems;
            if (formatToItems.containsKey(sp.getFormat())) {
                convertItems = formatToItems.get(sp.getFormat());
            } else {
                convertItems = new ArrayList<>(1);
                formatToItems.put(sp.getFormat(), Collections.singletonList(item));
            }
            convertItems.add(item);
        }
    }
    conversionConfirmationCtrl = new ConversionConfirmationController(ureq, getWindowControl(), formatToItems, itemSource);
    listenTo(conversionConfirmationCtrl);
    cmc = new CloseableModalController(getWindowControl(), translate("close"), conversionConfirmationCtrl.getInitialComponent(), true, translate("convert.item"));
    cmc.activate();
    listenTo(cmc);
}
Also used : HashMap(java.util.HashMap) QPoolSPI(org.olat.modules.qpool.QPoolSPI) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) QuestionItemShort(org.olat.modules.qpool.QuestionItemShort) List(java.util.List) ArrayList(java.util.ArrayList)

Example 4 with QuestionItemShort

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

the class QuestionItemDetailsController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (source == copyConfirmationCtrl) {
        doPostCopy(ureq, event);
        cmc.deactivate();
        cleanUp();
    } else if (source == conversionConfirmationCtrl) {
        doPostConvert(ureq, event);
        cmc.deactivate();
        cleanUp();
    } else if (source == selectGroupCtrl) {
        if (event instanceof BusinessGroupSelectionEvent) {
            BusinessGroupSelectionEvent bge = (BusinessGroupSelectionEvent) event;
            List<BusinessGroup> groups = bge.getGroups();
            if (groups.size() > 0) {
                QuestionItem item = (QuestionItem) ((SelectBusinessGroupController) source).getUserObject();
                doShareItemsWithGroup(ureq, item, groups);
                metadatasCtrl.updateShares();
            }
        }
        cmc.deactivate();
        cleanUp();
    } else if (source == selectPoolCtrl) {
        cmc.deactivate();
        if (event instanceof QPoolSelectionEvent) {
            QPoolSelectionEvent qpe = (QPoolSelectionEvent) event;
            List<Pool> pools = qpe.getPools();
            if (pools.size() > 0) {
                QuestionItemShort item = (QuestionItemShort) selectPoolCtrl.getUserObject();
                doShareItemsWithPool(ureq, item, pools);
                metadatasCtrl.updateShares();
            }
        }
        cleanUp();
    } else if (source == reviewActionCtrl) {
        if (QItemReviewEvent.START.equals(event.getCommand())) {
            doConfirmStartReview(ureq);
        } else if (QItemReviewEvent.DO.equals(event.getCommand())) {
            openReview(ureq);
        }
    } else if (source == reviewStartCtrl) {
        if (event == Event.DONE_EVENT) {
            TaxonomyLevel taxonomyLevel = reviewStartCtrl.getSelectedTaxonomyLevel();
            doStartReview(ureq, taxonomyLevel);
        }
        cmc.deactivate();
        cleanUp();
    } else if (source == reviewCtrl) {
        if (event == Event.DONE_EVENT) {
            float rating = reviewCtrl.getCurrentRatting();
            String comment = reviewCtrl.getComment();
            doRate(ureq, rating, comment);
        }
        cmc.deactivate();
        cleanUp();
    } else if (source == confirmEndOfLifeCtrl) {
        boolean endOfLife = DialogBoxUIFactory.isYesEvent(event) || DialogBoxUIFactory.isOkEvent(event);
        if (endOfLife) {
            QuestionItem item = (QuestionItem) confirmEndOfLifeCtrl.getUserObject();
            doEndOfLife(ureq, item);
        }
        cleanUp();
    } else if (source == deleteConfirmationCtrl) {
        if (event == Event.DONE_EVENT) {
            List<QuestionItemShort> items = deleteConfirmationCtrl.getItemsToDelete();
            doDelete(ureq, items);
        }
        cmc.deactivate();
        cleanUp();
    } else if (source == cmc) {
        cleanUp();
    } else if (source == questionCtrl) {
        if (event instanceof QItemEdited) {
            questionEdited = true;
            fireEvent(ureq, event);
        }
    } else if (source == metadatasCtrl) {
        if (event instanceof QItemEdited) {
            reloadData(ureq);
            fireEvent(ureq, event);
        }
    }
    super.event(ureq, source, event);
}
Also used : QItemEdited(org.olat.modules.qpool.ui.events.QItemEdited) BusinessGroup(org.olat.group.BusinessGroup) QPoolSelectionEvent(org.olat.modules.qpool.ui.events.QPoolSelectionEvent) BusinessGroupSelectionEvent(org.olat.group.model.BusinessGroupSelectionEvent) QuestionItemShort(org.olat.modules.qpool.QuestionItemShort) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) List(java.util.List) ArrayList(java.util.ArrayList) QuestionItem(org.olat.modules.qpool.QuestionItem)

Example 5 with QuestionItemShort

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

the class QuestionListController method doDelete.

private void doDelete(List<QuestionItemShort> items) {
    for (QuestionItemShort item : items) {
        QuestionItem qitem = qpoolService.loadItemById(item.getKey());
        QuestionItemAuditLogBuilder builder = qpoolService.createAuditLogBuilder(getIdentity(), Action.DELETE_QUESTION_ITEM);
        builder.withBefore(qitem);
        qpoolService.persist(builder.create());
    }
    qpoolService.deleteItems(items);
    getItemsTable().reset(true, true, true);
    showInfo("item.deleted");
}
Also used : QuestionItemAuditLogBuilder(org.olat.modules.qpool.QuestionItemAuditLogBuilder) QuestionItemShort(org.olat.modules.qpool.QuestionItemShort) QuestionItem(org.olat.modules.qpool.QuestionItem)

Aggregations

QuestionItemShort (org.olat.modules.qpool.QuestionItemShort)76 ArrayList (java.util.ArrayList)52 QuestionItem (org.olat.modules.qpool.QuestionItem)28 Identity (org.olat.core.id.Identity)14 List (java.util.List)12 BusinessGroup (org.olat.group.BusinessGroup)12 Test (org.junit.Test)10 QPoolSPI (org.olat.modules.qpool.QPoolSPI)10 QuestionItemImpl (org.olat.modules.qpool.model.QuestionItemImpl)10 QItemType (org.olat.modules.qpool.model.QItemType)8 HashMap (java.util.HashMap)6 ExportFormatOptions (org.olat.modules.qpool.ExportFormatOptions)6 QuestionItemAuditLogBuilder (org.olat.modules.qpool.QuestionItemAuditLogBuilder)6 QuestionItemFull (org.olat.modules.qpool.QuestionItemFull)6 QuestionItemView (org.olat.modules.qpool.QuestionItemView)6 QItemList (org.olat.modules.qpool.model.QItemList)6 QItemEdited (org.olat.modules.qpool.ui.events.QItemEdited)6 QPoolEvent (org.olat.modules.qpool.ui.events.QPoolEvent)6 QuestionItemCollection (org.olat.modules.qpool.QuestionItemCollection)5 Path (javax.ws.rs.Path)4