diff --git a/mod/workshop/classes/external.php b/mod/workshop/classes/external.php index 4e6c0f97720..829f0d362ef 100644 --- a/mod/workshop/classes/external.php +++ b/mod/workshop/classes/external.php @@ -1280,6 +1280,10 @@ class mod_workshop_external extends external_api { } } + // Get dimensions info. + $grader = $workshop->grading_strategy_instance(); + $result['dimensionsinfo'] = $grader->get_dimensions_info(); + return $result; } @@ -1318,6 +1322,17 @@ class mod_workshop_external extends external_api { ) ), 'The current field values.' ), + 'dimensionsinfo' => new external_multiple_structure( + new external_single_structure( + array( + 'id' => new external_value(PARAM_INT, 'Dimension id.'), + 'min' => new external_value(PARAM_FLOAT, 'Minimum grade for the dimension.'), + 'max' => new external_value(PARAM_FLOAT, 'Maximum grade for the dimension.'), + 'weight' => new external_value(PARAM_TEXT, 'The weight of the dimension.'), + 'scale' => new external_value(PARAM_TEXT, 'Scale items (if used).', VALUE_OPTIONAL), + ) + ), 'The dimensions general information.' + ), 'warnings' => new external_warnings() ) ); diff --git a/mod/workshop/form/accumulative/lib.php b/mod/workshop/form/accumulative/lib.php index 77576a8ad92..87a5f99c30c 100644 --- a/mod/workshop/form/accumulative/lib.php +++ b/mod/workshop/form/accumulative/lib.php @@ -346,6 +346,7 @@ class workshop_accumulative_strategy implements workshop_strategy { // the dimension uses a scale $diminfo[$dimid]->min = 1; $diminfo[$dimid]->max = count(explode(',', $dimrecord->scale)); + $diminfo[$dimid]->scale = $dimrecord->scale; } else { // the dimension uses points $diminfo[$dimid]->min = 0; diff --git a/mod/workshop/form/lib.php b/mod/workshop/form/lib.php index 3889d843153..1f5d930ff5d 100644 --- a/mod/workshop/form/lib.php +++ b/mod/workshop/form/lib.php @@ -84,7 +84,7 @@ interface workshop_strategy { /** * Returns a general information about the assessment dimensions * - * @return array [dimid] => stdclass (->id ->max ->min ->weight) + * @return array [dimid] => stdclass (->id ->max ->min ->weight and optionally ->scale containing scale items) */ public function get_dimensions_info(); diff --git a/mod/workshop/tests/external_test.php b/mod/workshop/tests/external_test.php index 737b800f1b9..8d26175237d 100644 --- a/mod/workshop/tests/external_test.php +++ b/mod/workshop/tests/external_test.php @@ -1312,6 +1312,13 @@ class mod_workshop_external_testcase extends externallib_advanced_testcase { $this->assertEquals(25, $field['value']); // Check one of the dimension fields attributes. } } + // Check dimensions grading info. + foreach ($result['dimensionsinfo'] as $dimension) { + $this->assertEquals(0, $dimension['min']); + $this->assertEquals(25, $dimension['max']); + $this->assertEquals(25, $dimension['weight']); + $this->assertFalse(isset($dimension['scale'])); + } } /** diff --git a/mod/workshop/upgrade.txt b/mod/workshop/upgrade.txt index 88a71f5b34a..4032b08cebf 100644 --- a/mod/workshop/upgrade.txt +++ b/mod/workshop/upgrade.txt @@ -1,6 +1,10 @@ This files describes API changes in /mod/workshop - activity modules, information provided here is intended especially for developers. +=== 3.4 === + +* workshop_strategy::get_dimensions_info now returns also the scale items (if scales are being used). + === 3.3.2 === * workshop_refresh_events() Now takes two additional parameters to refine the update to a specific instance. This function