MDL-56363 mod_assign: Restrictions added for tutors.

If the grader does not have the accessallgroups capability,
or groups mode is set to separate groups and the user is not
a member of the group then no participants are shown.
This commit is contained in:
Adrian Greeve 2016-11-02 13:56:16 +08:00 committed by Eloy Lafuente (stronk7)
parent 6063f62e7d
commit f65db49765
3 changed files with 7 additions and 3 deletions

View File

@ -1 +1 @@
define(["core/ajax","jquery","core/templates"],function(a,b,c){return{processResults:function(a,b){var c=[],d=0;for(d=0;d<b.length;d++)c[d]={value:b[d].id,label:b[d].label};return c},transport:function(d,e,f,g){var h=b(d).attr("data-assignmentid"),i=b('[data-region="configure-filters"] input[type="checkbox"]'),j=[];i.each(function(a,c){j[b(c).attr("name")]=b(c).prop("checked")});var k=a.call([{methodname:"mod_assign_list_participants",args:{assignid:h,groupid:0,filter:e,limit:30,includeenrolments:!1}}]);k[0].then(function(a){var d=[],e=b("[data-showuseridentity]").data("showuseridentity").split(",");b.each(a,function(a,f){var g=f,h=[],i=!0;j.filter_submitted&&!f.submitted&&(i=!1),j.filter_notsubmitted&&f.submitted&&(i=!1),j.filter_requiregrading&&!f.requiregrading&&(i=!1),i&&(b.each(e,function(a,b){"undefined"!=typeof f[b]&&""!==f[b]&&(g.hasidentity=!0,h.push(f[b]))}),g.identity=h.join(", "),d.push(c.render("mod_assign/list_participant_user_summary",g)))}),b.when.apply(b.when,d).then(function(){var c=arguments,d=0;b.each(a,function(a,b){b.label=c[d],d++}),f(a)})},g)}}});
define(["core/ajax","jquery","core/templates"],function(a,b,c){return{processResults:function(a,b){var c=[],d=0;for(d=0;d<b.length;d++)c[d]={value:b[d].id,label:b[d].label};return c},transport:function(d,e,f,g){var h=b(d).attr("data-assignmentid"),i=b(d).attr("data-groupid"),j=b('[data-region="configure-filters"] input[type="checkbox"]'),k=[];j.each(function(a,c){k[b(c).attr("name")]=b(c).prop("checked")});var l=a.call([{methodname:"mod_assign_list_participants",args:{assignid:h,groupid:i,filter:e,limit:30,includeenrolments:!1}}]);l[0].then(function(a){var d=[],e=b("[data-showuseridentity]").data("showuseridentity").split(",");b.each(a,function(a,f){var g=f,h=[],i=!0;k.filter_submitted&&!f.submitted&&(i=!1),k.filter_notsubmitted&&f.submitted&&(i=!1),k.filter_requiregrading&&!f.requiregrading&&(i=!1),i&&(b.each(e,function(a,b){"undefined"!=typeof f[b]&&""!==f[b]&&(g.hasidentity=!0,h.push(f[b]))}),g.identity=h.join(", "),d.push(c.render("mod_assign/list_participant_user_summary",g)))}),b.when.apply(b.when,d).then(function(){var c=arguments,d=0;b.each(a,function(a,b){b.label=c[d],d++}),f(a)})},g)}}});

View File

@ -54,6 +54,7 @@ define(['core/ajax', 'jquery', 'core/templates'], function(ajax, $, templates) {
*/
transport: function(selector, query, success, failure) {
var assignmentid = $(selector).attr('data-assignmentid');
var groupid = $(selector).attr('data-groupid');
var filters = $('[data-region="configure-filters"] input[type="checkbox"]');
var filterstrings = [];
@ -63,7 +64,7 @@ define(['core/ajax', 'jquery', 'core/templates'], function(ajax, $, templates) {
var promise = ajax.call([{
methodname: 'mod_assign_list_participants',
args: {assignid: assignmentid, groupid: 0, filter: query, limit: 30, includeenrolments: false}
args: {assignid: assignmentid, groupid: groupid, filter: query, limit: 30, includeenrolments: false}
}]);
promise[0].then(function(results) {

View File

@ -2568,7 +2568,10 @@ class mod_assign_external extends external_api {
$assign->require_view_grades();
$participants = $assign->list_participants_with_filter_status_and_group($params['groupid']);
$participants = array();
if (groups_group_visible($params['groupid'], $course, $cm)) {
$participants = $assign->list_participants_with_filter_status_and_group($params['groupid']);
}
$userfields = user_get_default_fields();
if (!$params['includeenrolments']) {