use of org.olat.core.id.Identity in project OpenOLAT by OpenOLAT.
the class ReturnboxFullAccessCallback method event.
/**
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest, org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
*/
@Override
public void event(UserRequest ureq, Controller source, Event event) {
if (source == dropboxFolderRunController) {
if (event instanceof FolderEvent) {
FolderEvent folderEvent = (FolderEvent) event;
if (folderEvent.getCommand().equals(FolderEvent.DELETE_EVENT)) {
UserNodeAuditManager am = userCourseEnv.getCourseEnvironment().getAuditManager();
// log entry for this file
Identity coach = ureq.getIdentity();
Identity student = userCourseEnv.getIdentityEnvironment().getIdentity();
am.appendToUserNodeLog(node, coach, student, "FILE DELETED: " + folderEvent.getFilename());
}
}
} else if (source == returnboxFolderRunController) {
if (event instanceof FolderEvent) {
FolderEvent folderEvent = (FolderEvent) event;
if (folderEvent.getCommand().equals(FolderEvent.UPLOAD_EVENT) || folderEvent.getCommand().equals(FolderEvent.NEW_FILE_EVENT)) {
UserNodeAuditManager am = userCourseEnv.getCourseEnvironment().getAuditManager();
// log entry for this file
Identity coach = ureq.getIdentity();
Identity student = userCourseEnv.getIdentityEnvironment().getIdentity();
if (node instanceof AssessableCourseNode) {
AssessableCourseNode acn = (AssessableCourseNode) node;
AssessmentEvaluation eval = acn.getUserScoreEvaluation(userCourseEnv);
if (eval.getAssessmentStatus() == null || eval.getAssessmentStatus() == AssessmentEntryStatus.notStarted) {
eval = new AssessmentEvaluation(eval, AssessmentEntryStatus.inProgress);
acn.updateUserScoreEvaluation(eval, userCourseEnv, coach, false, Role.coach);
}
}
am.appendToUserNodeLog(node, coach, student, "FILE UPLOADED: " + folderEvent.getFilename());
String toMail = UserManager.getInstance().getUserDisplayEmail(student, ureq.getLocale());
OLATResourceable ores = OresHelper.createOLATResourceableInstance(CourseNode.class, Long.valueOf(node.getIdent()));
ContextEntry ce = BusinessControlFactory.getInstance().createContextEntry(ores);
BusinessControl bc = BusinessControlFactory.getInstance().createBusinessControl(ce, getWindowControl().getBusinessControl());
String link = BusinessControlFactory.getInstance().getAsURIString(bc, true);
log.debug("DEBUG : Returnbox notification email with link=" + link);
String subject = translate("returnbox.email.subject");
String body = translate("returnbox.email.body", new String[] { userCourseEnv.getCourseEnvironment().getCourseTitle(), node.getShortTitle(), folderEvent.getFilename(), link });
MailContext context = new MailContextImpl(getWindowControl().getBusinessControl().getAsString());
MailBundle bundle = new MailBundle();
bundle.setContext(context);
bundle.setToId(student);
bundle.setContent(subject, body);
MailerResult result = CoreSpringFactory.getImpl(MailManager.class).sendMessage(bundle);
if (result.getReturnCode() > 0) {
am.appendToUserNodeLog(node, coach, student, "MAIL SEND FAILED TO:" + toMail + "; MailReturnCode: " + result.getReturnCode());
log.warn("Could not send email 'returnbox notification' to " + student + "with email=" + toMail);
} else {
log.info("Send email 'returnbox notification' to " + student + "with email=" + toMail);
}
}
} else if (FolderCommand.FOLDERCOMMAND_FINISHED == event) {
if (node instanceof AssessableCourseNode) {
AssessableCourseNode acn = (AssessableCourseNode) node;
AssessmentEvaluation eval = acn.getUserScoreEvaluation(userCourseEnv);
if (eval == null) {
eval = AssessmentEvaluation.EMPTY_EVAL;
}
if (eval.getAssessmentStatus() == null || eval.getAssessmentStatus() == AssessmentEntryStatus.notStarted) {
eval = new AssessmentEvaluation(eval, AssessmentEntryStatus.inProgress);
acn.updateUserScoreEvaluation(eval, userCourseEnv, getIdentity(), false, Role.coach);
fireEvent(ureq, Event.CHANGED_EVENT);
}
}
}
} else if (source == statusForm) {
if (event == Event.DONE_EVENT) {
// get identity not from request (this would be an author)
StatusManager.getInstance().saveStatusFormData(statusForm, node, userCourseEnv);
}
} else if (source == dialogBoxController) {
if (DialogBoxUIFactory.isYesEvent(event) && assignedTask != null) {
// cancel task assignment, and show "no task assigned to user"
removeAssignedTask(userCourseEnv, userCourseEnv.getIdentityEnvironment().getIdentity());
// update UI
myContent.contextPut("assignedtask", null);
}
}
}
use of org.olat.core.id.Identity in project OpenOLAT by OpenOLAT.
the class StatusManager method saveStatusFormData.
public void saveStatusFormData(StatusForm statusForm, CourseNode node, UserCourseEnvironment userCourseEnv) {
Identity identity = userCourseEnv.getIdentityEnvironment().getIdentity();
String selectedKey = statusForm.getSelectedStatus();
CoursePropertyManager cpm = userCourseEnv.getCourseEnvironment().getCoursePropertyManager();
Property statusProperty;
statusProperty = cpm.findCourseNodeProperty(node, identity, null, PROPERTY_KEY_STATUS);
if (statusProperty == null) {
statusProperty = cpm.createCourseNodePropertyInstance(node, identity, null, PROPERTY_KEY_STATUS, null, null, selectedKey, null);
cpm.saveProperty(statusProperty);
} else {
statusProperty.setStringValue(selectedKey);
cpm.updateProperty(statusProperty);
}
}
use of org.olat.core.id.Identity in project OpenOLAT by OpenOLAT.
the class AttemptsRuleSPI method filter.
@Override
public void filter(RepositoryEntry entry, List<Identity> identities, ReminderRule rule) {
if (rule instanceof ReminderRuleImpl) {
ReminderRuleImpl r = (ReminderRuleImpl) rule;
String nodeIdent = r.getLeftOperand();
String operator = r.getOperator();
int value = Integer.parseInt(r.getRightOperand());
ICourse course = CourseFactory.loadCourse(entry);
CourseNode courseNode = course.getRunStructure().getNode(nodeIdent);
if (courseNode == null) {
identities.clear();
log.error("Attempts rule in course " + entry.getKey() + " (" + entry.getDisplayname() + ") is missing a course element");
return;
}
Map<Long, Integer> attempts = helperDao.getAttempts(entry, courseNode, identities);
for (Iterator<Identity> identityIt = identities.iterator(); identityIt.hasNext(); ) {
Identity identity = identityIt.next();
Integer attempt = attempts.get(identity.getKey());
if (attempt == null) {
attempt = 0;
}
if (!evaluateAttempt(attempt.intValue(), operator, value)) {
identityIt.remove();
}
}
}
}
use of org.olat.core.id.Identity in project OpenOLAT by OpenOLAT.
the class BinderAssessmentController method loadModel.
private void loadModel() {
List<AssessmentSection> aSections = portfolioService.getAssessmentSections(binder, null);
Map<Section, AssessmentSection> aSectionsMap = new HashMap<>();
for (AssessmentSection aSection : aSections) {
aSectionsMap.put(aSection.getSection(), aSection);
}
// binder done only is an owner is present
// and all owners have done the binder
boolean binderDone = false;
List<Identity> assessedIdentities = portfolioService.getMembers(binder, PortfolioRoles.owner.name());
int countDone = 0;
for (Identity assessedIdentity : assessedIdentities) {
AssessmentEntryStatus status = portfolioService.getAssessmentStatus(assessedIdentity, binder);
if (status == AssessmentEntryStatus.done) {
countDone++;
}
}
binderDone = (countDone > 0 && countDone == assessedIdentities.size());
boolean allClosed = true;
List<Section> sections = portfolioService.getSections(binder);
List<AssessmentSectionWrapper> rows = new ArrayList<>();
Map<Section, AssessmentSectionWrapper> sectionToRows = new HashMap<>();
for (Section section : sections) {
AssessmentSection assessmentSection = aSectionsMap.get(section);
AssessmentSectionWrapper row = new AssessmentSectionWrapper(section, assessmentSection);
sectionToRows.put(section, row);
if (secCallback.canViewAssess(section) || secCallback.canAssess(section)) {
rows.add(row);
}
allClosed &= section.getSectionStatus() == SectionStatus.closed;
}
List<Page> pages = portfolioService.getPages(binder, null);
for (Page page : pages) {
AssessmentSectionWrapper row = sectionToRows.get(page.getSection());
if (row != null) {
row.setNumOfPages(row.getNumOfPages() + 1);
}
}
boolean allowedToAssess = false;
boolean allowedToAssessBinder = secCallback.canAssess(binder);
for (AssessmentSectionWrapper row : rows) {
boolean canAssess = secCallback.canAssess(row.getSection());
if (canAssess && !binderDone) {
forgeAssessmentSection(row);
allowedToAssess = true;
}
}
reopenLink.setVisible(allowedToAssessBinder && binderDone);
saveAndDoneLink.setVisible(allowedToAssessBinder && !binderDone && allClosed);
saveButton.setVisible(allowedToAssess);
cancelButton.setVisible(allowedToAssess);
model.setObjects(rows);
tableEl.reset();
tableEl.reloadData();
}
use of org.olat.core.id.Identity in project OpenOLAT by OpenOLAT.
the class BinderAssessmentController method commitChanges.
private void commitChanges() {
List<AssessmentSectionWrapper> rows = model.getObjects();
List<Identity> assessedIdentities = portfolioService.getMembers(binder, PortfolioRoles.owner.name());
List<AssessmentSectionChange> changes = new ArrayList<>();
for (AssessmentSectionWrapper row : rows) {
Section section = row.getSection();
if (secCallback.canAssess(section) && !SectionStatus.isClosed(section)) {
BigDecimal score = null;
if (withScore) {
String value = row.getScoreEl().getValue();
if (StringHelper.containsNonWhitespace(value)) {
score = new BigDecimal(value);
}
}
Boolean passed = null;
if (withPassed) {
passed = row.getPassedEl().isSelected(0);
}
for (Identity assessedIdentity : assessedIdentities) {
changes.add(new AssessmentSectionChange(assessedIdentity, row.getSection(), row.getAssessmentSection(), score, passed));
}
}
}
portfolioService.updateAssessmentSections(binder, changes, getIdentity());
}
Aggregations