MDL-67049 grading: options are array, ensure json_decode() knows it

By default json_decode() returns object for associative arrays. That
was not a problem till now becuause array_key_exists() worked with
objects too. But in php74 that emits a warning.

So we need to ensure that the information arriving to it is
an array, allowing everything to continue working ok.
This commit is contained in:
Eloy Lafuente (stronk7) 2019-10-28 02:50:24 +01:00
parent a5f618d6a9
commit 8e98f82f12

View file

@ -386,7 +386,7 @@ class gradingform_rubric_controller extends gradingform_controller {
public function get_options() {
$options = self::get_default_options();
if (!empty($this->definition->options)) {
$thisoptions = json_decode($this->definition->options);
$thisoptions = json_decode($this->definition->options, true); // Assoc. array is expected.
foreach ($thisoptions as $option => $value) {
$options[$option] = $value;
}