use of org.olat.modules.qpool.QuestionItemAuditLogBuilder in project OpenOLAT by OpenOLAT.
the class QuestionItemDetailsController method doChangeQuestionStatus.
private void doChangeQuestionStatus(UserRequest ureq, QuestionItem item, QuestionStatus newStatus) {
if (!newStatus.equals(item.getQuestionStatus()) && item instanceof QuestionItemImpl) {
QuestionItemImpl itemImpl = (QuestionItemImpl) item;
QuestionItemAuditLogBuilder builder = qpoolService.createAuditLogBuilder(getIdentity(), Action.STATUS_CHANGED);
builder.withBefore(itemImpl);
builder.withMessage("New status: " + newStatus);
itemImpl.setQuestionStatus(newStatus);
qpoolService.updateItem(itemImpl);
builder.withAfter(item);
qpoolService.persist(builder.create());
fireEvent(ureq, new QPoolEvent(QPoolEvent.ITEM_STATUS_CHANGED, item.getKey()));
}
reloadData(ureq);
}
use of org.olat.modules.qpool.QuestionItemAuditLogBuilder 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");
}
use of org.olat.modules.qpool.QuestionItemAuditLogBuilder in project OpenOLAT by OpenOLAT.
the class QuestionListController method doOpenExcelImportQTI21.
private void doOpenExcelImportQTI21(UserRequest ureq) {
removeAsListenerAndDispose(excelImportWizard);
Step additionalStep = null;
if (getSource().askEditable()) {
additionalStep = new EditableStep(ureq);
}
final AssessmentItemsPackage importPackage = new AssessmentItemsPackage();
final ImportOptions options = new ImportOptions();
options.setShuffle(true);
Step start = new QImport_1_InputStep(ureq, importPackage, options, additionalStep);
StepRunnerCallback finish = new StepRunnerCallback() {
@Override
public Step execute(UserRequest uureq, WindowControl wControl, StepsRunContext runContext) {
QTI21QPoolServiceProvider spi = CoreSpringFactory.getImpl(QTI21QPoolServiceProvider.class);
List<AssessmentItemAndMetadata> items = importPackage.getItems();
List<QuestionItem> importItems = new ArrayList<>();
for (AssessmentItemAndMetadata item : items) {
QuestionItem importedItem = spi.importExcelItem(getIdentity(), item, getLocale());
if (importedItem != null) {
importItems.add(importedItem);
}
}
for (QuestionItem item : importItems) {
QuestionItemAuditLogBuilder builder = qpoolService.createAuditLogBuilder(getIdentity(), Action.CREATE_QUESTION_ITEM_BY_IMPORT);
builder.withAfter(item);
qpoolService.persist(builder.create());
}
boolean editable = true;
if (getSource().askEditable()) {
Object editableCtx = runContext.get("editable");
editable = (editableCtx instanceof Boolean) ? ((Boolean) editableCtx).booleanValue() : false;
}
qpoolService.index(importItems);
int postImported = getSource().postImport(importItems, editable);
if (postImported > 0) {
getItemsTable().reset();
}
return StepsMainRunController.DONE_MODIFIED;
}
};
excelImportWizard = new StepsMainRunController(ureq, getWindowControl(), start, finish, null, translate("import.excellike.21"), "o_sel_qpool_excel_import_wizard");
listenTo(excelImportWizard);
getWindowControl().pushAsModalDialog(excelImportWizard.getInitialComponent());
}
use of org.olat.modules.qpool.QuestionItemAuditLogBuilder in project OpenOLAT by OpenOLAT.
the class QuestionListController method doCreateNewItem.
private void doCreateNewItem(UserRequest ureq, String title, TaxonomyLevel taxonomyLevel, QItemFactory factory) {
QuestionItem item = factory.createItem(getIdentity(), title, getLocale());
List<QuestionItem> newItems = Collections.singletonList(item);
getSource().postImport(newItems, false);
if (taxonomyLevel != null && item instanceof QuestionItemImpl) {
QuestionItemImpl itemImpl = (QuestionItemImpl) item;
itemImpl.setTaxonomyLevel(taxonomyLevel);
qpoolService.updateItem(itemImpl);
}
if (licenseModule.isEnabled(licenseHandler)) {
// The QItemFactory may create a no license as part of the import process.
// But for new question items the default license should be created.
// So delete the no license first, so that the default license can be created.
licenseService.delete(item);
licenseService.createDefaultLicense(item, licenseHandler, getIdentity());
}
getItemsTable().reset();
dbInstance.commit();
qpoolService.index(newItems);
QuestionItemAuditLogBuilder builder = qpoolService.createAuditLogBuilder(getIdentity(), Action.CREATE_QUESTION_ITEM_NEW);
builder.withAfter(item);
qpoolService.persist(builder.create());
QPoolEvent qce = new QPoolEvent(QPoolEvent.ITEM_CREATED);
fireEvent(ureq, qce);
doOpenDetails(ureq, item);
}
use of org.olat.modules.qpool.QuestionItemAuditLogBuilder in project OpenOLAT by OpenOLAT.
the class CopyConfirmationController method logAudit.
private void logAudit(List<QuestionItem> items) {
for (QuestionItem item : items) {
QuestionItemAuditLogBuilder builder = qpoolService.createAuditLogBuilder(getIdentity(), Action.CREATE_QUESTION_ITEM_BY_COPY);
builder.withAfter(item);
qpoolService.persist(builder.create());
}
}
Aggregations