course completion: MDL-2631 Prevent error when no roles are available
authorAaron Barnes <aaronb@catalyst.net.nz>
Wed, 4 Aug 2010 02:21:19 +0000 (02:21 +0000)
committerAaron Barnes <aaronb@catalyst.net.nz>
Wed, 4 Aug 2010 02:21:19 +0000 (02:21 +0000)
course/completion.php

index 137f084..861a576 100644 (file)
@@ -132,6 +132,10 @@ if ($form->is_cancelled()){
     $aggregation->insert();
 
     // Role aggregation
     $aggregation->insert();
 
     // Role aggregation
+    if (empty($data->role_aggregation)) {
+        $data->role_aggregation = 0;
+    }
+
     $aggregation = new completion_aggregation();
     $aggregation->course = $data->id;
     $aggregation->criteriatype = COMPLETION_CRITERIA_TYPE_ROLE;
     $aggregation = new completion_aggregation();
     $aggregation->course = $data->id;
     $aggregation->criteriatype = COMPLETION_CRITERIA_TYPE_ROLE;