Search in sources :

Example 6 with BulkAssessmentSettings

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

the class ChooseColumnsStepForm method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormTitle("chooseColumns.title");
    setFormDescription("chooseColumns.description");
    setFormContextHelp("Using Course Tools#bulkassessment_map");
    AssessableCourseNode courseNode = (AssessableCourseNode) getFromRunContext("courseNode");
    BulkAssessmentSettings settings = new BulkAssessmentSettings(courseNode);
    String[] usernameKeys = new String[numOfColumns];
    String[] usernameValues = new String[numOfColumns];
    String[] otherKeys = new String[numOfColumns + 1];
    String[] otherValues = new String[numOfColumns + 1];
    for (int i = 0; i < numOfColumns; i++) {
        usernameKeys[i] = "col" + i;
        usernameValues[i] = translate("column", Integer.toString(i + 1));
        otherKeys[i] = "col" + i;
        otherValues[i] = translate("column", Integer.toString(i + 1));
    }
    otherKeys[otherKeys.length - 1] = "col9999";
    otherValues[otherValues.length - 1] = translate("column.dontuse");
    FormLayoutContainer choosersCont = FormLayoutContainer.createDefaultFormLayout("choosers", getTranslator());
    choosersCont.setElementCssClass("o_sel_bulk_assessment_columns");
    choosersCont.setRootForm(mainForm);
    formLayout.add(choosersCont);
    int pos = 0;
    userNameColumnEl = uifactory.addDropdownSingleselect("table.header.identifier", choosersCont, usernameKeys, usernameValues, null);
    if (columnsSettings != null && columnsSettings.getUsernameColumn() < usernameKeys.length) {
        userNameColumnEl.select(getSelectedKey(pos++, columnsSettings.getUsernameColumn(), usernameKeys), true);
    } else if (usernameKeys.length > 0) {
        userNameColumnEl.select(usernameKeys[Math.min(pos++, usernameKeys.length - 1)], true);
    }
    if (settings.isHasScore()) {
        scoreColumnEl = uifactory.addDropdownSingleselect("table.header.score", choosersCont, otherKeys, otherValues, null);
        if (columnsSettings != null && columnsSettings.getScoreColumn() < otherKeys.length) {
            scoreColumnEl.select(getSelectedKey(pos++, columnsSettings.getScoreColumn(), otherKeys), true);
        } else if (otherKeys.length > 0) {
            scoreColumnEl.select(otherKeys[Math.min(pos++, otherKeys.length - 1)], true);
        }
    }
    if (settings.isHasPassed() && settings.getCut() == null) {
        passedColumnEl = uifactory.addDropdownSingleselect("table.header.passed", choosersCont, otherKeys, otherValues, null);
        if (columnsSettings != null && columnsSettings.getPassedColumn() < otherKeys.length) {
            passedColumnEl.select(getSelectedKey(pos++, columnsSettings.getPassedColumn(), otherKeys), true);
        } else if (otherKeys.length > 0) {
            passedColumnEl.select(otherKeys[Math.min(pos++, otherKeys.length - 1)], true);
        }
    }
    if (settings.isHasUserComment()) {
        commentColumnEl = uifactory.addDropdownSingleselect("table.header.comment", choosersCont, otherKeys, otherValues, null);
        if (columnsSettings != null && columnsSettings.getCommentColumn() < otherKeys.length) {
            commentColumnEl.select(getSelectedKey(pos++, columnsSettings.getCommentColumn(), otherKeys), true);
        } else if (otherKeys.length > 0) {
            commentColumnEl.select(otherKeys[Math.min(pos++, otherKeys.length - 1)], true);
        }
    }
    FlexiTableColumnModel tableColumnModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
    for (int i = 0; i < numOfColumns; i++) {
        DefaultFlexiColumnModel colModel = new DefaultFlexiColumnModel("ccc" + (i + 1), i);
        tableColumnModel.addFlexiColumnModel(colModel);
    }
    overviewDataModel.setTableColumnModel(tableColumnModel);
    FlexiTableElement tableEl = uifactory.addTableElement(getWindowControl(), "overviewList", overviewDataModel, getTranslator(), formLayout);
    tableEl.setCustomizeColumns(false);
}
Also used : AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) BulkAssessmentSettings(org.olat.course.assessment.model.BulkAssessmentSettings) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel) FlexiTableElement(org.olat.core.gui.components.form.flexible.elements.FlexiTableElement)

Example 7 with BulkAssessmentSettings

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

the class DataStepForm method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    formLayout.setElementCssClass("o_sel_bulk_assessment_data");
    // hide data input field in case the element does not have any score, passed or comment field enabled
    BulkAssessmentSettings settings = new BulkAssessmentSettings(courseNode);
    boolean onlyReturnFiles = (!settings.isHasScore() && !settings.isHasPassed() && !settings.isHasUserComment());
    setFormTitle("data.title");
    if (!onlyReturnFiles) {
        setFormDescription("data.description");
    }
    setFormContextHelp("Using Course Tools#bulkassessment_data");
    String dataVal = "";
    if (savedDatas != null && StringHelper.containsNonWhitespace(savedDatas.getDataBackupFile())) {
        OlatRootFileImpl file = new OlatRootFileImpl(savedDatas.getDataBackupFile(), null);
        InputStream in = file.getInputStream();
        try {
            dataVal = IOUtils.toString(in, "UTF-8");
        } catch (IOException e) {
            logError("", e);
        } finally {
            IOUtils.closeQuietly(in);
        }
    }
    dataEl = uifactory.addTextAreaElement("data", "data", -1, 6, 60, true, dataVal, formLayout);
    dataEl.showLabel(false);
    String[] values = new String[] { translate("form.step3.delimiter.tab"), translate("form.step3.delimiter.comma") };
    delimiter = uifactory.addRadiosVertical("delimiter", "form.step3.delimiter", formLayout, keys, values);
    // preset delimiter type to first appearance of either tab or comma when data is available, default to tab for no data
    int firstComma = dataVal.indexOf(",");
    int firstTab = dataVal.indexOf("\t");
    if (firstComma > -1 && (firstTab == -1 || firstTab > firstComma)) {
        delimiter.select("comma", true);
    } else {
        delimiter.select("tab", true);
    }
    // hide data input field in case the element does not have any score, passed or comment field enabled
    if (onlyReturnFiles) {
        dataEl.setVisible(false);
        delimiter.setVisible(false);
    }
    // return files only when configured
    if (settings.isHasReturnFiles()) {
        returnFileEl = uifactory.addFileElement(getWindowControl(), "returnfiles", "return.files", formLayout);
        Set<String> mimes = new HashSet<String>();
        mimes.add(WebappHelper.getMimeType("file.zip"));
        returnFileEl.limitToMimeType(mimes, "return.mime", null);
        if (savedDatas != null && StringHelper.containsNonWhitespace(savedDatas.getReturnFiles())) {
            targetArchive = new OlatRootFileImpl(savedDatas.getReturnFiles(), null);
            if (targetArchive.exists()) {
                returnFileEl.setInitialFile(targetArchive.getBasefile());
            }
        }
    }
}
Also used : ZipInputStream(java.util.zip.ZipInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) OlatRootFileImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFileImpl) IOException(java.io.IOException) BulkAssessmentSettings(org.olat.course.assessment.model.BulkAssessmentSettings) HashSet(java.util.HashSet)

Example 8 with BulkAssessmentSettings

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

the class BulkAssessment_2b_ChooseColumnsStep method getStepController.

@Override
public StepFormController getStepController(UserRequest ureq, WindowControl wControl, StepsRunContext context, Form form) {
    // Skip this step if it has only return files
    AssessableCourseNode courseNode = (AssessableCourseNode) context.get("courseNode");
    BulkAssessmentSettings settings = new BulkAssessmentSettings(courseNode);
    boolean onlyReturnFiles = (!settings.isHasScore() && !settings.isHasPassed() && !settings.isHasUserComment());
    if (onlyReturnFiles) {
        return new ChooseColumnsStepSkipForm(ureq, wControl, context, form);
    } else {
        return new ChooseColumnsStepForm(ureq, wControl, savedColumnsSettings, context, form);
    }
}
Also used : AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) BulkAssessmentSettings(org.olat.course.assessment.model.BulkAssessmentSettings)

Aggregations

BulkAssessmentSettings (org.olat.course.assessment.model.BulkAssessmentSettings)8 AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)6 DefaultFlexiColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel)4 FlexiTableColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel)4 FileInputStream (java.io.FileInputStream)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 HashSet (java.util.HashSet)2 ZipInputStream (java.util.zip.ZipInputStream)2 OlatRootFileImpl (org.olat.core.commons.modules.bc.vfs.OlatRootFileImpl)2 FlexiTableElement (org.olat.core.gui.components.form.flexible.elements.FlexiTableElement)2 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)2