Search in sources :

Example 6 with QuestionItemAuditLogBuilder

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

the class QuestionPoolMainEditorController method doCopyToMy.

private void doCopyToMy(QuestionItemShort item) {
    List<QuestionItem> copiedItems = qpoolService.copyItems(getIdentity(), singletonList(item));
    for (QuestionItem copy : copiedItems) {
        QuestionItemAuditLogBuilder builder = qpoolService.createAuditLogBuilder(getIdentity(), Action.CREATE_QUESTION_ITEM_BY_COPY);
        builder.withAfter(copy);
        qpoolService.persist(builder.create());
    }
    showInfo("item.copied", Integer.toString(copiedItems.size()));
    if (currentCtrl instanceof QuestionsController) {
        ((QuestionsController) currentCtrl).updateSource();
    }
}
Also used : QuestionItemAuditLogBuilder(org.olat.modules.qpool.QuestionItemAuditLogBuilder) QuestionItem(org.olat.modules.qpool.QuestionItem)

Example 7 with QuestionItemAuditLogBuilder

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

the class ImportController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    String filename = fileEl.getUploadFileName();
    File file = fileEl.getUploadFile();
    List<QuestionItem> importItems = qpoolService.importItems(getIdentity(), getLocale(), filename, file);
    if (importItems == null || importItems.isEmpty()) {
        fireEvent(ureq, Event.DONE_EVENT);
        showWarning("import.failed");
    } else {
        boolean editable = editableEl == null ? true : editableEl.isSelected(0);
        source.postImport(importItems, editable);
        for (QuestionItem item : importItems) {
            QuestionItemAuditLogBuilder builder = qpoolService.createAuditLogBuilder(getIdentity(), Action.CREATE_QUESTION_ITEM_BY_IMPORT);
            builder.withAfter(item);
            qpoolService.persist(builder.create());
        }
        fireEvent(ureq, Event.DONE_EVENT);
        showInfo("import.success", Integer.toString(importItems.size()));
    }
}
Also used : QuestionItemAuditLogBuilder(org.olat.modules.qpool.QuestionItemAuditLogBuilder) File(java.io.File) QuestionItem(org.olat.modules.qpool.QuestionItem)

Example 8 with QuestionItemAuditLogBuilder

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

the class QuestionPoolUserDataDeletable method deleteUserData.

@Override
public void deleteUserData(Identity identity, String newDeletedUserName, File archivePath) {
    if (!qpoolModule.isDeleteQuestionsWithoutAuthor())
        return;
    List<QuestionItem> itemsWithOneAuthor = questionItemDao.getItemsWithOneAuthor(identity);
    qpoolService.deleteItems(itemsWithOneAuthor);
    for (QuestionItem item : itemsWithOneAuthor) {
        QuestionItemAuditLogBuilder builder = qpoolService.createAuditLogBuilder(null, Action.DELETE_QUESTION_ITEM);
        builder.withBefore(item);
        builder.withMessage("Author deleted");
        qpoolService.persist(builder.create());
    }
    String logMessage = getLogMessage(identity, itemsWithOneAuthor);
    log.info(logMessage);
}
Also used : QuestionItemAuditLogBuilder(org.olat.modules.qpool.QuestionItemAuditLogBuilder) QuestionItem(org.olat.modules.qpool.QuestionItem)

Example 9 with QuestionItemAuditLogBuilder

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

the class QuestionMetadataEditController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    if (item instanceof QuestionItemImpl) {
        QuestionItemImpl itemImpl = (QuestionItemImpl) item;
        QuestionItemAuditLogBuilder builder = qpoolService.createAuditLogBuilder(getIdentity(), Action.UPDATE_QUESTION_ITEM_METADATA);
        builder.withBefore(itemImpl);
        int day = learningTimeDayElement.getIntValue();
        int hour = learningTimeHourElement.getIntValue();
        int minute = learningTimeMinuteElement.getIntValue();
        int seconds = learningTimeSecondElement.getIntValue();
        String timeStr = MetadataConverterHelper.convertDuration(day, hour, minute, seconds);
        itemImpl.setEducationalLearningTime(timeStr);
        BigDecimal difficulty = toBigDecimal(difficultyEl.getValue());
        itemImpl.setDifficulty(difficulty);
        BigDecimal stdevDifficulty = toBigDecimal(stdevDifficultyEl.getValue());
        itemImpl.setStdevDifficulty(stdevDifficulty);
        BigDecimal differentiation = toBigDecimal(differentiationEl.getValue());
        itemImpl.setDifferentiation(differentiation);
        int numOfAnswerAlternatives = toInt(numAnswerAltEl.getValue());
        itemImpl.setNumOfAnswerAlternatives(numOfAnswerAlternatives);
        int numUsage = toInt(usageEl.getValue());
        itemImpl.setUsage(numUsage);
        item = qpoolService.updateItem(itemImpl);
        builder.withAfter(item);
        qpoolService.persist(builder.create());
        fireEvent(ureq, new QItemEdited(item));
    }
}
Also used : QuestionItemAuditLogBuilder(org.olat.modules.qpool.QuestionItemAuditLogBuilder) QItemEdited(org.olat.modules.qpool.ui.events.QItemEdited) QuestionItemImpl(org.olat.modules.qpool.model.QuestionItemImpl) MetaUIFactory.bigDToString(org.olat.modules.qpool.ui.metadata.MetaUIFactory.bigDToString) BigDecimal(java.math.BigDecimal) MetaUIFactory.validateBigDecimal(org.olat.modules.qpool.ui.metadata.MetaUIFactory.validateBigDecimal) MetaUIFactory.toBigDecimal(org.olat.modules.qpool.ui.metadata.MetaUIFactory.toBigDecimal)

Example 10 with QuestionItemAuditLogBuilder

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

the class RightsMetadataEditController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    if (item instanceof QuestionItemImpl) {
        QuestionItemImpl itemImpl = (QuestionItemImpl) item;
        QuestionItemAuditLogBuilder builder = qpoolService.createAuditLogBuilder(getIdentity(), Action.UPDATE_QUESTION_ITEM_METADATA);
        builder.withBefore(itemImpl);
        if (licenseModule.isEnabled(licenseHandler)) {
            if (licenseEl != null && licenseEl.isOneSelected()) {
                String licenseTypeKey = licenseEl.getSelectedKey();
                LicenseType licneseType = licenseService.loadLicenseTypeByKey(licenseTypeKey);
                license.setLicenseType(licneseType);
            }
            String licensor = null;
            String freetext = null;
            if (licensorEl != null && licensorEl.isVisible()) {
                licensor = StringHelper.containsNonWhitespace(licensorEl.getValue()) ? licensorEl.getValue() : null;
            }
            if (licenseFreetextEl != null && licenseFreetextEl.isVisible()) {
                freetext = StringHelper.containsNonWhitespace(licenseFreetextEl.getValue()) ? licenseFreetextEl.getValue() : null;
            }
            license.setLicensor(licensor);
            license.setFreetext(freetext);
            license = licenseService.update(license);
            licensorEl.setValue(license.getLicensor());
            licenseFreetextEl.setValue(license.getFreetext());
        }
        item = qpoolService.updateItem(item);
        builder.withAfter(itemImpl);
        qpoolService.persist(builder.create());
        fireEvent(ureq, new QItemEdited(item));
    }
}
Also used : QuestionItemAuditLogBuilder(org.olat.modules.qpool.QuestionItemAuditLogBuilder) QItemEdited(org.olat.modules.qpool.ui.events.QItemEdited) QuestionItemImpl(org.olat.modules.qpool.model.QuestionItemImpl) LicenseType(org.olat.core.commons.services.license.LicenseType)

Aggregations

QuestionItemAuditLogBuilder (org.olat.modules.qpool.QuestionItemAuditLogBuilder)42 QuestionItem (org.olat.modules.qpool.QuestionItem)32 QuestionItemImpl (org.olat.modules.qpool.model.QuestionItemImpl)16 QItemEdited (org.olat.modules.qpool.ui.events.QItemEdited)8 QuestionItemShort (org.olat.modules.qpool.QuestionItemShort)6 QPoolEvent (org.olat.modules.qpool.ui.events.QPoolEvent)6 UserRequest (org.olat.core.gui.UserRequest)4 WindowControl (org.olat.core.gui.control.WindowControl)4 Step (org.olat.core.gui.control.generic.wizard.Step)4 StepRunnerCallback (org.olat.core.gui.control.generic.wizard.StepRunnerCallback)4 StepsMainRunController (org.olat.core.gui.control.generic.wizard.StepsMainRunController)4 StepsRunContext (org.olat.core.gui.control.generic.wizard.StepsRunContext)4 QTIQPoolServiceProvider (org.olat.ims.qti.qpool.QTIQPoolServiceProvider)4 QTI21QPoolServiceProvider (org.olat.ims.qti21.pool.QTI21QPoolServiceProvider)4 AssessmentItemAndMetadata (org.olat.ims.qti21.questionimport.AssessmentItemAndMetadata)4 AssessmentItemsPackage (org.olat.ims.qti21.questionimport.AssessmentItemsPackage)4 ImportOptions (org.olat.ims.qti21.questionimport.ImportOptions)4 QImport_1_InputStep (org.olat.ims.qti21.questionimport.QImport_1_InputStep)4 QPoolService (org.olat.modules.qpool.QPoolService)4 Export_1_TypeStep (org.olat.modules.qpool.ui.wizard.Export_1_TypeStep)4