diff --git a/classes/external/rule_conditions.php b/classes/external/rule_conditions.php index 7fbe7cf..d7a58cf 100644 --- a/classes/external/rule_conditions.php +++ b/classes/external/rule_conditions.php @@ -73,10 +73,12 @@ public static function get_conditions(int $ruleid): array { $name = $condition->get('classname'); $description = $condition->get('configdata'); $configdata = $condition->get('configdata'); + $broken = false; } else { $name = $instance->get_name(); $description = $instance->is_broken() ? $instance->get_broken_description() : $instance->get_config_description(); $configdata = json_encode($instance->get_config_data()); + $broken = $instance->is_broken(); } $conditions[$condition->get('id')] = [ @@ -86,6 +88,7 @@ public static function get_conditions(int $ruleid): array { 'configdata' => $configdata, 'description' => $description, 'name' => $name, + 'broken' => $broken, ]; } @@ -106,6 +109,7 @@ public static function get_conditions_returns(): external_multiple_structure { 'configdata' => new external_value(PARAM_RAW, ''), 'description' => new external_value(PARAM_RAW, ''), 'name' => new external_value(PARAM_RAW, ''), + 'broken' => new external_value(PARAM_BOOL, ''), ]) ); } diff --git a/classes/rule_manager.php b/classes/rule_manager.php index 1587c08..f4a8ab7 100644 --- a/classes/rule_manager.php +++ b/classes/rule_manager.php @@ -76,16 +76,20 @@ public static function build_data_for_form(rule $rule): array { $instance = condition_base::get_instance(0, $condition->to_record()); if (!$instance) { + $broken = false; $name = $condition->get('classname'); $description = $condition->get('configdata'); } else { + $broken = $instance->is_broken(); $name = $instance->get_name(); - $description = $instance->is_broken() ? $instance->get_broken_description() : $instance->get_config_description(); + $description = $broken ? $instance->get_broken_description() : $instance->get_config_description(); } $conditions[] = (array)$condition->to_record() + ['description' => $description] + - ['name' => $name]; + ['name' => $name] + + ['broken' => $broken]; + ; } if (!empty($conditions)) { diff --git a/templates/conditions.mustache b/templates/conditions.mustache index 2da0231..9af9c5f 100644 --- a/templates/conditions.mustache +++ b/templates/conditions.mustache @@ -51,7 +51,7 @@
{{#conditions}}