Package org.olat.course.run.userview

Examples of org.olat.course.run.userview.NodeEvaluation


      Roles roles = ManagerFactory.getManager().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);
      if (nodeEval.isVisible() && validAuthentication(identity, token)) {
        hasAccess = true;
      }
    }
    return hasAccess;
  }
View Full Code Here


    String nodeIdS = nodeId.toString();
    CourseNode courseNode = course.getRunStructure().getNode(nodeIdS);
    if (log.isDebug()) log.debug("courseNode=" + courseNode );
   
    TreeEvaluation treeEval = new TreeEvaluation();
    NodeEvaluation rootNodeEval = rootCn.eval(userCourseEnv.getConditionInterpreter(), treeEval);
    if (log.isDebug()) log.debug("rootNodeEval=" + rootNodeEval );

    TreeNode newCalledTreeNode = treeEval.getCorrespondingTreeNode(courseNode);
    if (newCalledTreeNode == null) {
      // TreeNode no longer visible
      return false;
    }
    // go further
    NodeEvaluation nodeEval = (NodeEvaluation) newCalledTreeNode.getUserObject();
    if (log.isDebug()) log.debug("nodeEval=" + nodeEval );
    if (nodeEval.getCourseNode() != courseNode) throw new AssertException("error in structure");
    if (!nodeEval.isVisible()) throw new AssertException("node eval not visible!!");
    if (log.isDebug()) log.debug("call mayAccessWholeTreeUp..." );
    boolean mayAccessWholeTreeUp = NavigationHandler.mayAccessWholeTreeUp(nodeEval)
    if (log.isDebug()) log.debug("call mayAccessWholeTreeUp=" + mayAccessWholeTreeUp );
   
    if (mayAccessWholeTreeUp) {
View Full Code Here

      // course
      ICourse course = CourseFactory.loadCourse(repositoryEntry.getOlatResource());
      CourseNode rootNode = course.getRunStructure().getRootNode();
      UserCourseEnvironmentImpl uce = new UserCourseEnvironmentImpl(ureq.getUserSession().getIdentityEnvironment(), course
          .getCourseEnvironment());
      NodeEvaluation nodeEval = rootNode.eval(uce.getConditionInterpreter(), new TreeEvaluation());
      boolean mayAccessWholeTreeUp = NavigationHandler.mayAccessWholeTreeUp(nodeEval);
      if (!mayAccessWholeTreeUp || !nodeEval.isVisible()) {
        String explan = rootNode.getNoAccessExplanation();
        String sExplan = (explan == null ? translate("launch.noaccess") : Formatter.formatLatexFormulas(explan));
        main.contextPut("disabledlaunchreason", sExplan);
        return false;
      }
View Full Code Here

    // grandchildren)
    String peekviewChildNodesConfig = config.getStringValue(STCourseNodeEditController.CONFIG_KEY_PEEKVIEW_CHILD_NODES, null);
    List<String> peekviewChildNodes =  (peekviewChildNodesConfig == null ? new ArrayList<String>() : Arrays.asList(peekviewChildNodesConfig.split(",")));
    int chdCnt = ne.getChildCount();
    for (int i = 0; i < chdCnt; i++) {
      NodeEvaluation neChd = ne.getNodeEvaluationChildAt(i);
      if (neChd.isVisible()) {
        // Build and add child generic or specific peek view
        CourseNode child = neChd.getCourseNode();
        Controller childViewController = null;
        Controller childPeekViewController = null;
        if (displayType.equals(STCourseNodeEditController.CONFIG_VALUE_DISPLAY_PEEKVIEW)) {
          if (peekviewChildNodes.size() == 0) {
            // Special case: no child nodes configured. This is the case when
View Full Code Here

   */
  public NodeEvaluation eval(ConditionInterpreter ci, TreeEvaluation treeEval) {
    // each CourseNodeImplementation has the full control over all children
    // eval.
    // default behaviour is to eval all visible children
    NodeEvaluation nodeEval = new NodeEvaluation(this);
    calcAccessAndVisibility(ci, nodeEval);
    nodeEval.build();
    treeEval.cacheCourseToTreeNode(this, nodeEval.getTreeNode());
    // only add children (coursenodes/nodeeval) when I am visible and
    // atleastOneAccessible myself
    if (nodeEval.isVisible() && nodeEval.isAtLeastOneAccessible()) {
      int childcnt = getChildCount();
      for (int i = 0; i < childcnt; i++) {
        CourseNode cn = (CourseNode) this.getChildAt(i);
        NodeEvaluation chdEval = cn.eval(ci, treeEval);
        if (chdEval.isVisible()) { // child is visible
          nodeEval.addNodeEvaluationChild(chdEval);
        }
      }
    }
    return nodeEval;
View Full Code Here

      // no node construction result indicates handled
      ncr = new NodeClickedRef(null, true, null, null, null);
    } else {
      // normal dispatching to a coursenode.
      // get the courseNode that was called
      NodeEvaluation prevEval = (NodeEvaluation) selTN.getUserObject();
      if (!prevEval.isVisible()) throw new AssertException("clicked on a node which is not visible: treenode=" + selTN.getIdent() + ", "
          + selTN.getTitle());
      CourseNode calledCourseNode = prevEval.getCourseNode();
      ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrap(calledCourseNode));
      ncr = doEvaluateJumpTo(ureq, wControl, calledCourseNode, listeningController, nodecmd);
    }
    return ncr;
View Full Code Here

    // build the new treemodel by evaluating the preconditions
    TreeEvaluation treeEval = new TreeEvaluation();
    GenericTreeModel treeModel = new GenericTreeModel();
    CourseNode rootCn = userCourseEnv.getCourseEnvironment().getRunStructure().getRootNode();
    NodeEvaluation rootNodeEval = rootCn.eval(userCourseEnv.getConditionInterpreter(), treeEval);
    TreeNode treeRoot = rootNodeEval.getTreeNode();
    treeModel.setRootNode(treeRoot);

    // find the treenode that corresponds to the node (!= selectedTreeNode since
    // we built the TreeModel anew in the meantime
    TreeNode newCalledTreeNode = treeEval.getCorrespondingTreeNode(courseNode);
    if (newCalledTreeNode == null) {
      // the clicked node is not visible anymore!
      // if the new calculated model does not contain the selected node anymore
      // (because of visibility changes of at least one of the ancestors
      // -> issue an user infomative msg
      // nclr: the new treemodel, not visible, no selected nodeid, no
      // calledcoursenode, no nodeconstructionresult
      nclr = new NodeClickedRef(treeModel, false, null, null, null);
    } else {
      // calculate the NodeClickedRef
      // 1. get the correct (new) nodeevaluation
      NodeEvaluation nodeEval = (NodeEvaluation) newCalledTreeNode.getUserObject();
      if (nodeEval.getCourseNode() != courseNode) throw new AssertException("error in structure");
      if (!nodeEval.isVisible()) throw new AssertException("node eval not visible!!");
      // 2. start with the current NodeEvaluation, evaluate overall accessiblity
      // per node bottom-up to see if all ancestors still grant access to the
      // desired node
      boolean mayAccessWholeTreeUp = mayAccessWholeTreeUp(nodeEval);
      String newSelectedNodeId = newCalledTreeNode.getIdent();
View Full Code Here

  /**
   * @param ne
   * @return
   */
  public static boolean mayAccessWholeTreeUp(NodeEvaluation ne) {
    NodeEvaluation curNodeEval = ne;
    boolean mayAccess;
    do {
      mayAccess = curNodeEval.isAtLeastOneAccessible();
      curNodeEval = (NodeEvaluation) curNodeEval.getParent();
    } while (curNodeEval != null && mayAccess);
    // top reached or may not access node
    return mayAccess;
  }
View Full Code Here

TOP

Related Classes of org.olat.course.run.userview.NodeEvaluation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.