Examples of CourseNode


Examples of org.olat.course.nodes.CourseNode

      StatusDescription[] status = new StatusDescription[damagedRefsModifiedNodes.size()];
      status = damagedRefsModifiedNodes.toArray(status);
      return status;
    }

    CourseNode clonedCourseNode = (CourseNode) ObjectCloner.deepCopy(resultingCourseRun.getRootNode());
    CourseEditorTreeNode clonedRoot = new CourseEditorTreeNode(clonedCourseNode);
    convertInCourseEditorTreeNode(clonedRoot, clonedCourseNode);
    clonedCourseNode.removeAllChildren(); // Do remove all children after convertInCourseEditorTreeNode
    CourseEditorTreeModel cloneCETM = new CourseEditorTreeModel();
    cloneCETM.setRootNode(clonedRoot);

    /*
     * now we have the cloned editor tree synchronized with the pre-published
     * runstructure. The cloned editor tree is used within a new
     * CourseEditorEnvironment which is placed in a new Editor User Course
     * Session for evaluation only. This is like opening the runstructure in a
     * virtual course editor for using the validation facilities of the editor
     * environment.
     */
    CourseEditorEnv tmpCEV = new CourseEditorEnvImpl(cloneCETM, course.getCourseEnvironment().getCourseGroupManager(), locale);
    // the resulting object is not needed, but constructor makes
    // initializations within tmpCEV!! thus important step.
    new EditorUserCourseEnvironmentImpl(tmpCEV);
    //
    tmpCEV.setCurrentCourseNodeId(cloneCETM.getRootNode().getIdent());
    tmpCEV.validateCourse();
    StatusDescription[] status = tmpCEV.getCourseStatus();
    // check if the resulting course contains cycles.
    Set<String> nodesInCycle = tmpCEV.listCycles();
    if (nodesInCycle.size() > 0) {
      // there are nodes generating cylces -> error! this is not a publishable
      // set!
      StringBuilder sb = new StringBuilder();
      for (Iterator<String> iter = nodesInCycle.iterator(); iter.hasNext();) {
        String id = iter.next();
        String title = editorTreeModel.getCourseEditorNodeById(id).getTitle();
        sb.append("<b>").append(title).append("</b>");
        sb.append("(id:").append(id).append(")<br />");
      }
      StatusDescription sd = new StatusDescription(ValidationStatus.ERROR, "pbl.error.cycles", "pbl.error.cycles", new String[] { sb
          .toString() }, PACKAGE);
      status = new StatusDescription[] { sd };
    } else {
      /*
       * these are now status description as they are helpful in the editor
       * context. The same errors in the publish context have a kind of
       * different meaning --- Let the nodes explain what it means in publish
       * mode.
       */
      for (int i = 0; i < status.length; i++) {
        StatusDescription description = status[i];
        String nodeId = description.getDescriptionForUnit();
        CourseNode cn = cloneCETM.getCourseNode(nodeId);
        status[i] = cn.explainThisDuringPublish(description);
      }
    }
    return status;
  }
View Full Code Here

Examples of org.olat.course.nodes.CourseNode

  private List<StatusDescription> checkRefs(List<CourseEditorTreeNode> courseEditorTreeNodes) {
    // course Editor Nodes With Damaged Reference
    List<StatusDescription> cetnDamaged = new ArrayList<StatusDescription>();
    for (Iterator<CourseEditorTreeNode> iter = courseEditorTreeNodes.iterator(); iter.hasNext();) {
      CourseEditorTreeNode cetn = iter.next();
      CourseNode cn = cetn.getCourseNode();
      /*
       * for those coursenodes which need a reference to a repository entry to
       * function properly, check that the reference is valid
       */
      if (cn.needsReferenceToARepositoryEntry()) {
        RepositoryEntry referencedEntry = cn.getReferencedRepositoryEntry();
        if (referencedEntry == null) {
          cetnDamaged.add(new StatusDescription(ValidationStatus.ERROR, "pbl.error.refs", "pbl.error.refs", new String[] { cetn.getTitle()
              + "(id:" + cetn.getIdent() + " )" }, PACKAGE));
        }
      }
View Full Code Here

Examples of org.olat.course.nodes.CourseNode

   * @param node                  Current course node which will be converted
   */
  private void convertInCourseEditorTreeNode(CourseEditorTreeNode courseEditorTreeNode, CourseNode node) {
    int childCnt = node.getChildCount();
    for (int i = 0; i < childCnt; i++) {
      CourseNode childNode = (CourseNode) node.getChildAt(i);
      CourseEditorTreeNode newEditorNode = new CourseEditorTreeNode(childNode);
      courseEditorTreeNode.addChild(newEditorNode);
      convertInCourseEditorTreeNode(newEditorNode, childNode);
      childNode.removeAllChildren(); // remove all children after calling convertInCourseEditorTreeNode
    }
  }
View Full Code Here

Examples of org.olat.course.nodes.CourseNode

     */
    Set<String> deletedCourseNodeIds = new HashSet<String>();
    if (editorModelDeletedNodes.size() > 0) {
      for (Iterator<CourseEditorTreeNode> iter = editorModelDeletedNodes.iterator(); iter.hasNext();) {
        CourseEditorTreeNode cetn = iter.next();
        CourseNode cn = cetn.getCourseNode();
        deletedCourseNodeIds.add(cn.getIdent());
      }
    }
    Set<String> insertedCourseNodeIds = new HashSet<String>();
    if (editorModelInsertedNodes.size() > 0) {
      for (Iterator<CourseEditorTreeNode> iter = editorModelInsertedNodes.iterator(); iter.hasNext();) {
        CourseEditorTreeNode cetn = iter.next();
        CourseNode cn = cetn.getCourseNode();
        insertedCourseNodeIds.add(cn.getIdent());
      }
    }
    Set<String> modifiedCourseNodeIds = new HashSet<String>();
    if (editorModelModifiedNodes.size() > 0) {
      for (Iterator<CourseEditorTreeNode> iter = editorModelModifiedNodes.iterator(); iter.hasNext();) {
        CourseEditorTreeNode cetn = iter.next();
        CourseNode cn = cetn.getCourseNode();
        modifiedCourseNodeIds.add(cn.getIdent());
      }
    }
    /*
     * broadcast PRE PUBLISH event that a publish will take place
     */
    PublishEvent beforePublish = new PublishEvent(editorTreeModel.getLatestPublishTimestamp(), course, PublishEvent.EVENT_IDENTIFIER);
    beforePublish.setDeletedCourseNodeIds(deletedCourseNodeIds);
    beforePublish.setInsertedCourseNodeIds(insertedCourseNodeIds);
    beforePublish.setModifiedCourseNodeIds(modifiedCourseNodeIds);
    beforePublish.setState(PublishEvent.PRE_PUBLISH);
    // old course structure accessible
    orec.fireEventToListenersOf(beforePublish, course);
    /*
     * TODO:pb: disucss with fj: listeners could add information to
     * beforePublish event such as a right to veto or add identities who is
     * currently in the course, thus stopping the publishing author from
     * publishing! i.e. if people are in a test or something like this.... we
     * could the ask here beforePublish.accepted() and proceed only in this
     * case.
     */
    //
    /*
     * remove new nodes which were marked as delete and deletion is published.
     */
    File exportDirectory = CourseFactory.getOrCreateDataExportDirectory(identity, course.getCourseTitle());
    UserManager um = UserManager.getInstance();
    String charset = um.getUserCharset(identity);
    if (editorModelDeletedNodes.size() > 0) {
      for (Iterator<CourseEditorTreeNode> iter = editorModelDeletedNodes.iterator(); iter.hasNext();) {
        CourseEditorTreeNode cetn = iter.next();
        CourseNode cn = cetn.getCourseNode();
        CourseNode oldCn = existingCourseRun.getNode(cetn.getIdent());
        // moved node with a parent deleted (deletion published) -> oldCn ==
        // null
        if (oldCn != null) {
          if (!(cn.getIdent().equals(oldCn.getIdent()))) { throw new AssertException("deleted cn.getIdent != oldCn.getIdent"); }
        }
        cetn.removeFromParent();
        if (!cetn.isNewnode()) {
          // only clean up and archive of nodes which were already in run
          // save data, remove references
          deleteRefs(oldCn);
          oldCn.archiveNodeData(locale, course, exportDirectory, charset);
          // 2) delete all user data
          oldCn.cleanupOnDelete(course);
        }
      }
    }
    /*
     * mark modified ones as no longer dirty
     */
    if (editorModelModifiedNodes.size() > 0) {
      for (Iterator<CourseEditorTreeNode> iter = editorModelModifiedNodes.iterator(); iter.hasNext();) {
        CourseEditorTreeNode cetn = iter.next();
        CourseNode cn = cetn.getCourseNode();
        CourseNode oldCn = existingCourseRun.getNode(cetn.getIdent());
        // moved node with a parent deleted (deletion published) -> oldCn ==
        // null
        if (oldCn != null) {
          if (!(cn.getIdent().equals(oldCn.getIdent()))) { throw new AssertException("deleted cn.getIdent != oldCn.getIdent"); }
        }
        cetn.setDirty(false);
        //
        updateRefs(cn, oldCn);
      }
    }
    /*
     * mark newly published ones is no longer new and dirty
     */
    if (editorModelInsertedNodes.size() > 0) {
      for (Iterator<CourseEditorTreeNode> iter = editorModelInsertedNodes.iterator(); iter.hasNext();) {
        CourseEditorTreeNode cetn = iter.next();
        CourseNode cn = cetn.getCourseNode();
        CourseNode oldCn = existingCourseRun.getNode(cetn.getIdent());
        if (oldCn != null) { throw new AssertException("new node has an oldCN??"); }
        cetn.setDirty(false);
        cetn.setNewnode(false);
        //
        updateRefs(cn, null);
View Full Code Here

Examples of org.olat.course.nodes.CourseNode

    CourseEditorTreeModel cetm = course.getEditorTreeModel();
    for (int i = 0; i < nodeIdsToPublish.size(); i++) {
      msg.append("<li>");
      String nodeId = (String) nodeIdsToPublish.get(i);
      CourseEditorTreeNode cetn = (CourseEditorTreeNode) cetm.getNodeById(nodeId);
      CourseNode cn = cetm.getCourseNode(nodeId);
      msg.append(cn.getShortTitle());
      if (cetn.isDeleted() && !cetn.isNewnode()) {
        //use locale of this initialized translator.
        String onDeleteMessage = cn.informOnDelete(translator.getLocale(), course);
        if (onDeleteMessage != null) {
          msg.append("<br /><font color=\"red\">");
          msg.append(onDeleteMessage);
          msg.append("</font>");
        }
View Full Code Here

Examples of org.olat.course.nodes.CourseNode

        String actionid = te.getActionId();
        if (actionid.equals(CMD_SELECT_NODE)) {
          int rowid = te.getRowId();
          Map nodeData = (Map) nodeTableModel.getObject(rowid);
          ICourse course = CourseFactory.loadCourse(ores);
          CourseNode node = course.getRunStructure().getNode((String) nodeData.get(AssessmentHelper.KEY_IDENTIFYER));
          this.currentCourseNode = (FOCourseNode) node;
          // cast should be save, only ta course nodes nodes are selectable
          archiveForumNode(ureq);
          getWindowControl().setInfo(translate("archive.fo.successfully"));     
        }
View Full Code Here

Examples of org.olat.course.nodes.CourseNode

    nodeListCtr.addColumnDescriptor(new DefaultColumnDescriptor("table.action.select", 1,
        CMD_SELECT_NODE, ureq.getLocale()));
   
    // get list of course node data and populate table data model
    ICourse course = CourseFactory.loadCourse(ores);
    CourseNode rootNode = course.getRunStructure().getRootNode();
    List nodesTableObjectArrayList = addForumNodesAndParentsToList(0, rootNode);
   
    // only populate data model if data available
    if (nodesTableObjectArrayList == null) {
      nodeChoose.contextPut("hasForumNodes", Boolean.FALSE);
View Full Code Here

Examples of org.olat.course.nodes.CourseNode

  @SuppressWarnings("unchecked")
  private List addForumNodesAndParentsToList(int recursionLevel, CourseNode courseNode) {
    // 1) Get list of children data using recursion of this method
    List childrenData = new ArrayList();
    for (int i = 0; i < courseNode.getChildCount(); i++) {
      CourseNode child = (CourseNode) courseNode.getChildAt(i);
      List childData = addForumNodesAndParentsToList( (recursionLevel + 1),  child);
      if (childData != null)
        childrenData.addAll(childData);
    }
   
View Full Code Here

Examples of org.olat.course.nodes.CourseNode

       * or the CourseEditorTreeNode cetn !! .................................
       */
      CourseEditorTreeNode cetn = (CourseEditorTreeNode) node;
      if (cetn == root && publishNodeIds.contains(cetn.getIdent()) ) {
        // root node changed and published
        CourseNode clone = (CourseNode)XStreamHelper.xstreamClone(cetn.getCourseNode());
        resultingCourseRun.setRootNode(clone);
        editorModelModifiedNodes.add(cetn);// TODO:pb: Review  Change to fic OLAT-1644
        return;
      }
      if (cetn == root) { // TODO:pb: Review Change to fix OLAT-1644
        // root node
        CourseNode clone = (CourseNode)XStreamHelper.xstreamClone(cetn.getCourseNode());
        resultingCourseRun.setRootNode(clone);
        return;
      }
      /*
       * check that root exist in newRunStruct
View Full Code Here

Examples of org.olat.course.nodes.CourseNode

    /**
     * @param newRunStruct
     * @param cetn
     */
    private void addNodeTo(final Structure newRunStruct, CourseEditorTreeNode cetn) {
      CourseNode clone = (CourseNode) XStreamHelper.xstreamClone(cetn.getCourseNode());
      clone.removeAllChildren();// children get also visited
      // parent in the course editor model
      CourseEditorTreeNode parentCetn = (CourseEditorTreeNode) cetn.getParent();
      CourseNode parent = parentCetn.getCourseNode();
      CourseNode parentClone = newRunStruct.getNode(parent.getIdent());
      parentClone.addChild(clone);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.