Search in sources :

Example 1 with ImportOptions

use of org.olat.ims.qti21.questionimport.ImportOptions 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());
}
Also used : ArrayList(java.util.ArrayList) 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) QuestionItemAuditLogBuilder(org.olat.modules.qpool.QuestionItemAuditLogBuilder) QTI21QPoolServiceProvider(org.olat.ims.qti21.pool.QTI21QPoolServiceProvider) AssessmentItemAndMetadata(org.olat.ims.qti21.questionimport.AssessmentItemAndMetadata) AssessmentItemsPackage(org.olat.ims.qti21.questionimport.AssessmentItemsPackage) StepsMainRunController(org.olat.core.gui.control.generic.wizard.StepsMainRunController) QuestionItem(org.olat.modules.qpool.QuestionItem) ImportOptions(org.olat.ims.qti21.questionimport.ImportOptions) StepRunnerCallback(org.olat.core.gui.control.generic.wizard.StepRunnerCallback) UserRequest(org.olat.core.gui.UserRequest)

Example 2 with ImportOptions

use of org.olat.ims.qti21.questionimport.ImportOptions in project openolat by klemens.

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());
}
Also used : ArrayList(java.util.ArrayList) 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) QuestionItemAuditLogBuilder(org.olat.modules.qpool.QuestionItemAuditLogBuilder) QTI21QPoolServiceProvider(org.olat.ims.qti21.pool.QTI21QPoolServiceProvider) AssessmentItemAndMetadata(org.olat.ims.qti21.questionimport.AssessmentItemAndMetadata) AssessmentItemsPackage(org.olat.ims.qti21.questionimport.AssessmentItemsPackage) StepsMainRunController(org.olat.core.gui.control.generic.wizard.StepsMainRunController) QuestionItem(org.olat.modules.qpool.QuestionItem) ImportOptions(org.olat.ims.qti21.questionimport.ImportOptions) StepRunnerCallback(org.olat.core.gui.control.generic.wizard.StepRunnerCallback) UserRequest(org.olat.core.gui.UserRequest)

Example 3 with ImportOptions

use of org.olat.ims.qti21.questionimport.ImportOptions in project OpenOLAT by OpenOLAT.

the class AssessmentTestComposerController method doImportTable.

private void doImportTable(UserRequest ureq) {
    removeAsListenerAndDispose(importTableWizard);
    final AssessmentItemsPackage importPackage = new AssessmentItemsPackage();
    final ImportOptions options = new ImportOptions();
    options.setShuffle(!survey);
    Step start = new QImport_1_InputStep(ureq, importPackage, options, null);
    StepRunnerCallback finish = new StepRunnerCallback() {

        @Override
        public Step execute(UserRequest uureq, WindowControl wControl, StepsRunContext runContext) {
            runContext.put("importPackage", importPackage);
            return StepsMainRunController.DONE_MODIFIED;
        }
    };
    importTableWizard = new StepsMainRunController(ureq, getWindowControl(), start, finish, null, translate("tools.import.table"), "o_mi_table_import_wizard");
    listenTo(importTableWizard);
    getWindowControl().pushAsModalDialog(importTableWizard.getInitialComponent());
}
Also used : AssessmentItemsPackage(org.olat.ims.qti21.questionimport.AssessmentItemsPackage) StepsMainRunController(org.olat.core.gui.control.generic.wizard.StepsMainRunController) QImport_1_InputStep(org.olat.ims.qti21.questionimport.QImport_1_InputStep) Step(org.olat.core.gui.control.generic.wizard.Step) WindowControl(org.olat.core.gui.control.WindowControl) StepsRunContext(org.olat.core.gui.control.generic.wizard.StepsRunContext) ImportOptions(org.olat.ims.qti21.questionimport.ImportOptions) StepRunnerCallback(org.olat.core.gui.control.generic.wizard.StepRunnerCallback) UserRequest(org.olat.core.gui.UserRequest) QImport_1_InputStep(org.olat.ims.qti21.questionimport.QImport_1_InputStep)

Example 4 with ImportOptions

use of org.olat.ims.qti21.questionimport.ImportOptions in project openolat by klemens.

the class AssessmentTestComposerController method doImportTable.

private void doImportTable(UserRequest ureq) {
    removeAsListenerAndDispose(importTableWizard);
    final AssessmentItemsPackage importPackage = new AssessmentItemsPackage();
    final ImportOptions options = new ImportOptions();
    options.setShuffle(!survey);
    Step start = new QImport_1_InputStep(ureq, importPackage, options, null);
    StepRunnerCallback finish = new StepRunnerCallback() {

        @Override
        public Step execute(UserRequest uureq, WindowControl wControl, StepsRunContext runContext) {
            runContext.put("importPackage", importPackage);
            return StepsMainRunController.DONE_MODIFIED;
        }
    };
    importTableWizard = new StepsMainRunController(ureq, getWindowControl(), start, finish, null, translate("tools.import.table"), "o_mi_table_import_wizard");
    listenTo(importTableWizard);
    getWindowControl().pushAsModalDialog(importTableWizard.getInitialComponent());
}
Also used : AssessmentItemsPackage(org.olat.ims.qti21.questionimport.AssessmentItemsPackage) StepsMainRunController(org.olat.core.gui.control.generic.wizard.StepsMainRunController) QImport_1_InputStep(org.olat.ims.qti21.questionimport.QImport_1_InputStep) Step(org.olat.core.gui.control.generic.wizard.Step) WindowControl(org.olat.core.gui.control.WindowControl) StepsRunContext(org.olat.core.gui.control.generic.wizard.StepsRunContext) ImportOptions(org.olat.ims.qti21.questionimport.ImportOptions) StepRunnerCallback(org.olat.core.gui.control.generic.wizard.StepRunnerCallback) UserRequest(org.olat.core.gui.UserRequest) QImport_1_InputStep(org.olat.ims.qti21.questionimport.QImport_1_InputStep)

Aggregations

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 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 ArrayList (java.util.ArrayList)2 QTI21QPoolServiceProvider (org.olat.ims.qti21.pool.QTI21QPoolServiceProvider)2 AssessmentItemAndMetadata (org.olat.ims.qti21.questionimport.AssessmentItemAndMetadata)2 QuestionItem (org.olat.modules.qpool.QuestionItem)2 QuestionItemAuditLogBuilder (org.olat.modules.qpool.QuestionItemAuditLogBuilder)2 Export_1_TypeStep (org.olat.modules.qpool.ui.wizard.Export_1_TypeStep)2 ImportAuthor_1_ChooseMemberStep (org.olat.modules.qpool.ui.wizard.ImportAuthor_1_ChooseMemberStep)2