mirror of
https://github.com/moodle/moodle.git
synced 2025-03-21 08:00:37 +01:00
Merge branch 'MDL-72207-master' of git://github.com/jleyva/moodle
This commit is contained in:
commit
12d6a8c3d9
@ -2316,7 +2316,7 @@ class mod_assign_external extends external_api {
|
||||
'assignid' => new external_value(PARAM_INT, 'assignment instance id'),
|
||||
'userid' => new external_value(PARAM_INT, 'user id (empty for current user)', VALUE_DEFAULT, 0),
|
||||
'groupid' => new external_value(PARAM_INT, 'filter by users in group (used for generating the grading summary).
|
||||
Empty or 0 for all groups information.', VALUE_DEFAULT, 0),
|
||||
0 for all groups information, any other empty value will calculate currrent group.', VALUE_DEFAULT, 0),
|
||||
)
|
||||
);
|
||||
}
|
||||
@ -2368,8 +2368,9 @@ class mod_assign_external extends external_api {
|
||||
throw new moodle_exception('notingroup');
|
||||
}
|
||||
} else {
|
||||
// A null gorups means that following functions will calculate the current group.
|
||||
$groupid = null;
|
||||
// A null group means that following functions will calculate the current group.
|
||||
// A groupid set to 0 means all groups.
|
||||
$groupid = ($params['groupid'] == 0) ? 0 : null;
|
||||
}
|
||||
if ($assign->can_view_grades($groupid)) {
|
||||
$gradingsummary = $assign->get_assign_grading_summary_renderable($groupid);
|
||||
|
@ -2082,6 +2082,7 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
|
||||
* Test get_submission_status using the teacher role.
|
||||
*/
|
||||
public function test_get_submission_status_in_submission_status_for_teacher() {
|
||||
global $DB;
|
||||
$this->resetAfterTest(true);
|
||||
|
||||
list($assign, $instance, $student1, $student2, $teacher, $g1, $g2) = $this->create_submission_for_testing_status(true);
|
||||
@ -2115,11 +2116,22 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
|
||||
$this->assertEquals(0, $result['gradingsummary']['submissionssubmittedcount']); // G2 students didn't submit yet.
|
||||
$this->assertEquals(0, $result['gradingsummary']['submissionsneedgradingcount']); // G2 students didn't submit yet.
|
||||
|
||||
// Should return also 1 participant if we allow the function to auto-select the group.
|
||||
// Should not return information for all users (missing access to all groups capability for non-editing teacher).
|
||||
$result = mod_assign_external::get_submission_status($assign->get_instance()->id);
|
||||
$result = external_api::clean_returnvalue(mod_assign_external::get_submission_status_returns(), $result);
|
||||
$this->assertCount(0, $result['warnings']);
|
||||
$this->assertEquals(1, $result['gradingsummary']['participantcount']);
|
||||
$this->assertFalse(isset($result['gradingsummary']));
|
||||
|
||||
// Should return all participants if we grant accessallgroups capability to the normal teacher role.
|
||||
$context = context_course::instance($assign->get_instance()->course);
|
||||
$teacherrole = $DB->get_record('role', array('shortname' => 'teacher'));
|
||||
assign_capability('moodle/site:accessallgroups', CAP_ALLOW, $teacherrole->id, $context->id, true);
|
||||
accesslib_clear_all_caches_for_unit_testing();
|
||||
|
||||
$result = mod_assign_external::get_submission_status($assign->get_instance()->id);
|
||||
$result = external_api::clean_returnvalue(mod_assign_external::get_submission_status_returns(), $result);
|
||||
$this->assertCount(0, $result['warnings']);
|
||||
$this->assertEquals(2, $result['gradingsummary']['participantcount']);
|
||||
$this->assertEquals(0, $result['gradingsummary']['submissiondraftscount']);
|
||||
$this->assertEquals(1, $result['gradingsummary']['submissionssubmittedcount']); // One student from G1 submitted.
|
||||
$this->assertEquals(1, $result['gradingsummary']['submissionsneedgradingcount']); // One student from G1 submitted.
|
||||
|
Loading…
x
Reference in New Issue
Block a user