use of org.olat.course.assessment.model.BulkAssessmentSettings in project OpenOLAT by OpenOLAT.
the class ValidationStepForm method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
AssessableCourseNode courseNode = (AssessableCourseNode) getFromRunContext("courseNode");
BulkAssessmentSettings settings = new BulkAssessmentSettings(courseNode);
FlexiTableColumnModel tableColumnModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.identifier", Cols.identifier.ordinal()));
tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.lastName", Cols.lastName.ordinal()));
tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.firstName", Cols.firstName.ordinal()));
if (settings.isHasScore()) {
tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.score", Cols.score.ordinal(), new ScoreCellRenderer(settings)));
}
if (settings.isHasPassed() && settings.getCut() == null) {
tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.passed", Cols.passed.ordinal(), new PassedCellRenderer()));
}
if (settings.isHasUserComment()) {
tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.comment", Cols.comment.ordinal()));
}
if (settings.isHasReturnFiles()) {
tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.numOfReturnFiles", Cols.numOfReturnFiles.ordinal()));
}
validModel = new ValidDataModel(Collections.<UserData>emptyList());
validModel.setTableColumnModel(tableColumnModel);
validTableEl = uifactory.addTableElement(getWindowControl(), "validList", validModel, getTranslator(), formLayout);
validTableEl.setCustomizeColumns(false);
invalidModel = new ValidDataModel(Collections.<UserData>emptyList());
invalidModel.setTableColumnModel(tableColumnModel);
invalidTableEl = uifactory.addTableElement(getWindowControl(), "notFoundList", invalidModel, getTranslator(), formLayout);
invalidTableEl.setCustomizeColumns(false);
flc.contextPut("settings", settings);
}
use of org.olat.course.assessment.model.BulkAssessmentSettings in project OpenOLAT by OpenOLAT.
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());
}
}
}
}
use of org.olat.course.assessment.model.BulkAssessmentSettings in project OpenOLAT by OpenOLAT.
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);
}
use of org.olat.course.assessment.model.BulkAssessmentSettings in project openolat by klemens.
the class ValidationStepForm method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
AssessableCourseNode courseNode = (AssessableCourseNode) getFromRunContext("courseNode");
BulkAssessmentSettings settings = new BulkAssessmentSettings(courseNode);
FlexiTableColumnModel tableColumnModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.identifier", Cols.identifier.ordinal()));
tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.lastName", Cols.lastName.ordinal()));
tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.firstName", Cols.firstName.ordinal()));
if (settings.isHasScore()) {
tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.score", Cols.score.ordinal(), new ScoreCellRenderer(settings)));
}
if (settings.isHasPassed() && settings.getCut() == null) {
tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.passed", Cols.passed.ordinal(), new PassedCellRenderer()));
}
if (settings.isHasUserComment()) {
tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.comment", Cols.comment.ordinal()));
}
if (settings.isHasReturnFiles()) {
tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.numOfReturnFiles", Cols.numOfReturnFiles.ordinal()));
}
validModel = new ValidDataModel(Collections.<UserData>emptyList());
validModel.setTableColumnModel(tableColumnModel);
validTableEl = uifactory.addTableElement(getWindowControl(), "validList", validModel, getTranslator(), formLayout);
validTableEl.setCustomizeColumns(false);
invalidModel = new ValidDataModel(Collections.<UserData>emptyList());
invalidModel.setTableColumnModel(tableColumnModel);
invalidTableEl = uifactory.addTableElement(getWindowControl(), "notFoundList", invalidModel, getTranslator(), formLayout);
invalidTableEl.setCustomizeColumns(false);
flc.contextPut("settings", settings);
}
use of org.olat.course.assessment.model.BulkAssessmentSettings in project openolat by klemens.
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);
}
}
Aggregations