use of org.olat.course.ICourse in project OpenOLAT by OpenOLAT.
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());
}
use of org.olat.course.ICourse in project OpenOLAT by OpenOLAT.
the class AssessmentModule method prepareUpdate.
private void prepareUpdate(Long resId) {
boolean recalc = false;
synchronized (upcomingWork) {
// o_clusterOK by:ld synchronized OK - only one cluster node must update the EfficiencyStatements (the course is locked for editing) (same as e.g. file indexer)
recalc = upcomingWork.contains(resId);
if (recalc) {
for (; upcomingWork.remove(resId); ) {
// remove all with the same res id
}
}
}
if (recalc) {
ICourse pubCourse = CourseFactory.loadCourse(resId);
UpdateEfficiencyStatementsWorker worker = new UpdateEfficiencyStatementsWorker(pubCourse);
taskExecutorManager.execute(worker);
}
}
use of org.olat.course.ICourse in project OpenOLAT by OpenOLAT.
the class CourseAssessmentManagerImpl method addIndividualAssessmentDocument.
@Override
public void addIndividualAssessmentDocument(CourseNode courseNode, Identity identity, Identity assessedIdentity, File document, String filename) {
if (document == null)
return;
if (!StringHelper.containsNonWhitespace(filename)) {
filename = document.getName();
}
try {
File directory = getAssessmentDocumentsDirectory(courseNode, assessedIdentity);
File targetFile = new File(directory, filename);
if (targetFile.exists()) {
String newName = FileUtils.rename(targetFile);
targetFile = new File(directory, newName);
}
Files.copy(document.toPath(), targetFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
// update counter
AssessmentEntry nodeAssessment = getOrCreate(assessedIdentity, courseNode);
File[] docs = directory.listFiles(new SystemFileFilter(true, false));
int numOfDocs = docs == null ? 0 : docs.length;
nodeAssessment.setNumberOfAssessmentDocuments(numOfDocs);
assessmentService.updateAssessmentEntry(nodeAssessment);
// node log
ICourse course = CourseFactory.loadCourse(cgm.getCourseEntry());
UserNodeAuditManager am = course.getCourseEnvironment().getAuditManager();
am.appendToUserNodeLog(courseNode, identity, assessedIdentity, "assessment document added: " + filename);
// user activity logging
ThreadLocalUserActivityLogger.log(AssessmentLoggingAction.ASSESSMENT_DOCUMENT_ADDED, getClass(), LoggingResourceable.wrap(assessedIdentity), LoggingResourceable.wrapNonOlatResource(StringResourceableType.assessmentDocument, "", StringHelper.stripLineBreaks(filename)));
} catch (IOException e) {
log.error("", e);
}
}
use of org.olat.course.ICourse in project OpenOLAT by OpenOLAT.
the class CourseAssessmentManagerImpl method incrementNodeAttempts.
@Override
public void incrementNodeAttempts(CourseNode courseNode, Identity assessedIdentity, UserCourseEnvironment userCourseEnv, Role by) {
ICourse course = CourseFactory.loadCourse(cgm.getCourseEntry());
AssessmentEntry nodeAssessment = getOrCreate(assessedIdentity, courseNode);
int attempts = nodeAssessment.getAttempts() == null ? 1 : nodeAssessment.getAttempts().intValue() + 1;
nodeAssessment.setAttempts(attempts);
if (by == Role.coach) {
nodeAssessment.setLastCoachModified(new Date());
} else if (by == Role.user) {
nodeAssessment.setLastUserModified(new Date());
}
assessmentService.updateAssessmentEntry(nodeAssessment);
DBFactory.getInstance().commit();
userCourseEnv.getScoreAccounting().evaluateAll(true);
DBFactory.getInstance().commit();
if (courseNode instanceof AssessableCourseNode) {
// Update users efficiency statement
efficiencyStatementManager.updateUserEfficiencyStatement(userCourseEnv);
}
// notify about changes
AssessmentChangedEvent ace = new AssessmentChangedEvent(AssessmentChangedEvent.TYPE_ATTEMPTS_CHANGED, assessedIdentity);
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(ace, course);
// user activity logging
ThreadLocalUserActivityLogger.log(AssessmentLoggingAction.ASSESSMENT_ATTEMPTS_UPDATED, getClass(), LoggingResourceable.wrap(assessedIdentity), LoggingResourceable.wrapNonOlatResource(StringResourceableType.qtiAttempts, "", String.valueOf(attempts)));
}
use of org.olat.course.ICourse in project OpenOLAT by OpenOLAT.
the class CourseAssessmentManagerImpl method incrementNodeAttemptsInBackground.
@Override
public void incrementNodeAttemptsInBackground(CourseNode courseNode, Identity assessedIdentity, UserCourseEnvironment userCourseEnv) {
ICourse course = CourseFactory.loadCourse(cgm.getCourseEntry());
AssessmentEntry nodeAssessment = getOrCreate(assessedIdentity, courseNode);
int attempts = nodeAssessment.getAttempts() == null ? 1 : nodeAssessment.getAttempts().intValue() + 1;
nodeAssessment.setAttempts(attempts);
assessmentService.updateAssessmentEntry(nodeAssessment);
if (courseNode instanceof AssessableCourseNode) {
// Update users efficiency statement
efficiencyStatementManager.updateUserEfficiencyStatement(userCourseEnv);
}
// notify about changes
AssessmentChangedEvent ace = new AssessmentChangedEvent(AssessmentChangedEvent.TYPE_ATTEMPTS_CHANGED, assessedIdentity);
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(ace, course);
}
Aggregations