Search in sources :

Example 21 with QuestionItemAuditLogBuilder

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

the class QuestionPoolServiceImpl method rateItemInReview.

@Override
public void rateItemInReview(QuestionItem item, Identity identity, Float rating, String comment) {
    if (item == null || identity == null)
        return;
    if (rating != null && rating > 0f) {
        // Review is only in status review possible
        QuestionItem previousItem = loadItemById(item.getKey());
        if (QuestionStatus.review.equals(previousItem.getQuestionStatus())) {
            QuestionItemAuditLogBuilder builder = createAuditLogBuilder(identity, Action.REVIEW_QUESTION_ITEM);
            builder.withBefore(item);
            Integer newRating = Float.valueOf(rating).intValue();
            builder.withMessage("Rating: " + newRating);
            commentAndRatingService.createRating(identity, item, null, newRating);
            ReviewDecision decision = reviewService.decideStatus(item, rating);
            if (item instanceof QuestionItemImpl && decision.isStatusChanged()) {
                QuestionItemImpl itemImpl = (QuestionItemImpl) item;
                itemImpl.setQuestionStatus(decision.getStatus());
                updateItem(itemImpl);
            }
            builder.withAfter(item);
            persist(builder.create());
        }
    }
    if (StringHelper.containsNonWhitespace(comment)) {
        commentAndRatingService.createComment(identity, item, null, comment);
    }
}
Also used : QuestionItemAuditLogBuilder(org.olat.modules.qpool.QuestionItemAuditLogBuilder) ReviewDecision(org.olat.modules.qpool.model.ReviewDecision) QuestionItemImpl(org.olat.modules.qpool.model.QuestionItemImpl) QuestionItem(org.olat.modules.qpool.QuestionItem)

Example 22 with QuestionItemAuditLogBuilder

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

the class QuestionItemDetailsController method finishQuestionEdition.

private void finishQuestionEdition() {
    if (questionEdited) {
        QuestionItem item = metadatasCtrl.getItem();
        qpoolService.backupQuestion(item);
        QuestionItemAuditLogBuilder builder = qpoolService.createAuditLogBuilder(getIdentity(), Action.UPDATE_QUESTION).withBefore(item).withAfter(item);
        qpoolService.persist(builder.create());
    }
}
Also used : QuestionItemAuditLogBuilder(org.olat.modules.qpool.QuestionItemAuditLogBuilder) QuestionItem(org.olat.modules.qpool.QuestionItem)

Example 23 with QuestionItemAuditLogBuilder

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

the class QuestionItemDetailsController method doDelete.

private void doDelete(UserRequest ureq, 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);
    fireEvent(ureq, new QPoolEvent(QPoolEvent.ITEM_DELETED));
    showInfo("item.deleted");
}
Also used : QuestionItemAuditLogBuilder(org.olat.modules.qpool.QuestionItemAuditLogBuilder) QuestionItemShort(org.olat.modules.qpool.QuestionItemShort) QPoolEvent(org.olat.modules.qpool.ui.events.QPoolEvent) QuestionItem(org.olat.modules.qpool.QuestionItem)

Example 24 with QuestionItemAuditLogBuilder

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

the class QuestionListController method doImportResource.

private void doImportResource(UserRequest ureq, RepositoryEntry repositoryEntry) {
    List<QuestionItem> importItems = null;
    if (ImsQTI21Resource.TYPE_NAME.equals(repositoryEntry.getOlatResource().getResourceableTypeName())) {
        QTI21QPoolServiceProvider spi = CoreSpringFactory.getImpl(QTI21QPoolServiceProvider.class);
        importItems = spi.importRepositoryEntry(getIdentity(), repositoryEntry, getLocale());
    } else {
        QTIQPoolServiceProvider spi = (QTIQPoolServiceProvider) CoreSpringFactory.getBean("qtiPoolServiceProvider");
        importItems = spi.importRepositoryEntry(getIdentity(), repositoryEntry, getLocale());
    }
    for (QuestionItem item : importItems) {
        QuestionItemAuditLogBuilder builder = qpoolService.createAuditLogBuilder(getIdentity(), Action.CREATE_QUESTION_ITEM_BY_IMPORT);
        builder.withAfter(item);
        qpoolService.persist(builder.create());
    }
    if (getSource().askEditable()) {
        removeAsListenerAndDispose(shareItemsToSourceCtrl);
        shareItemsToSourceCtrl = new ShareItemSourceOptionController(ureq, getWindowControl(), importItems, getSource());
        listenTo(shareItemsToSourceCtrl);
        removeAsListenerAndDispose(cmcShareItemToSource);
        cmcShareItemToSource = new CloseableModalController(getWindowControl(), translate("close"), shareItemsToSourceCtrl.getInitialComponent(), true, translate("import.item"));
        cmcShareItemToSource.activate();
        listenTo(cmcShareItemToSource);
    } else {
        qpoolService.index(importItems);
        int postImported = getSource().postImport(importItems, true);
        if (postImported > 0) {
            getItemsTable().reset();
        }
        if (importItems.isEmpty()) {
            showWarning("import.failed");
        } else {
            showInfo("import.success", Integer.toString(importItems.size()));
            getItemsTable().reset();
        }
    }
}
Also used : QuestionItemAuditLogBuilder(org.olat.modules.qpool.QuestionItemAuditLogBuilder) QTI21QPoolServiceProvider(org.olat.ims.qti21.pool.QTI21QPoolServiceProvider) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) QTIQPoolServiceProvider(org.olat.ims.qti.qpool.QTIQPoolServiceProvider) QuestionItem(org.olat.modules.qpool.QuestionItem)

Example 25 with QuestionItemAuditLogBuilder

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

the class QuestionListController method doOpenExcelImportQTI12.

private void doOpenExcelImportQTI12(UserRequest ureq) {
    removeAsListenerAndDispose(excelImportWizard);
    final ItemsPackage importPackage = new ItemsPackage();
    Step additionalStep = null;
    if (getSource().askEditable()) {
        additionalStep = new EditableStep(ureq);
    }
    final org.olat.ims.qti.questionimport.ImportOptions options = new org.olat.ims.qti.questionimport.ImportOptions();
    options.setShuffle(true);
    Step start = new org.olat.ims.qti.questionimport.QImport_1_InputStep(ureq, importPackage, options, additionalStep);
    StepRunnerCallback finish = new StepRunnerCallback() {

        @Override
        public Step execute(UserRequest uureq, WindowControl wControl, StepsRunContext runContext) {
            List<ItemAndMetadata> itemsToImport = importPackage.getItems();
            QTIQPoolServiceProvider spi = CoreSpringFactory.getImpl(QTIQPoolServiceProvider.class);
            List<QuestionItem> importItems = spi.importBeecomItem(getIdentity(), itemsToImport, getLocale());
            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.12"), "o_sel_qpool_excel_import_wizard");
    listenTo(excelImportWizard);
    getWindowControl().pushAsModalDialog(excelImportWizard.getInitialComponent());
}
Also used : QImport_1_InputStep(org.olat.ims.qti21.questionimport.QImport_1_InputStep) Step(org.olat.core.gui.control.generic.wizard.Step) Export_1_TypeStep(org.olat.modules.qpool.ui.wizard.Export_1_TypeStep) ImportAuthor_1_ChooseMemberStep(org.olat.modules.qpool.ui.wizard.ImportAuthor_1_ChooseMemberStep) WindowControl(org.olat.core.gui.control.WindowControl) StepsRunContext(org.olat.core.gui.control.generic.wizard.StepsRunContext) QImport_1_InputStep(org.olat.ims.qti21.questionimport.QImport_1_InputStep) QTIQPoolServiceProvider(org.olat.ims.qti.qpool.QTIQPoolServiceProvider) UserRequest(org.olat.core.gui.UserRequest) AssessmentItemsPackage(org.olat.ims.qti21.questionimport.AssessmentItemsPackage) ItemsPackage(org.olat.ims.qti.questionimport.ItemsPackage) QuestionItemAuditLogBuilder(org.olat.modules.qpool.QuestionItemAuditLogBuilder) StepsMainRunController(org.olat.core.gui.control.generic.wizard.StepsMainRunController) AssessmentItemAndMetadata(org.olat.ims.qti21.questionimport.AssessmentItemAndMetadata) ItemAndMetadata(org.olat.ims.qti.questionimport.ItemAndMetadata) QuestionItem(org.olat.modules.qpool.QuestionItem) ImportOptions(org.olat.ims.qti21.questionimport.ImportOptions) StepRunnerCallback(org.olat.core.gui.control.generic.wizard.StepRunnerCallback)

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