use of org.olat.course.run.userview.UserCourseEnvironmentImpl in project OpenOLAT by OpenOLAT.
the class BCCourseNode method getSecurisedNodeFolderContainer.
public static OlatNamedContainerImpl getSecurisedNodeFolderContainer(BCCourseNode node, CourseEnvironment courseEnv, IdentityEnvironment ienv) {
boolean isOlatAdmin = ienv.getRoles().isOLATAdmin();
boolean isGuestOnly = ienv.getRoles().isGuestOnly();
UserCourseEnvironmentImpl uce = new UserCourseEnvironmentImpl(ienv, courseEnv);
NodeEvaluation ne = node.eval(uce.getConditionInterpreter(), new TreeEvaluation(), new VisibleTreeFilter());
OlatNamedContainerImpl container = getNodeFolderContainer(node, courseEnv);
VFSSecurityCallback secCallback = new FolderNodeCallback(container.getRelPath(), ne, isOlatAdmin, isGuestOnly, null);
container.setLocalSecurityCallback(secCallback);
return container;
}
use of org.olat.course.run.userview.UserCourseEnvironmentImpl in project OpenOLAT by OpenOLAT.
the class CheckListCourseNode method updateScorePassedOnPublish.
private void updateScorePassedOnPublish(Identity assessedIdentity, Identity coachIdentity, CheckboxManager checkboxManager, ICourse course) {
AssessmentManager am = course.getCourseEnvironment().getAssessmentManager();
Float currentScore = am.getNodeScore(this, assessedIdentity);
Boolean currentPassed = am.getNodePassed(this, assessedIdentity);
Float updatedScore = null;
Boolean updatedPassed = null;
ModuleConfiguration config = getModuleConfiguration();
Boolean scoreGrantedBool = (Boolean) config.get(MSCourseNode.CONFIG_KEY_HAS_SCORE_FIELD);
if (scoreGrantedBool != null && scoreGrantedBool.booleanValue()) {
updatedScore = checkboxManager.calculateScore(assessedIdentity, course, getIdent());
} else {
updatedScore = null;
}
Boolean passedBool = (Boolean) config.get(MSCourseNode.CONFIG_KEY_HAS_PASSED_FIELD);
if (passedBool != null && passedBool.booleanValue()) {
Float cutValue = (Float) config.get(MSCourseNode.CONFIG_KEY_PASSED_CUT_VALUE);
Boolean sumCheckbox = (Boolean) config.get(CheckListCourseNode.CONFIG_KEY_PASSED_SUM_CHECKBOX);
if (sumCheckbox != null && sumCheckbox.booleanValue()) {
Integer minValue = (Integer) config.get(CheckListCourseNode.CONFIG_KEY_PASSED_SUM_CUTVALUE);
int checkedBox = checkboxManager.countChecked(assessedIdentity, course, getIdent());
if (minValue != null && minValue.intValue() <= checkedBox) {
updatedPassed = Boolean.TRUE;
} else {
updatedPassed = Boolean.FALSE;
}
} else if (cutValue != null) {
if (updatedScore == null) {
updatedScore = checkboxManager.calculateScore(assessedIdentity, course, getIdent());
}
if (updatedScore != null && cutValue.floatValue() <= updatedScore.floatValue()) {
updatedPassed = Boolean.TRUE;
} else {
updatedPassed = Boolean.FALSE;
}
}
} else {
updatedPassed = null;
}
boolean needUpdate = false;
Boolean manualCorrection = (Boolean) config.get(CheckListCourseNode.CONFIG_KEY_PASSED_MANUAL_CORRECTION);
if (manualCorrection == null || !manualCorrection.booleanValue()) {
// update passed
if ((currentPassed == null && updatedPassed != null && updatedScore != null && updatedScore.floatValue() > 0f) || (currentPassed != null && updatedPassed == null) || (currentPassed != null && !currentPassed.equals(updatedPassed))) {
needUpdate = true;
}
}
if ((currentScore == null && updatedScore != null && updatedScore.floatValue() > 0f) || (currentScore != null && updatedScore == null) || (currentScore != null && !currentScore.equals(updatedScore))) {
needUpdate = true;
}
if (needUpdate) {
ScoreEvaluation scoreEval = new ScoreEvaluation(updatedScore, updatedPassed);
IdentityEnvironment identityEnv = new IdentityEnvironment(assessedIdentity, null);
UserCourseEnvironment uce = new UserCourseEnvironmentImpl(identityEnv, course.getCourseEnvironment());
am.saveScoreEvaluation(this, coachIdentity, assessedIdentity, scoreEval, uce, false, Role.coach);
}
}
use of org.olat.course.run.userview.UserCourseEnvironmentImpl in project openolat by klemens.
the class CheckListAssessmentController method loadDatas.
private List<CheckListAssessmentRow> loadDatas() {
if (!(coachCourseEnv instanceof UserCourseEnvironmentImpl)) {
return Collections.emptyList();
}
UserCourseEnvironmentImpl env = (UserCourseEnvironmentImpl) coachCourseEnv;
List<Checkbox> checkboxColl = checkboxList.getList();
int numOfCheckbox = checkboxList.getNumOfCheckbox();
boolean courseAdmin = env.isAdmin();
RepositoryEntry re = env.getCourseRepositoryEntry();
boolean courseTutor = repositoryService.hasRole(getIdentity(), re, GroupRoles.coach.name());
Set<Long> missingIdentityKeys = new HashSet<>();
if (courseTutor || courseAdmin) {
List<RepositoryEntryMembership> repoMemberships = repositoryManager.getRepositoryEntryMembership(re);
for (RepositoryEntryMembership repoMembership : repoMemberships) {
if (repoMembership.isParticipant()) {
missingIdentityKeys.add(repoMembership.getIdentityKey());
}
}
}
List<BusinessGroup> coachedGroups = courseAdmin ? coachCourseEnv.getCourseEnvironment().getCourseGroupManager().getAllBusinessGroups() : env.getCoachedGroups();
List<AssessmentData> dataList = checkboxManager.getAssessmentDatas(courseOres, courseNode.getIdent(), courseTutor || courseAdmin ? re : null, coachedGroups);
List<CheckListAssessmentRow> boxList = getAssessmentDataViews(dataList, checkboxColl);
Map<Long, CheckListAssessmentRow> identityToView = new HashMap<>();
for (CheckListAssessmentRow box : boxList) {
identityToView.put(box.getIdentityKey(), box);
missingIdentityKeys.remove(box.getIdentityKey());
}
List<BusinessGroupMembership> memberships = businessGroupService.getBusinessGroupsMembership(coachedGroups);
for (BusinessGroupMembership membership : memberships) {
if (!membership.isParticipant())
continue;
Long identityKey = membership.getIdentityKey();
if (!identityToView.containsKey(identityKey)) {
missingIdentityKeys.add(identityKey);
}
}
List<Identity> missingIdentities = securityManager.loadIdentityByKeys(missingIdentityKeys);
for (Identity missingIdentity : missingIdentities) {
Boolean[] checked = new Boolean[numOfCheckbox];
Float[] scores = new Float[numOfCheckbox];
CheckListAssessmentRow view = new CheckListAssessmentRow(missingIdentity, checked, scores, null, userPropertyHandlers, getLocale());
identityToView.put(missingIdentity.getKey(), view);
}
for (BusinessGroupMembership membership : memberships) {
if (!membership.isParticipant())
continue;
CheckListAssessmentRow view = identityToView.get(membership.getIdentityKey());
if (view != null) {
view.addGroupKey(membership.getGroupKey());
}
}
List<CheckListAssessmentRow> views = new ArrayList<>();
views.addAll(identityToView.values());
return views;
}
use of org.olat.course.run.userview.UserCourseEnvironmentImpl in project openolat by klemens.
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.UserCourseEnvironmentImpl in project openolat by klemens.
the class FeedMediaDispatcher method hasAccess.
/**
* Verifies the access of an identity to a course node.
*
* @param identity
* @param token
* @param course
* @param node
* @return True if the identity has access to the node in the given course.
* False otherwise.
*/
private boolean hasAccess(Identity identity, String token, ICourse course, CourseNode node) {
boolean hasAccess = false;
final RepositoryManager resMgr = RepositoryManager.getInstance();
final RepositoryEntry repoEntry = resMgr.lookupRepositoryEntry(course, false);
if (allowsGuestAccess(repoEntry)) {
hasAccess = true;
} else {
IdentityEnvironment ienv = new IdentityEnvironment();
ienv.setIdentity(identity);
Roles roles = BaseSecurityManager.getInstance().getRoles(identity);
ienv.setRoles(roles);
UserCourseEnvironment userCourseEnv = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
// Build an evaluation tree
TreeEvaluation treeEval = new TreeEvaluation();
NodeEvaluation nodeEval = node.eval(userCourseEnv.getConditionInterpreter(), treeEval, new VisibleTreeFilter());
if (nodeEval.isVisible() && validAuthentication(identity, token)) {
hasAccess = true;
}
}
return hasAccess;
}
Aggregations