Update of 
/var/cvs/contributions/didactor2/src/assessment/java/nl/didactor/component/assessment/education_menu/utils
In directory 
james.mmbase.org:/tmp/cvs-serv20478/java/nl/didactor/component/assessment/education_menu/utils

Modified Files:
        LessonChecker.java 
Log Message:
added a features 'relate_component' to indicate which learnblocks must be 
presented in the assessment overviews


See also: 
http://cvs.mmbase.org/viewcvs/contributions/didactor2/src/assessment/java/nl/didactor/component/assessment/education_menu/utils


Index: LessonChecker.java
===================================================================
RCS file: 
/var/cvs/contributions/didactor2/src/assessment/java/nl/didactor/component/assessment/education_menu/utils/LessonChecker.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- LessonChecker.java  25 Sep 2008 16:30:42 -0000      1.4
+++ LessonChecker.java  9 Oct 2008 16:07:24 -0000       1.5
@@ -3,13 +3,17 @@
 import java.util.*;
 import nl.didactor.util.ClassRoom;
 
+import nl.didactor.component.assessment.AssessmentField;
 import org.mmbase.bridge.*;
+import org.mmbase.bridge.util.Queries;
+import org.mmbase.util.Casting;
+import nl.didactor.component.Component;
 import org.mmbase.util.logging.*;
 
 
 /**
  * @javadoc
- * @version $Id: LessonChecker.java,v 1.4 2008/09/25 16:30:42 michiel Exp $
+ * @version $Id: LessonChecker.java,v 1.5 2008/10/09 16:07:24 michiel Exp $
  */
 
 public class LessonChecker {
@@ -17,6 +21,16 @@
 
    private static final Logger log = 
Logging.getLoggerInstance(LessonChecker.class);
 
+    protected static Component getComponent() {
+        return Component.getComponent("assessment");
+    }
+
+    protected static boolean checkRelated(Cloud cloud, Node education) {
+        Map wtf = new HashMap();
+        wtf.put("education", education);
+        return  
Casting.toBoolean(getComponent().getSetting("relate_component", cloud, wtf));
+    }
+
    /**
     * Checks that learnblocks are blocked for this particular user.
     * It is advised to call this method only once during the education menu 
building
@@ -33,7 +47,7 @@
 
        // Check whether this education indeeds needs 'assessment'.
 
-       Node assessment = 
cloud.getNode(nl.didactor.component.Component.getComponent("assessment").getNumber());
+       Node assessment = cloud.getNode(getComponent().getNumber());
        if (! education.getRelatedNodes("components", "settingrel", 
"destination").contains(assessment)) {
            return resultSet;
        }
@@ -42,6 +56,7 @@
        if (roles.contains("teacher") ||
            roles.contains("courseeditor") ||
            roles.contains("systemadministrator")) {
+           // nothing blocked
            return resultSet;
        }
 
@@ -52,6 +67,8 @@
                                                    "posrel.pos",
                                                    null, null, true);
 
+       boolean checkRelated = checkRelated(cloud, education);
+
        int counter = 0;
        boolean statusBlocked = false;
        boolean firstHasFeedback = false;
@@ -63,7 +80,7 @@
 
            if (statusBlocked) {
                //It means the rest of learnblocks is closed.
-               previousOneHasGotNoFeedbackRelated(learnBlock);
+               log.debug("Learnblock=" + learnBlock.getNumber() + " is blocked 
because the previous one is blocked.");
                resultSet.add(learnBlock);
            } else {
                NodeList classRels = cloud.getList("" + learnBlock.getNumber(),
@@ -75,11 +92,16 @@
 
 
                if (classRels.size() == 0) {
+                   if (checkRelated) {
+                       if 
(Queries.count(AssessmentField.getRelationsQuery(learnBlock)) != 0) {
+                           statusBlocked = noFeedbackRelated(learnBlock, 
resultSet, counter, statusBlocked, firstHasFeedback);
+                       }
+                   } else {
                    //blocked
                    statusBlocked = noFeedbackRelated(learnBlock, resultSet, 
counter, statusBlocked, firstHasFeedback);
+                   }
                } else {
                    if 
(cloud.getNode(classRels.getNode(0).getIntValue("classrel.number")).countRelatedNodes("popfeedback")
 > 0) {
-                       feedbackRelated(learnBlock);
                        if (counter == 0) {
                            firstHasFeedback = true;
                        }
@@ -110,7 +132,7 @@
       if (counter == 1) {
           if (!firstHasFeedback) {
               //The first learnblock has got no feedback
-              previousOneHasGotNoFeedbackRelated(nodeLearnBlock);
+                log.debug("Learnblock=" + nodeLearnBlock.getNumber() + " is 
blocked because the previous one has got no feedback.");
               resultSet.add(nodeLearnBlock);
           }
       }
@@ -121,17 +143,6 @@
    }
 
 
-
-
-
-   private static void feedbackRelated(Node nodeLearnBlock){
-      log.debug("Learnblock=" + nodeLearnBlock.getNumber() + " has got a 
feedback related.");
-   }
-
-
-   private static void previousOneHasGotNoFeedbackRelated(Node nodeLearnBlock){
-      log.debug("Learnblock=" + nodeLearnBlock.getNumber() + " is blocked 
because the previous one has got no feedback.");
-   }
 }
 
 
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to