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);
}
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());
}
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);
}
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);
}
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");
}
Aggregations