Permalink
Browse files

MDL-37835 Assignment unit tests fail when custom submission types are…

… installed.

The assignment generator will now take all submission/feedback modules into concideration when creating new assignments.
  • Loading branch information...
Erik Lundberg authored and stronk7 committed Feb 4, 2013
1 parent 4f15387 commit a5c4a768483f261440f8d8780860d64067cd67d1
Showing with 16 additions and 17 deletions.
  1. +16 −17 mod/assign/tests/generator/lib.php
@@ -78,24 +78,23 @@ public function create_instance($record = null, array $options = null) {
if (!isset($record->allowsubmissionsfromdate)) {
$record->allowsubmissionsfromdate = 0;
}
- if (!isset($record->assignsubmission_onlinetext_enabled)) {
- $record->assignsubmission_onlinetext_enabled = 0;
- }
- if (!isset($record->assignsubmission_file_enabled)) {
- $record->assignsubmission_file_enabled = 0;
- }
- if (!isset($record->assignsubmission_comments_enabled)) {
- $record->assignsubmission_comments_enabled = 0;
- }
- if (!isset($record->assignfeedback_comments_enabled)) {
- $record->assignfeedback_comments_enabled = 0;
- }
- if (!isset($record->assignfeedback_file_enabled)) {
- $record->assignfeedback_file_enabled = 0;
- }
- if (!isset($record->assignfeedback_offline_enabled)) {
- $record->assignfeedback_offline_enabled = 0;
+
+ // If a submission or feedback plugin is not activated, make sure it's disabled.
+ $installedplugins = get_plugin_list('assignsubmission');
+ foreach ($installedplugins as $pluginname => $path) {
+ $enabledvariable = 'assignsubmission_'.$pluginname.'_enabled';
+ if (!isset($record->{$enabledvariable})) {
+ $record->{$enabledvariable} = 0;
+ }
+ }
+ $installedplugins = get_plugin_list('assignfeedback');
+ foreach ($installedplugins as $pluginname => $path) {
+ $enabledvariable = 'assignfeedback_'.$pluginname.'_enabled';
+ if (!isset($record->{$enabledvariable})) {
+ $record->{$enabledvariable} = 0;
+ }
}
+
if (!isset($record->grade)) {
$record->grade = 100;
}

0 comments on commit a5c4a76

Please sign in to comment.