use of org.olat.course.run.userview.UserCourseEnvironment in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_12_0_0 method processCourseAssessmentLastModified.
private boolean processCourseAssessmentLastModified(RepositoryEntry entry) {
try {
ICourse course = CourseFactory.loadCourse(entry);
CourseNode rootNode = course.getRunStructure().getRootNode();
Set<Identity> changeSet = new HashSet<>();
processCourseNodeAssessmentLastModified(course, entry, rootNode, changeSet);
dbInstance.commitAndCloseSession();
// update structure nodes and efficiency statement if any
Set<Identity> identitiesWithEfficiencyStatements = findIdentitiesWithEfficiencyStatements(entry);
for (Identity assessedIdentity : changeSet) {
UserCourseEnvironment userCourseEnv = AssessmentHelper.createInitAndUpdateUserCourseEnvironment(assessedIdentity, course);
if (identitiesWithEfficiencyStatements.contains(assessedIdentity)) {
efficiencyStatementManager.updateUserEfficiencyStatement(userCourseEnv);
}
dbInstance.commitAndCloseSession();
}
} catch (CorruptedCourseException e) {
log.error("Corrupted course: " + entry.getKey(), e);
} catch (Exception e) {
log.error("Unexpected error", e);
} finally {
dbInstance.commitAndCloseSession();
}
return true;
}
use of org.olat.course.run.userview.UserCourseEnvironment in project OpenOLAT by OpenOLAT.
the class EditCommentController method formOK.
@Override
protected void formOK(UserRequest ureq) {
String comment = commentEl.getValue();
row.setComment(comment);
ICourse course = CourseFactory.loadCourse(courseOres);
UserCourseEnvironment userCourseEnv = row.getUserCourseEnvironment(course);
gtaNode.updateUserUserComment(comment, userCourseEnv, getIdentity());
if (StringHelper.containsNonWhitespace(comment)) {
row.getCommentEditLink().setIconLeftCSS("o_icon o_icon_comments");
} else {
row.getCommentEditLink().setIconLeftCSS("o_icon o_icon_comments_none");
}
fireEvent(ureq, Event.DONE_EVENT);
}
use of org.olat.course.run.userview.UserCourseEnvironment in project OpenOLAT by OpenOLAT.
the class CourseTemplateSearchController method loadModel.
private void loadModel(UserRequest ureq) {
IdentityEnvironment identityEnv = ureq.getUserSession().getIdentityEnvironment();
List<Binder> currentBinders = portfolioService.searchOwnedBindersFromCourseTemplate(getIdentity());
Set<CurrentBinder> currentSet = new HashSet<>();
for (Binder currentBinder : currentBinders) {
Long courseEntryKey = currentBinder.getEntry().getKey();
String nodeIdent = currentBinder.getSubIdent();
currentSet.add(new CurrentBinder(courseEntryKey, nodeIdent));
}
List<RepositoryEntry> entries = portfolioService.searchCourseWithBinderTemplates(getIdentity());
List<CourseTemplateRow> rows = new ArrayList<>(entries.size());
for (RepositoryEntry entry : entries) {
ICourse course = CourseFactory.loadCourse(entry);
UserCourseEnvironment uce = new UserCourseEnvironmentImpl(identityEnv, course.getCourseEnvironment());
uce.getScoreAccounting().evaluateAll();
CourseNode rootNode = uce.getCourseEnvironment().getRunStructure().getRootNode();
loadCourseModel(rootNode, uce, rows, currentSet);
}
model.setObjects(rows);
tableEl.reset();
tableEl.reloadData();
}
use of org.olat.course.run.userview.UserCourseEnvironment in project OpenOLAT by OpenOLAT.
the class PortfolioServiceImpl method updateAssessmentEntry.
private void updateAssessmentEntry(Identity assessedIdentity, Binder binder, Set<AssessmentSection> assessmentSections, Identity coachingIdentity) {
boolean allPassed = true;
int totalSectionPassed = 0;
int totalSectionClosed = 0;
BigDecimal totalScore = new BigDecimal("0.0");
AssessmentEntryStatus binderStatus = null;
for (AssessmentSection assessmentSection : assessmentSections) {
if (assessmentSection.getScore() != null) {
totalScore = totalScore.add(assessmentSection.getScore());
}
if (assessmentSection.getPassed() != null && assessmentSection.getPassed().booleanValue()) {
allPassed &= true;
totalSectionPassed++;
}
Section section = assessmentSection.getSection();
if (section.getSectionStatus() == SectionStatus.closed) {
totalSectionClosed++;
}
}
Boolean totalPassed = null;
if (totalSectionClosed == assessmentSections.size()) {
totalPassed = new Boolean(allPassed);
} else {
if (assessmentSections.size() == totalSectionPassed) {
totalPassed = Boolean.TRUE;
}
binderStatus = AssessmentEntryStatus.inProgress;
}
// order status from the entry / section
RepositoryEntry entry = binder.getEntry();
if ("CourseModule".equals(entry.getOlatResource().getResourceableTypeName())) {
ICourse course = CourseFactory.loadCourse(entry);
CourseNode courseNode = course.getRunStructure().getNode(binder.getSubIdent());
if (courseNode instanceof PortfolioCourseNode) {
PortfolioCourseNode pfNode = (PortfolioCourseNode) courseNode;
ScoreEvaluation scoreEval = new ScoreEvaluation(totalScore.floatValue(), totalPassed, binderStatus, true, true, null, null, binder.getKey());
UserCourseEnvironment userCourseEnv = AssessmentHelper.createAndInitUserCourseEnvironment(assessedIdentity, course);
pfNode.updateUserScoreEvaluation(scoreEval, userCourseEnv, coachingIdentity, false, Role.coach);
}
} else {
OLATResource resource = ((BinderImpl) binder.getTemplate()).getOlatResource();
RepositoryEntry referenceEntry = repositoryService.loadByResourceKey(resource.getKey());
AssessmentEntry assessmentEntry = assessmentService.getOrCreateAssessmentEntry(assessedIdentity, null, binder.getEntry(), binder.getSubIdent(), referenceEntry);
assessmentEntry.setScore(totalScore);
assessmentEntry.setPassed(totalPassed);
assessmentEntry.setAssessmentStatus(binderStatus);
assessmentService.updateAssessmentEntry(assessmentEntry);
}
}
use of org.olat.course.run.userview.UserCourseEnvironment in project OpenOLAT by OpenOLAT.
the class UserCalendarWebService method getCalendar.
private KalendarRenderWrapper getCalendar(UserRequest ureq, String calendarId) {
int typeIndex = calendarId.indexOf('_');
if (typeIndex <= 0 || (typeIndex + 1 >= calendarId.length())) {
return null;
}
CalendarModule calendarModule = CoreSpringFactory.getImpl(CalendarModule.class);
if (!calendarModule.isEnabled()) {
return null;
}
String type = calendarId.substring(0, typeIndex);
String id = calendarId.substring(typeIndex + 1);
KalendarRenderWrapper wrapper = null;
if ("group".equals(type) && calendarModule.isEnableGroupCalendar()) {
Long groupId = Long.parseLong(id);
BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
BusinessGroup group = bgs.loadBusinessGroup(groupId);
if (bgs.isIdentityInBusinessGroup(ureq.getIdentity(), group)) {
CollaborationManager collaborationManager = CoreSpringFactory.getImpl(CollaborationManager.class);
wrapper = collaborationManager.getCalendar(group, ureq, false);
}
} else if ("course".equals(type) && (calendarModule.isEnableCourseElementCalendar() || calendarModule.isEnableCourseToolCalendar())) {
Long courseId = Long.parseLong(id);
IdentityEnvironment ienv = new IdentityEnvironment();
ienv.setIdentity(ureq.getIdentity());
ienv.setRoles(ureq.getUserSession().getRoles());
ICourse course = CourseFactory.loadCourse(courseId);
UserCourseEnvironment userCourseEnv = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
wrapper = CourseCalendars.getCourseCalendarWrapper(ureq, userCourseEnv, null);
} else if ("user".equals(type) && calendarModule.isEnablePersonalCalendar()) {
if (id.equals(ureq.getIdentity().getName())) {
wrapper = getPersonalCalendar(ureq.getIdentity());
} else if (isAdmin(ureq.getHttpReq())) {
Identity identity = BaseSecurityManager.getInstance().findIdentityByName(id);
wrapper = getPersonalCalendar(identity);
}
}
return wrapper;
}
Aggregations