Search in sources :

Example 11 with BulkAssessmentDatas

use of org.olat.course.assessment.model.BulkAssessmentDatas in project OpenOLAT by OpenOLAT.

the class DataStepForm method formOK.

@Override
protected void formOK(UserRequest ureq) {
    String val = dataEl.getValue();
    if (!StringHelper.containsNonWhitespace(val) && (returnFileEl != null ? !returnFileEl.isUploadSuccess() : true)) {
        // do not proceed when nothin in input field and no file uploaded
        setFormWarning("form.step2.error");
        return;
    }
    // reset error
    setFormWarning(null);
    BulkAssessmentDatas datas = (BulkAssessmentDatas) getFromRunContext("datas");
    if (datas == null) {
        datas = new BulkAssessmentDatas();
    }
    if (bulkAssessmentTmpDir == null) {
        OlatRootFolderImpl bulkAssessmentDir = new OlatRootFolderImpl("/bulkassessment/", null);
        bulkAssessmentTmpDir = bulkAssessmentDir.createChildContainer(UUID.randomUUID().toString());
    }
    backupInputDatas(val, datas, bulkAssessmentTmpDir);
    List<String[]> splittedRows = splitRawData(val);
    addToRunContext("splittedRows", splittedRows);
    List<BulkAssessmentRow> rows = new ArrayList<>(100);
    if (returnFileEl != null) {
        processReturnFiles(datas, rows, bulkAssessmentTmpDir);
    }
    datas.setRows(rows);
    addToRunContext("datas", datas);
    fireEvent(ureq, StepsEvent.ACTIVATE_NEXT);
}
Also used : BulkAssessmentDatas(org.olat.course.assessment.model.BulkAssessmentDatas) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) ArrayList(java.util.ArrayList) BulkAssessmentRow(org.olat.course.assessment.model.BulkAssessmentRow)

Example 12 with BulkAssessmentDatas

use of org.olat.course.assessment.model.BulkAssessmentDatas in project openolat by klemens.

the class ValidationStepForm method formOK.

@Override
protected void formOK(UserRequest ureq) {
    if (validModel.getRowCount() == 0) {
        // do not continue wizard without valid data
        return;
    }
    BulkAssessmentDatas datas = (BulkAssessmentDatas) getFromRunContext("datas");
    List<BulkAssessmentRow> rows = new ArrayList<>(validModel.getRowCount() + invalidModel.getRowCount());
    for (int i = validModel.getRowCount(); i-- > 0; ) {
        rows.add(validModel.getObject(i).getRow());
    }
    for (int i = invalidModel.getRowCount(); i-- > 0; ) {
        rows.add(invalidModel.getObject(i).getRow());
    }
    datas.setRows(rows);
    addToRunContext("datas", datas);
    fireEvent(ureq, StepsEvent.ACTIVATE_NEXT);
}
Also used : BulkAssessmentDatas(org.olat.course.assessment.model.BulkAssessmentDatas) ArrayList(java.util.ArrayList) BulkAssessmentRow(org.olat.course.assessment.model.BulkAssessmentRow)

Example 13 with BulkAssessmentDatas

use of org.olat.course.assessment.model.BulkAssessmentDatas in project openolat by klemens.

the class BulkAssessmentOverviewController method doNewBulkAssessment.

private void doNewBulkAssessment(UserRequest ureq) {
    removeAsListenerAndDispose(bulkAssessmentCtrl);
    List<AssessableCourseNode> nodes = new ArrayList<>();
    ICourse course = CourseFactory.loadCourse(courseEntry);
    collectBulkAssessableCourseNode(course.getRunStructure().getRootNode(), nodes);
    Step start;
    if (nodes.size() > 1) {
        start = new BulkAssessment_1_SelectCourseNodeStep(ureq, courseEntry);
    } else if (nodes.size() == 1) {
        start = new BulkAssessment_2_DatasStep(ureq, nodes.get(0));
    } else {
        showWarning("bulk.action.no.coursenodes");
        return;
    }
    StepRunnerCallback finish = new StepRunnerCallback() {

        @Override
        public Step execute(UserRequest uureq, WindowControl wControl, StepsRunContext runContext) {
            Date scheduledDate = (Date) runContext.get("scheduledDate");
            AssessableCourseNode courseNode = (AssessableCourseNode) runContext.get("courseNode");
            BulkAssessmentDatas datas = (BulkAssessmentDatas) runContext.get("datas");
            Feedback feedback = doBulkAssessment(courseNode, scheduledDate, datas);
            runContext.put("feedback", feedback);
            return StepsMainRunController.DONE_MODIFIED;
        }
    };
    bulkAssessmentCtrl = new StepsMainRunController(ureq, getWindowControl(), start, finish, null, translate("bulk.wizard.title"), "o_sel_bulk_assessment_wizard");
    listenTo(bulkAssessmentCtrl);
    getWindowControl().pushAsModalDialog(bulkAssessmentCtrl.getInitialComponent());
}
Also used : ArrayList(java.util.ArrayList) ICourse(org.olat.course.ICourse) 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) Date(java.util.Date) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) BulkAssessmentDatas(org.olat.course.assessment.model.BulkAssessmentDatas) BulkAssessmentFeedback(org.olat.course.assessment.model.BulkAssessmentFeedback) StepsMainRunController(org.olat.core.gui.control.generic.wizard.StepsMainRunController) StepRunnerCallback(org.olat.core.gui.control.generic.wizard.StepRunnerCallback) UserRequest(org.olat.core.gui.UserRequest)

Example 14 with BulkAssessmentDatas

use of org.olat.course.assessment.model.BulkAssessmentDatas in project openolat by klemens.

the class BulkAssessmentOverviewController method doEditBulkAssessment.

private void doEditBulkAssessment(UserRequest ureq, TaskData data) {
    removeAsListenerAndDispose(bulkAssessmentCtrl);
    if (editedTask != null) {
        // only for security purpose
        taskManager.returnTaskAfterEdition(editedTask, null);
    }
    AssessableCourseNode courseNode = data.getCourseNode();
    final Task editableTask = taskManager.pickTaskForEdition(data.getTask());
    editedTask = editableTask;
    if (editableTask == null) {
        showWarning("task.edited");
    } else {
        BulkAssessmentTask runnable = taskManager.getPersistedRunnableTask(editableTask, BulkAssessmentTask.class);
        BulkAssessmentDatas datas = runnable.getDatas();
        Step start = new BulkAssessment_2_DatasStep(ureq, courseNode, datas, editableTask);
        StepRunnerCallback finish = new StepRunnerCallback() {

            @Override
            public Step execute(UserRequest uureq, WindowControl wControl, StepsRunContext runContext) {
                Task task = (Task) runContext.get("task");
                Date scheduledDate = (Date) runContext.get("scheduledDate");
                AssessableCourseNode assessableCourseNode = (AssessableCourseNode) runContext.get("courseNode");
                BulkAssessmentDatas bulkDatas = (BulkAssessmentDatas) runContext.get("datas");
                Feedback feedback = doUpdateBulkAssessment(task, assessableCourseNode, scheduledDate, bulkDatas);
                runContext.put("feedback", feedback);
                editedTask = null;
                return StepsMainRunController.DONE_MODIFIED;
            }
        };
        StepRunnerCallback cancel = new StepRunnerCallback() {

            @Override
            public Step execute(UserRequest uureq, WindowControl wControl, StepsRunContext runContext) {
                taskManager.returnTaskAfterEdition(editableTask, null);
                editedTask = null;
                return Step.NOSTEP;
            }
        };
        bulkAssessmentCtrl = new StepsMainRunController(ureq, getWindowControl(), start, finish, cancel, translate("bulk.wizard.title"), "o_sel_bulk_assessment_wizard");
        listenTo(bulkAssessmentCtrl);
        getWindowControl().pushAsModalDialog(bulkAssessmentCtrl.getInitialComponent());
    }
}
Also used : Task(org.olat.core.commons.services.taskexecutor.Task) BulkAssessmentTask(org.olat.course.assessment.manager.BulkAssessmentTask) 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) Date(java.util.Date) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) BulkAssessmentDatas(org.olat.course.assessment.model.BulkAssessmentDatas) BulkAssessmentFeedback(org.olat.course.assessment.model.BulkAssessmentFeedback) StepsMainRunController(org.olat.core.gui.control.generic.wizard.StepsMainRunController) BulkAssessmentTask(org.olat.course.assessment.manager.BulkAssessmentTask) StepRunnerCallback(org.olat.core.gui.control.generic.wizard.StepRunnerCallback) UserRequest(org.olat.core.gui.UserRequest)

Aggregations

BulkAssessmentDatas (org.olat.course.assessment.model.BulkAssessmentDatas)14 ArrayList (java.util.ArrayList)6 Date (java.util.Date)6 UserRequest (org.olat.core.gui.UserRequest)6 WindowControl (org.olat.core.gui.control.WindowControl)6 Step (org.olat.core.gui.control.generic.wizard.Step)6 StepRunnerCallback (org.olat.core.gui.control.generic.wizard.StepRunnerCallback)6 StepsMainRunController (org.olat.core.gui.control.generic.wizard.StepsMainRunController)6 StepsRunContext (org.olat.core.gui.control.generic.wizard.StepsRunContext)6 BulkAssessmentFeedback (org.olat.course.assessment.model.BulkAssessmentFeedback)6 BulkAssessmentRow (org.olat.course.assessment.model.BulkAssessmentRow)6 AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)4 HashMap (java.util.HashMap)2 OlatRootFolderImpl (org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)2 Task (org.olat.core.commons.services.taskexecutor.Task)2 ICourse (org.olat.course.ICourse)2 BulkAssessmentTask (org.olat.course.assessment.manager.BulkAssessmentTask)2 BulkAssessmentColumnSettings (org.olat.course.assessment.model.BulkAssessmentColumnSettings)2