mirror of
https://github.com/moodle/moodle.git
synced 2025-03-21 08:00:37 +01:00
MDL-66113 assign: Apply user overrides in get_submission_status WS
This commit is contained in:
parent
1c3efe48f8
commit
0b9f2215d0
@ -2350,6 +2350,8 @@ class mod_assign_external extends external_api {
|
||||
throw new required_capability_exception($context, 'mod/assign:viewgrades', 'nopermission', '');
|
||||
}
|
||||
|
||||
$assign->update_effective_access($user->id);
|
||||
|
||||
$gradingsummary = $lastattempt = $feedback = $previousattempts = null;
|
||||
|
||||
// Get the renderable since it contais all the info we need.
|
||||
|
@ -2228,6 +2228,65 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
|
||||
$this->assertEquals($teacher->id, $result['feedback']['grade']['grader']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get_submission_status with override for student.
|
||||
*/
|
||||
public function test_get_submission_status_with_override() {
|
||||
global $DB;
|
||||
|
||||
$this->resetAfterTest(true);
|
||||
|
||||
list($assign, $instance, $student1, $student2, $teacher, $g1, $g2) = $this->create_submission_for_testing_status();
|
||||
|
||||
$overridedata = new \stdClass();
|
||||
$overridedata->assignid = $assign->get_instance()->id;
|
||||
$overridedata->userid = $student1->id;
|
||||
$overridedata->allowsubmissionsfromdate = time() + YEARSECS;
|
||||
$DB->insert_record('assign_overrides', $overridedata);
|
||||
|
||||
$result = mod_assign_external::get_submission_status($assign->get_instance()->id);
|
||||
// We expect debugging because of the $PAGE object, this won't happen in a normal WS request.
|
||||
$this->assertDebuggingCalled();
|
||||
$result = external_api::clean_returnvalue(mod_assign_external::get_submission_status_returns(), $result);
|
||||
|
||||
$this->assertCount(0, $result['warnings']);
|
||||
$this->assertFalse(isset($result['gradingsummary']));
|
||||
$this->assertFalse(isset($result['feedback']));
|
||||
$this->assertFalse(isset($result['previousattempts']));
|
||||
|
||||
$this->assertTrue($result['lastattempt']['submissionsenabled']);
|
||||
$this->assertFalse($result['lastattempt']['canedit']); // False because of override.
|
||||
$this->assertFalse($result['lastattempt']['cansubmit']);
|
||||
$this->assertFalse($result['lastattempt']['locked']);
|
||||
$this->assertFalse($result['lastattempt']['graded']);
|
||||
$this->assertEmpty($result['lastattempt']['extensionduedate']);
|
||||
$this->assertFalse($result['lastattempt']['blindmarking']);
|
||||
$this->assertCount(0, $result['lastattempt']['submissiongroupmemberswhoneedtosubmit']);
|
||||
$this->assertEquals('notgraded', $result['lastattempt']['gradingstatus']);
|
||||
|
||||
// Same assignment but user without override.
|
||||
$this->setUser($student2);
|
||||
|
||||
$result = mod_assign_external::get_submission_status($assign->get_instance()->id);
|
||||
$result = external_api::clean_returnvalue(mod_assign_external::get_submission_status_returns(), $result);
|
||||
|
||||
// The submission is now in draft mode.
|
||||
$this->assertCount(0, $result['warnings']);
|
||||
$this->assertFalse(isset($result['gradingsummary']));
|
||||
$this->assertFalse(isset($result['feedback']));
|
||||
$this->assertFalse(isset($result['previousattempts']));
|
||||
|
||||
$this->assertTrue($result['lastattempt']['submissionsenabled']);
|
||||
$this->assertTrue($result['lastattempt']['canedit']); // True because there is not override for this user.
|
||||
$this->assertFalse($result['lastattempt']['cansubmit']);
|
||||
$this->assertFalse($result['lastattempt']['locked']);
|
||||
$this->assertFalse($result['lastattempt']['graded']);
|
||||
$this->assertEmpty($result['lastattempt']['extensionduedate']);
|
||||
$this->assertFalse($result['lastattempt']['blindmarking']);
|
||||
$this->assertCount(0, $result['lastattempt']['submissiongroupmemberswhoneedtosubmit']);
|
||||
$this->assertEquals('notgraded', $result['lastattempt']['gradingstatus']);
|
||||
}
|
||||
|
||||
/**
|
||||
* get_participant should throw an excaption if the requested assignment doesn't exist.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user