[MMBASE CVS] contributions/didactor2/src/education/java/nl/didactor/education Functions.java

2009-03-13 Thread Michiel Meeuwissen
Update of 
/var/cvs/contributions/didactor2/src/education/java/nl/didactor/education
In directory james.mmbase.org:/tmp/cvs-serv18600/education

Modified Files:
Functions.java 
Log Message:
Implemeted 'url' function for all learnobjects


See also: 
http://cvs.mmbase.org/viewcvs/contributions/didactor2/src/education/java/nl/didactor/education


Index: Functions.java
===
RCS file: 
/var/cvs/contributions/didactor2/src/education/java/nl/didactor/education/Functions.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- Functions.java  7 Jan 2009 17:45:44 -   1.10
+++ Functions.java  13 Mar 2009 14:56:59 -  1.11
@@ -4,12 +4,14 @@
 import org.mmbase.storage.search.*;
 import org.mmbase.bridge.util.Queries;
 import org.mmbase.util.logging.*;
+import org.mmbase.util.functions.*;
+import javax.servlet.http.HttpServletRequest;
 import java.util.*;
 
 /**
  * Several functions on mmbase nodes which are used by didactor.
  * @author Michiel Meeuwissen
- * @version $Id: Functions.java,v 1.10 2009/01/07 17:45:44 michiel Exp $
+ * @version $Id: Functions.java,v 1.11 2009/03/13 14:56:59 michiel Exp $
  */
 public class Functions {
 protected final static Logger log = 
Logging.getLoggerInstance(Functions.class);
@@ -23,7 +25,10 @@
 
 /**
  * returns a list of nodenumbers which follows the path in the cloud up, 
via learnobjects and posrel. This
- * would mean that the last node in this path is the learobject directly 
related to the education node.
+ * would mean that the last node in this path is the learobject directly 
related to the
+ * education node.
+ * The first object in the returned list is the object itself.
+ * @return lt;node numbergt;,lt;parent node numbergt;,lt;node 
number node directly related to deducationgt;
  */
 public ListInteger path() {
 ListInteger result = new ArrayListInteger();
@@ -72,7 +77,6 @@
 /**
  * The sequence number in the tree of learnobjects in the current 
education.
  */
-
 public Integer sequence() {
 Node education = education();
 if (education != null) {
@@ -89,22 +93,25 @@
 return null;
 }
 
-/*
-public String url() {
-ListInteger result = new ArrayListInteger();
-result.add(node.getNumber());
-NodeList parents = node.getRelatedNodes(learnobjects, posrel, 
source);
-while (parents.size()  0) {
-assert parents.size() == 1;
-Node parent = parents.getNode(0);
-if (result.contains(parent.getNumber())) break;
-result.add(parent.getNumber());
-parents = parent.getRelatedNodes(learnobjects, posrel, 
source);
+public static String url(@Required @Name(node) Node learnobject,
+ @Required @Name(request) HttpServletRequest 
request) {
+Functions fun = new Functions();
+fun.setNode(learnobject);
+// probably some didactor setting must be applied to determin which 
node is the 'learnboject'.x
+StringBuilder buf = new StringBuilder(request.getContextPath());
+buf.append(/education?learnobject=);
+ListInteger path = fun.path();
+buf.append(path.get(path.size() -1));
+char sep = '#';
+for (int i = path.size() - 2; i = 0; i--) {
+buf.append(sep);
+buf.append(path.get(i));
+sep = '_';
 }
-return result;
+return buf.toString();
+
 }
 
-*/
 
 /**
  * Used on nodes of type 'tests'
___
Cvs mailing list
Cvs@lists.mmbase.org
http://lists.mmbase.org/mailman/listinfo/cvs


[MMBASE CVS] contributions/didactor2/src/education/java/nl/didactor/education Functions.java

2009-01-07 Thread Michiel Meeuwissen
Update of 
/var/cvs/contributions/didactor2/src/education/java/nl/didactor/education
In directory james.mmbase.org:/tmp/cvs-serv23806/java/nl/didactor/education

Modified Files:
Functions.java 
Log Message:
added a function 'education' on learnobjects, and a function 'sequence'.


See also: 
http://cvs.mmbase.org/viewcvs/contributions/didactor2/src/education/java/nl/didactor/education


Index: Functions.java
===
RCS file: 
/var/cvs/contributions/didactor2/src/education/java/nl/didactor/education/Functions.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- Functions.java  2 Jan 2009 09:36:10 -   1.7
+++ Functions.java  7 Jan 2009 17:08:54 -   1.8
@@ -9,7 +9,7 @@
 /**
  * Several functions on mmbase nodes which are used by didactor.
  * @author Michiel Meeuwissen
- * @version $Id: Functions.java,v 1.7 2009/01/02 09:36:10 michiel Exp $
+ * @version $Id: Functions.java,v 1.8 2009/01/07 17:08:54 michiel Exp $
  */
 public class Functions {
 protected final static Logger log = 
Logging.getLoggerInstance(Functions.class);
@@ -41,6 +41,53 @@
 return result;
 }
 
+
+/**
+ * Returns the education associated with the current learnobject
+ */
+public Node education() {
+Node parent = null;
+NodeList parents = node.getRelatedNodes(learnobjects, posrel, 
source);
+while (parents.size()  0) {
+if (parents.size()  1) {
+log.warn(Node  + node.getNumber() +  has more than 1 posrel 
parents:  + parents);
+}
+parent = parents.getNode(0);
+parents = parent.getRelatedNodes(learnobjects, posrel, 
source);
+}
+if (parent != null) {
+NodeList educations = parent.getRelatedNodes(education, 
posrel, source);
+if (educations.size()  0) {
+return educations.getNode(0);
+} else {
+log.warn(No education found for  + node);
+return null;
+}
+} else {
+log.warn(No parents found for  + node +  don't know the 
education);
+return null;
+}
+}
+
+/**
+ * The sequence number in the tree of learnobjects in the current 
education.
+ */
+
+public int sequence() {
+Node education = education();
+if (education != null) {
+NodeList tree = (NodeList) education.getFunctionValue(tree, 
null);
+int seq = 0;
+for (Node leaf : tree) {
+if (leaf.getNumber() == node.getNumber()) {
+return seq;
+}
+seq++;
+}
+}
+return Integer.MAX_VALUE;
+}
+
 /*
 public String url() {
 ListInteger result = new ArrayListInteger();
___
Cvs mailing list
Cvs@lists.mmbase.org
http://lists.mmbase.org/mailman/listinfo/cvs


[MMBASE CVS] contributions/didactor2/src/education/java/nl/didactor/education Functions.java

2009-01-02 Thread Michiel Meeuwissen
Update of 
/var/cvs/contributions/didactor2/src/education/java/nl/didactor/education
In directory 
james.mmbase.org:/tmp/cvs-serv15048/education/java/nl/didactor/education

Modified Files:
Functions.java 
Log Message:



See also: 
http://cvs.mmbase.org/viewcvs/contributions/didactor2/src/education/java/nl/didactor/education


Index: Functions.java
===
RCS file: 
/var/cvs/contributions/didactor2/src/education/java/nl/didactor/education/Functions.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- Functions.java  20 Nov 2008 15:09:40 -  1.6
+++ Functions.java  2 Jan 2009 09:36:10 -   1.7
@@ -9,7 +9,7 @@
 /**
  * Several functions on mmbase nodes which are used by didactor.
  * @author Michiel Meeuwissen
- * @version $Id: Functions.java,v 1.6 2008/11/20 15:09:40 michiel Exp $
+ * @version $Id: Functions.java,v 1.7 2009/01/02 09:36:10 michiel Exp $
  */
 public class Functions {
 protected final static Logger log = 
Logging.getLoggerInstance(Functions.class);
@@ -30,7 +30,9 @@
 result.add(node.getNumber());
 NodeList parents = node.getRelatedNodes(learnobjects, posrel, 
source);
 while (parents.size()  0) {
-assert parents.size() == 1 : Node  + node.getNumber() +  has 
more than 1 posrel parents;
+if (parents.size()  1) {
+log.warn(Node  + node.getNumber() +  has more than 1 posrel 
parents:  + parents);
+}
 Node parent = parents.getNode(0);
 if (result.contains(parent.getNumber())) break;
 result.add(parent.getNumber());
___
Cvs mailing list
Cvs@lists.mmbase.org
http://lists.mmbase.org/mailman/listinfo/cvs


[MMBASE CVS] contributions/didactor2/src/education/java/nl/didactor/education Functions.java

2008-11-20 Thread Michiel Meeuwissen
Update of 
/var/cvs/contributions/didactor2/src/education/java/nl/didactor/education
In directory 
james.mmbase.org:/tmp/cvs-serv14970/education/java/nl/didactor/education

Modified Files:
Functions.java 
Log Message:
added some functions to make jsps simpler


See also: 
http://cvs.mmbase.org/viewcvs/contributions/didactor2/src/education/java/nl/didactor/education


Index: Functions.java
===
RCS file: 
/var/cvs/contributions/didactor2/src/education/java/nl/didactor/education/Functions.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- Functions.java  18 Jul 2008 13:43:00 -  1.5
+++ Functions.java  20 Nov 2008 15:09:40 -  1.6
@@ -9,7 +9,7 @@
 /**
  * Several functions on mmbase nodes which are used by didactor.
  * @author Michiel Meeuwissen
- * @version $Id: Functions.java,v 1.5 2008/07/18 13:43:00 michiel Exp $
+ * @version $Id: Functions.java,v 1.6 2008/11/20 15:09:40 michiel Exp $
  */
 public class Functions {
 protected final static Logger log = 
Logging.getLoggerInstance(Functions.class);
@@ -68,4 +68,21 @@
 }
 
 
+/**
+ * Attach the made test object to the nearest object which' node manager 
has the
+ * 'madetestholder' property.
+ */
+public Node  madetestholder() {
+Cloud cloud = node.getCloud();
+for (int n : path()) {
+Node node = cloud.getNode(n);
+NodeManager nm = node.getNodeManager();
+if (true.equals(nm.getProperty(madetestholder))) {
+return node;
+}
+}
+return  null;
+}
+
+
 }
___
Cvs mailing list
Cvs@lists.mmbase.org
http://lists.mmbase.org/mailman/listinfo/cvs


[MMBASE CVS] contributions/didactor2/src/education/java/nl/didactor/education Functions.java

2008-07-18 Thread Michiel Meeuwissen
Update of 
/var/cvs/contributions/didactor2/src/education/java/nl/didactor/education
In directory 
james.mmbase.org:/tmp/cvs-serv21725/src/education/java/nl/didactor/education

Modified Files:
Functions.java 
Log Message:



See also: 
http://cvs.mmbase.org/viewcvs/contributions/didactor2/src/education/java/nl/didactor/education


Index: Functions.java
===
RCS file: 
/var/cvs/contributions/didactor2/src/education/java/nl/didactor/education/Functions.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- Functions.java  5 Feb 2008 15:05:55 -   1.4
+++ Functions.java  18 Jul 2008 13:43:00 -  1.5
@@ -7,8 +7,9 @@
 import java.util.*;
 
 /**
- * Several functions on mmbase nodes which are used by didactor. * @author 
Michiel Meeuwissen
- * @version $Id: Functions.java,v 1.4 2008/02/05 15:05:55 michiel Exp $
+ * Several functions on mmbase nodes which are used by didactor.
+ * @author Michiel Meeuwissen
+ * @version $Id: Functions.java,v 1.5 2008/07/18 13:43:00 michiel Exp $
  */
 public class Functions {
 protected final static Logger log = 
Logging.getLoggerInstance(Functions.class);
@@ -20,11 +21,30 @@
 }
 
 
+/**
+ * returns a list of nodenumbers which follows the path in the cloud up, 
via learnobjects and posrel. This
+ * would mean that the last node in this path is the learobject directly 
related to the education node.
+ */
 public ListInteger path() {
 ListInteger result = new ArrayListInteger();
 result.add(node.getNumber());
 NodeList parents = node.getRelatedNodes(learnobjects, posrel, 
source);
 while (parents.size()  0) {
+assert parents.size() == 1 : Node  + node.getNumber() +  has 
more than 1 posrel parents;
+Node parent = parents.getNode(0);
+if (result.contains(parent.getNumber())) break;
+result.add(parent.getNumber());
+parents = parent.getRelatedNodes(learnobjects, posrel, 
source);
+}
+return result;
+}
+
+/*
+public String url() {
+ListInteger result = new ArrayListInteger();
+result.add(node.getNumber());
+NodeList parents = node.getRelatedNodes(learnobjects, posrel, 
source);
+while (parents.size()  0) {
 assert parents.size() == 1;
 Node parent = parents.getNode(0);
 if (result.contains(parent.getNumber())) break;
@@ -34,6 +54,7 @@
 return result;
 }
 
+*/
 
 /**
  * Used on nodes of type 'tests'
___
Cvs mailing list
Cvs@lists.mmbase.org
http://lists.mmbase.org/mailman/listinfo/cvs