Uploaded image for project: 'OpenOLAT'
  1. OpenOLAT
  2. OO-1993

Sending of course reminders fails if e.g test course node is deleted

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 10.4.9
    • Fix Version/s: 10.4.11
    • Component/s: Course
    • Labels:
      None

      Description

      When in a course a reminder evaluates e.g the attempts of a test and after having configured this reminder the test is removed of the course, the reminder scheduler terminates with a NullPointerException:

      2016-04-15 09:00:05,491 [schedulerFactoryBean_Worker-4] ERROR JobRunShell  - Job DEFAULT.reminderJobDetail threw an unhandled Exception: 
      java.lang.NullPointerException
      	at org.olat.course.reminder.manager.ReminderRuleDAO.buildCourseNodePropertyCategory(ReminderRuleDAO.java:218)
      	at org.olat.course.reminder.manager.ReminderRuleDAO.getAttempts(ReminderRuleDAO.java:113)
      	at org.olat.course.reminder.rule.AttemptsRuleSPI.filter(AttemptsRuleSPI.java:85)
      	at org.olat.modules.reminder.manager.ReminderRuleEngine.filterByRules(ReminderRuleEngine.java:245)
      

      The cause is that courseNode = course.getRunStructure().getNode(nodeIdent) returns null and no further processing of courseNode is possible.

      In this case, I see two possibilities:
      1. ignore the whole reminder and do nothing or
      2. Ignore the broken rule and process further rules of the reminder.

      I would prefer possibility 1, because an author had something in mind if he combined two or more rules in a reminder. Therefore it is not advisable to ignore one rule and process the others.
      I also successfully tested possibility 2 but I think the other is better.

      Here's my patch for possibility 1:

      diff --git a/src/main/java/org/olat/course/reminder/rule/AttemptsRuleSPI.java b/src/main/java/org/olat/course/reminder/rule/AttemptsRuleSPI.java
      --- a/src/main/java/org/olat/course/reminder/rule/AttemptsRuleSPI.java
      +++ b/src/main/java/org/olat/course/reminder/rule/AttemptsRuleSPI.java
      @@ -81,6 +81,10 @@
       			
       			ICourse course = CourseFactory.loadCourse(entry);
       			CourseNode courseNode = course.getRunStructure().getNode(nodeIdent);
      +			if (courseNode == null) {
      +				identities.clear();
      +				return;
      +			}
       
       			Map<Long, Integer> attempts = helperDao.getAttempts(entry.getOlatResource().getResourceableId(), courseNode, identities);
       			
      diff --git a/src/main/java/org/olat/course/reminder/rule/PassedRuleSPI.java b/src/main/java/org/olat/course/reminder/rule/PassedRuleSPI.java
      --- a/src/main/java/org/olat/course/reminder/rule/PassedRuleSPI.java
      +++ b/src/main/java/org/olat/course/reminder/rule/PassedRuleSPI.java
      @@ -84,6 +84,10 @@
       			
       			ICourse course = CourseFactory.loadCourse(entry);
       			CourseNode courseNode = course.getRunStructure().getNode(nodeIdent);
      +			if (courseNode == null) {
      +				identities.clear();
      +				return;
      +			}
       			
       			Map<Long, Boolean> passeds;
       			if(courseNode instanceof STCourseNode) {
      diff --git a/src/main/java/org/olat/course/reminder/rule/ScoreRuleSPI.java b/src/main/java/org/olat/course/reminder/rule/ScoreRuleSPI.java
      --- a/src/main/java/org/olat/course/reminder/rule/ScoreRuleSPI.java
      +++ b/src/main/java/org/olat/course/reminder/rule/ScoreRuleSPI.java
      @@ -87,6 +87,10 @@
       			
       			ICourse course = CourseFactory.loadCourse(entry);
       			CourseNode courseNode = course.getRunStructure().getNode(nodeIdent);
      +			if (courseNode == null) {
      +				identities.clear();
      +				return;
      +			}
       			
       			Map<Long, Float> scores;
       			if(courseNode instanceof STCourseNode) {
      

        Attachments

          Activity

            People

            Assignee:
            srosse Stéphane Rossé
            Reporter:
            stephan Stephan Clemenz
            Tester:
            Stephan Clemenz
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: