Skip to content

Commit

Permalink
Merge branch 'MDL-60378-master' of git://github.com/jleyva/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
David Monllao committed Oct 19, 2017
2 parents eef0ce9 + fe7b3e7 commit 23892d0
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 1 deletion.
15 changes: 15 additions & 0 deletions mod/workshop/classes/external.php
Original file line number Diff line number Diff line change
Expand Up @@ -1280,6 +1280,10 @@ public static function get_assessment_form_definition($assessmentid, $mode = 'as
}
}

// Get dimensions info.
$grader = $workshop->grading_strategy_instance();
$result['dimensionsinfo'] = $grader->get_dimensions_info();

return $result;
}

Expand Down Expand Up @@ -1318,6 +1322,17 @@ public static function get_assessment_form_definition_returns() {
)
), '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()
)
);
Expand Down
1 change: 1 addition & 0 deletions mod/workshop/form/accumulative/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ public function get_dimensions_info() {
// 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;
Expand Down
2 changes: 1 addition & 1 deletion mod/workshop/form/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function form_ready();
/**
* 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();

Expand Down
7 changes: 7 additions & 0 deletions mod/workshop/tests/external_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -1312,6 +1312,13 @@ public function test_get_assessment_form_definition_reviewer_new_assessment() {
$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']));
}
}

/**
Expand Down
4 changes: 4 additions & 0 deletions mod/workshop/upgrade.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 23892d0

Please sign in to comment.