use of org.olat.course.assessment.model.BulkAssessmentRow in project OpenOLAT by OpenOLAT.
the class ValidationStepForm method doValidateRows.
private void doValidateRows(BulkAssessmentDatas datas) {
List<BulkAssessmentRow> rows = datas.getRows();
List<String> assessedIdList = new ArrayList<String>(rows.size());
for (BulkAssessmentRow row : rows) {
assessedIdList.add(row.getAssessedId());
}
Map<String, Identity> idToIdentityMap = loadAssessedIdentities(assessedIdList);
List<UserData> validDatas = new ArrayList<UserData>(idToIdentityMap.size());
List<UserData> invalidDatas = new ArrayList<UserData>(rows.size() - idToIdentityMap.size());
for (BulkAssessmentRow row : datas.getRows()) {
Identity foundIdentity = idToIdentityMap.get(row.getAssessedId());
if (foundIdentity == null) {
invalidDatas.add(new UserData(row, null));
} else {
row.setIdentityKey(foundIdentity.getKey());
validDatas.add(new UserData(row, foundIdentity));
}
}
validModel.setObjects(validDatas);
invalidModel.setObjects(invalidDatas);
flc.contextPut("hasValidItems", Boolean.valueOf(validDatas.size() > 0));
flc.contextPut("hasInvalidItems", Boolean.valueOf(invalidDatas.size() > 0));
validTableEl.reset();
invalidTableEl.reset();
}
use of org.olat.course.assessment.model.BulkAssessmentRow in project OpenOLAT by OpenOLAT.
the class DataStepForm method processReturnFiles.
private void processReturnFiles(VFSLeaf target, List<BulkAssessmentRow> rows) {
Map<String, BulkAssessmentRow> assessedIdToRow = new HashMap<>();
for (BulkAssessmentRow row : rows) {
assessedIdToRow.put(row.getAssessedId(), row);
}
if (target.exists()) {
InputStream is = target.getInputStream();
File parentTarget = ((LocalImpl) target).getBasefile().getParentFile();
ZipInputStream zis = new ZipInputStream(is);
ZipEntry entry;
try {
byte[] b = new byte[FileUtils.BSIZE];
while ((entry = zis.getNextEntry()) != null) {
if (!entry.isDirectory()) {
while (zis.read(b) > 0) {
// continue
}
Path op = new File(parentTarget, entry.getName()).toPath();
if (!Files.isHidden(op) && !Files.isDirectory(op)) {
Path parentDir = op.getParent();
String assessedId = parentDir.getFileName().toString();
String filename = op.getFileName().toString();
BulkAssessmentRow row;
if (assessedIdToRow.containsKey(assessedId)) {
row = assessedIdToRow.get(assessedId);
} else {
row = new BulkAssessmentRow();
row.setAssessedId(assessedId);
assessedIdToRow.put(assessedId, row);
rows.add(row);
}
if (row.getReturnFiles() == null) {
row.setReturnFiles(new ArrayList<String>(2));
}
row.getReturnFiles().add(filename);
}
}
}
} catch (Exception e) {
logError("", e);
} finally {
IOUtils.closeQuietly(is);
IOUtils.closeQuietly(zis);
}
}
}
use of org.olat.course.assessment.model.BulkAssessmentRow in project OpenOLAT by OpenOLAT.
the class ChooseColumnsStepForm method formOK.
@Override
protected void formOK(UserRequest ureq) {
BulkAssessmentDatas datas = (BulkAssessmentDatas) getFromRunContext("datas");
List<BulkAssessmentRow> rows = datas.getRows();
Map<String, BulkAssessmentRow> assessedIdToRow = new HashMap<>();
for (BulkAssessmentRow row : rows) {
assessedIdToRow.put(row.getAssessedId(), row);
}
BulkAssessmentColumnSettings settings = datas.getColumnsSettings();
if (settings == null) {
settings = new BulkAssessmentColumnSettings();
datas.setColumnsSettings(settings);
}
settings.setUsernameColumn(getColumnPosition(userNameColumnEl));
settings.setScoreColumn(getColumnPosition(scoreColumnEl));
settings.setPassedColumn(getColumnPosition(passedColumnEl));
settings.setCommentColumn(getColumnPosition(commentColumnEl));
List<String[]> splittedRows = overviewDataModel.getObjects();
for (String[] values : splittedRows) {
createRow(values, settings, rows, assessedIdToRow);
}
fireEvent(ureq, StepsEvent.ACTIVATE_NEXT);
}
use of org.olat.course.assessment.model.BulkAssessmentRow in project openolat by klemens.
the class BulkAssessmentTask method doProcess.
private void doProcess(List<BulkAssessmentFeedback> feedbacks) {
final DB dbInstance = DBFactory.getInstance();
final BaseSecurity securityManager = CoreSpringFactory.getImpl(BaseSecurity.class);
final Identity coachIdentity = securityManager.loadIdentityByKey(coachedIdentity);
final ICourse course = CourseFactory.loadCourse(courseRes);
final AssessableCourseNode courseNode = getCourseNode();
final Roles studentRoles = new Roles(false, false, false, false, false, false, false, false);
final boolean hasUserComment = courseNode.hasCommentConfigured();
final boolean hasScore = courseNode.hasScoreConfigured();
final boolean hasPassed = courseNode.hasPassedConfigured();
final boolean hasReturnFiles = (StringHelper.containsNonWhitespace(datas.getReturnFiles()) && (courseNode instanceof TACourseNode || courseNode instanceof GTACourseNode));
if (hasReturnFiles) {
try {
OlatRootFileImpl returnFilesZipped = new OlatRootFileImpl(datas.getReturnFiles(), null);
String tmp = FolderConfig.getCanonicalTmpDir();
unzipped = new File(tmp, UUID.randomUUID().toString() + File.separatorChar);
unzipped.mkdirs();
ZipUtil.unzip(returnFilesZipped.getBasefile(), unzipped);
} catch (Exception e) {
log.error("Cannot unzip the return files during bulk assessment", e);
}
}
Float min = null;
Float max = null;
Float cut = null;
if (hasScore) {
min = courseNode.getMinScoreConfiguration();
max = courseNode.getMaxScoreConfiguration();
}
if (hasPassed) {
cut = courseNode.getCutValueConfiguration();
}
int count = 0;
List<BulkAssessmentRow> rows = datas.getRows();
for (BulkAssessmentRow row : rows) {
Long identityKey = row.getIdentityKey();
if (identityKey == null) {
feedbacks.add(new BulkAssessmentFeedback("bulk.action.no.such.user", row.getAssessedId()));
// nothing to do
continue;
}
Identity identity = securityManager.loadIdentityByKey(identityKey);
IdentityEnvironment ienv = new IdentityEnvironment(identity, studentRoles);
UserCourseEnvironment uce = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
// update comment, empty string will reset comment
String userComment = row.getComment();
if (hasUserComment && userComment != null) {
// Update userComment in db
courseNode.updateUserUserComment(userComment, uce, coachIdentity);
// LD: why do we have to update the efficiency statement?
// EfficiencyStatementManager esm = EfficiencyStatementManager.getInstance();
// esm.updateUserEfficiencyStatement(uce);
}
// update score
Float score = row.getScore();
if (hasScore && score != null) {
// score < minimum score
if ((min != null && score.floatValue() < min.floatValue()) || (score.floatValue() < AssessmentHelper.MIN_SCORE_SUPPORTED)) {
// "bulk.action.lessThanMin";
} else // score > maximum score
if ((max != null && score.floatValue() > max.floatValue()) || (score.floatValue() > AssessmentHelper.MAX_SCORE_SUPPORTED)) {
// "bulk.action.greaterThanMax";
} else {
// score between minimum and maximum score
ScoreEvaluation se;
if (hasPassed && cut != null) {
Boolean passed = (score.floatValue() >= cut.floatValue()) ? Boolean.TRUE : Boolean.FALSE;
se = new ScoreEvaluation(score, passed);
} else {
se = new ScoreEvaluation(score, null);
}
// Update score,passed properties in db, and the user's efficiency statement
courseNode.updateUserScoreEvaluation(se, uce, coachIdentity, false, Role.auto);
}
}
Boolean passed = row.getPassed();
if (hasPassed && passed != null && cut == null) {
// Configuration of manual assessment --> Display passed/not passed: yes, Type of display: Manual by tutor
ScoreEvaluation seOld = courseNode.getUserScoreEvaluation(uce);
Float oldScore = seOld.getScore();
ScoreEvaluation se = new ScoreEvaluation(oldScore, passed);
// Update score,passed properties in db, and the user's efficiency statement
boolean incrementAttempts = false;
courseNode.updateUserScoreEvaluation(se, uce, coachIdentity, incrementAttempts, Role.auto);
}
boolean identityHasReturnFile = false;
if (hasReturnFiles && row.getReturnFiles() != null && row.getReturnFiles().size() > 0) {
String assessedId = row.getAssessedId();
File assessedFolder = new File(unzipped, assessedId);
identityHasReturnFile = assessedFolder.exists();
if (identityHasReturnFile) {
processReturnFile(courseNode, row, uce, assessedFolder);
}
}
if (courseNode instanceof GTACourseNode) {
// push the state further
GTACourseNode gtaNode = (GTACourseNode) courseNode;
if ((hasScore && score != null) || (hasPassed && passed != null)) {
// pushed to graded
updateTasksState(gtaNode, uce, TaskProcess.grading);
} else if (hasReturnFiles) {
// push to revised
updateTasksState(gtaNode, uce, TaskProcess.correction);
}
}
if (count++ % 5 == 0) {
dbInstance.commitAndCloseSession();
} else {
dbInstance.commit();
}
}
}
use of org.olat.course.assessment.model.BulkAssessmentRow in project openolat by klemens.
the class ChooseColumnsStepForm method formOK.
@Override
protected void formOK(UserRequest ureq) {
BulkAssessmentDatas datas = (BulkAssessmentDatas) getFromRunContext("datas");
List<BulkAssessmentRow> rows = datas.getRows();
Map<String, BulkAssessmentRow> assessedIdToRow = new HashMap<>();
for (BulkAssessmentRow row : rows) {
assessedIdToRow.put(row.getAssessedId(), row);
}
BulkAssessmentColumnSettings settings = datas.getColumnsSettings();
if (settings == null) {
settings = new BulkAssessmentColumnSettings();
datas.setColumnsSettings(settings);
}
settings.setUsernameColumn(getColumnPosition(userNameColumnEl));
settings.setScoreColumn(getColumnPosition(scoreColumnEl));
settings.setPassedColumn(getColumnPosition(passedColumnEl));
settings.setCommentColumn(getColumnPosition(commentColumnEl));
List<String[]> splittedRows = overviewDataModel.getObjects();
for (String[] values : splittedRows) {
createRow(values, settings, rows, assessedIdToRow);
}
fireEvent(ureq, StepsEvent.ACTIVATE_NEXT);
}
Aggregations