use of org.olat.course.run.userview.UserCourseEnvironment in project openolat by klemens.
the class MergedCourseContainer method init.
protected void init(PersistingCourseImpl persistingCourse) {
super.init();
RepositoryEntry courseRe = persistingCourse.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
courseReadOnly = !overrideReadOnly && (courseRe.getRepositoryEntryStatus().isClosed() || courseRe.getRepositoryEntryStatus().isUnpublished());
if (courseReadOnly) {
setLocalSecurityCallback(new ReadOnlyCallback());
}
if (identityEnv == null || identityEnv.getRoles().isOLATAdmin()) {
VFSContainer courseContainer = persistingCourse.getIsolatedCourseFolder();
if (courseReadOnly) {
courseContainer.setLocalSecurityCallback(new ReadOnlyCallback());
}
addContainersChildren(courseContainer, true);
} else {
RepositoryEntry re = persistingCourse.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
RepositoryEntrySecurity reSecurity = RepositoryManager.getInstance().isAllowed(identityEnv.getIdentity(), identityEnv.getRoles(), re);
if (reSecurity.isEntryAdmin()) {
VFSContainer courseContainer = persistingCourse.getIsolatedCourseFolder();
if (courseReadOnly) {
courseContainer.setLocalSecurityCallback(new ReadOnlyCallback());
}
addContainersChildren(courseContainer, true);
}
}
initSharedFolder(persistingCourse);
// add all course building blocks of type BC to a virtual folder
MergeSource nodesContainer = new MergeSource(null, "_courseelementdata");
if (identityEnv == null) {
CourseNode rootNode = persistingCourse.getRunStructure().getRootNode();
addFoldersForAdmin(persistingCourse, nodesContainer, rootNode);
} else {
TreeEvaluation treeEval = new TreeEvaluation();
GenericTreeModel treeModel = new GenericTreeModel();
UserCourseEnvironment userCourseEnv = new UserCourseEnvironmentImpl(identityEnv, persistingCourse.getCourseEnvironment());
CourseNode rootCn = userCourseEnv.getCourseEnvironment().getRunStructure().getRootNode();
NodeEvaluation rootNodeEval = rootCn.eval(userCourseEnv.getConditionInterpreter(), treeEval, new VisibleTreeFilter());
TreeNode treeRoot = rootNodeEval.getTreeNode();
treeModel.setRootNode(treeRoot);
addFolders(persistingCourse, nodesContainer, treeRoot);
}
if (nodesContainer.getItems().size() > 0) {
addContainer(nodesContainer);
}
}
use of org.olat.course.run.userview.UserCourseEnvironment in project openolat by klemens.
the class AssessmentHelper method wrapIdentity.
/**
* Wraps an identity and it's score evaluation / attempts in a wrapper object
* for a given course node
*
* @param identity
* @param localUserCourseEnvironmentCache
* @param course the course
* @param courseNode an assessable course node or null if no details and
* attempts must be fetched
* @return a wrapped identity
*/
public static AssessedIdentityWrapper wrapIdentity(Identity identity, Map<Long, UserCourseEnvironment> localUserCourseEnvironmentCache, Map<Long, Date> initialLaunchDates, ICourse course, AssessableCourseNode courseNode) {
// Try to get user course environment from local hash map cache. If not
// successful
// create the environment and add it to the map for later performance
// optimization
UserCourseEnvironment uce = localUserCourseEnvironmentCache.get(identity.getKey());
if (uce == null) {
uce = createAndInitUserCourseEnvironment(identity, course);
// add to cache for later usage
localUserCourseEnvironmentCache.put(identity.getKey(), uce);
if (log.isDebug()) {
log.debug("localUserCourseEnvironmentCache hit failed, adding course environment for user::" + identity.getName());
}
}
Date initialLaunchDate = initialLaunchDates.get(identity.getKey());
return wrapIdentity(uce, initialLaunchDate, courseNode);
}
use of org.olat.course.run.userview.UserCourseEnvironment in project openolat by klemens.
the class AssessmentHelper method createAndInitUserCourseEnvironment.
public static UserCourseEnvironment createAndInitUserCourseEnvironment(Identity identity, CourseEnvironment courseEnv) {
// create an identenv with no roles, no attributes, no locale
IdentityEnvironment ienv = new IdentityEnvironment();
ienv.setIdentity(identity);
UserCourseEnvironment uce = new UserCourseEnvironmentImpl(ienv, courseEnv);
// Fetch all score and passed and calculate score accounting for the entire
// course
uce.getScoreAccounting().evaluateAll();
return uce;
}
use of org.olat.course.run.userview.UserCourseEnvironment in project openolat by klemens.
the class CourseNodeOutcomeMapper method doDeleteResult.
@Override
protected boolean doDeleteResult() {
ICourse course = CourseFactory.loadCourse(courseOresId);
CourseNode node = course.getRunStructure().getNode(courseNodeId);
if (node instanceof BasicLTICourseNode) {
BasicLTICourseNode ltiNode = (BasicLTICourseNode) node;
Identity assessedId = getIdentity();
ScoreEvaluation eval = new ScoreEvaluation(0.0f, false);
UserCourseEnvironment userCourseEnv = getUserCourseEnvironment(course);
ltiNode.updateUserScoreEvaluation(eval, userCourseEnv, assessedId, false, Role.user);
}
return super.doDeleteResult();
}
use of org.olat.course.run.userview.UserCourseEnvironment in project openolat by klemens.
the class CourseNodeOutcomeMapper method doReadResult.
@Override
protected String doReadResult(IMSPOXRequest pox) {
ICourse course = CourseFactory.loadCourse(courseOresId);
CourseNode node = course.getRunStructure().getNode(courseNodeId);
if (node instanceof BasicLTICourseNode) {
BasicLTICourseNode ltiNode = (BasicLTICourseNode) node;
UserCourseEnvironment userCourseEnv = getUserCourseEnvironment(course);
ScoreEvaluation eval = ltiNode.getUserScoreEvaluation(userCourseEnv);
String score = "";
if (eval != null && eval.getScore() != null) {
float scaledScore = eval.getScore();
if (scaledScore > 0.0f) {
float scale = getScalingFactor(ltiNode);
scaledScore = scaledScore / scale;
}
score = Float.toString(scaledScore);
}
Map<String, Object> theMap = new TreeMap<String, Object>();
theMap.put("/readResultResponse/result/sourcedId", getSourcedId());
theMap.put("/readResultResponse/result/resultScore/textString", score);
theMap.put("/readResultResponse/result/resultScore/language", "en");
String theXml = XMLMap.getXMLFragment(theMap, true);
return pox.getResponseSuccess("Result read", theXml);
}
return super.doReadResult(pox);
}
Aggregations