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

This commit is contained in:
Eloy Lafuente (stronk7) 2019-02-28 01:19:13 +01:00
commit 3c1bb2334d
2 changed files with 15 additions and 3 deletions

View File

@ -115,7 +115,8 @@ class mod_assign_external extends external_api {
try {
$context = context_module::instance($cm->id);
self::validate_context($context);
require_capability('mod/assign:grade', $context);
$assign = new assign($context, null, null);
$assign->require_view_grades();
} catch (Exception $e) {
$requestedassignmentids = array_diff($requestedassignmentids, array($cm->instance));
$warning = array();
@ -734,8 +735,8 @@ class mod_assign_external extends external_api {
try {
$context = context_module::instance($cm->id);
self::validate_context($context);
require_capability('mod/assign:grade', $context);
$assign = new assign($context, null, null);
$assign->require_view_grades();
$assigns[] = $assign;
} catch (Exception $e) {
$warnings[] = array(

View File

@ -61,7 +61,7 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
$context = context_course::instance($course->id);
$roleid = $this->assignUserCapability('moodle/course:viewparticipants', $context->id, 3);
$context = context_module::instance($assign->cmid);
$this->assignUserCapability('mod/assign:grade', $context->id, $roleid);
$this->assignUserCapability('mod/assign:viewgrades', $context->id, $roleid);
// Create the teacher's enrolment record.
$userenrolmentdata['status'] = 0;
@ -434,6 +434,17 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
$this->assertEquals($sid, $submission['id']);
$this->assertCount(1, $submission['plugins']);
$this->assertEquals('notgraded', $submission['gradingstatus']);
// Test locking the context.
set_config('contextlocking', 1);
$context = context_course::instance($course1->id);
$context->set_locked(true);
$this->setUser($teacher);
$assignmentids[] = $assign1->id;
$result = mod_assign_external::get_submissions($assignmentids);
$result = external_api::clean_returnvalue(mod_assign_external::get_submissions_returns(), $result);
$this->assertEquals(1, count($result['assignments']));
}
/**