Merge branch 'MDL-60378-master' of git://github.com/jleyva/moodle

This commit is contained in:
David Monllao 2017-10-19 14:06:26 +02:00
commit 23892d0843
5 changed files with 28 additions and 1 deletions

View File

@ -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()
)
);

View File

@ -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;

View File

@ -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();

View File

@ -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']));
}
}
/**

View File

@ -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