Search in sources :

Example 61 with UserCourseEnvironment

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);
    }
}
Also used : ReadOnlyCallback(org.olat.core.util.vfs.callbacks.ReadOnlyCallback) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) VisibleTreeFilter(org.olat.course.run.userview.VisibleTreeFilter) VFSContainer(org.olat.core.util.vfs.VFSContainer) RepositoryEntry(org.olat.repository.RepositoryEntry) MergeSource(org.olat.core.util.vfs.MergeSource) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) RepositoryEntrySecurity(org.olat.repository.model.RepositoryEntrySecurity) TreeNode(org.olat.core.gui.components.tree.TreeNode) TreeEvaluation(org.olat.course.run.userview.TreeEvaluation) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel) PFCourseNode(org.olat.course.nodes.PFCourseNode) CourseNode(org.olat.course.nodes.CourseNode) BCCourseNode(org.olat.course.nodes.BCCourseNode) NodeEvaluation(org.olat.course.run.userview.NodeEvaluation)

Example 62 with UserCourseEnvironment

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);
}
Also used : UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) Date(java.util.Date)

Example 63 with UserCourseEnvironment

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;
}
Also used : UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) IdentityEnvironment(org.olat.core.id.IdentityEnvironment)

Example 64 with UserCourseEnvironment

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();
}
Also used : BasicLTICourseNode(org.olat.course.nodes.BasicLTICourseNode) ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) ICourse(org.olat.course.ICourse) CourseNode(org.olat.course.nodes.CourseNode) BasicLTICourseNode(org.olat.course.nodes.BasicLTICourseNode) Identity(org.olat.core.id.Identity)

Example 65 with UserCourseEnvironment

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);
}
Also used : BasicLTICourseNode(org.olat.course.nodes.BasicLTICourseNode) ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) ICourse(org.olat.course.ICourse) CourseNode(org.olat.course.nodes.CourseNode) BasicLTICourseNode(org.olat.course.nodes.BasicLTICourseNode) TreeMap(java.util.TreeMap)

Aggregations

UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)158 ICourse (org.olat.course.ICourse)84 Identity (org.olat.core.id.Identity)60 UserCourseEnvironmentImpl (org.olat.course.run.userview.UserCourseEnvironmentImpl)58 IdentityEnvironment (org.olat.core.id.IdentityEnvironment)54 ScoreEvaluation (org.olat.course.run.scoring.ScoreEvaluation)52 CourseNode (org.olat.course.nodes.CourseNode)42 RepositoryEntry (org.olat.repository.RepositoryEntry)42 Test (org.junit.Test)28 AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)24 ConditionInterpreter (org.olat.course.condition.interpreter.ConditionInterpreter)20 CourseEnvironment (org.olat.course.run.environment.CourseEnvironment)16 Roles (org.olat.core.id.Roles)14 AssessmentEntry (org.olat.modules.assessment.AssessmentEntry)14 ArrayList (java.util.ArrayList)12 VFSContainer (org.olat.core.util.vfs.VFSContainer)12 IQTESTCourseNode (org.olat.course.nodes.IQTESTCourseNode)12 OLATResource (org.olat.resource.OLATResource)12 Date (java.util.Date)10 AssessmentManager (org.olat.course.assessment.AssessmentManager)10