Merge branch 'MDL-57604-master' of git://github.com/danpoltawski/moodle

This commit is contained in:
Eloy Lafuente (stronk7) 2017-01-18 00:16:53 +01:00
commit 36102596d7
2 changed files with 14 additions and 26 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(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)}}});
define(["core/ajax","jquery","core/templates"],function(a,b,c){return{processResults:function(a,b){return b},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")}),a.call([{methodname:"mod_assign_list_participants",args:{assignid:h,groupid:i,filter:e,limit:30,includeenrolments:!1}}])[0].then(function(a){var d=[],e=b("[data-showuseridentity]").data("showuseridentity").split(",");return 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).then(function(a){return{value:f.id,label:a}})))}),b.when.apply(b,d)}).then(function(){var a=Array.prototype.slice.call(arguments);f(a)})["catch"](g)}}});

View File

@ -35,12 +35,7 @@ define(['core/ajax', 'jquery', 'core/templates'], function(ajax, $, templates) {
* @return {Array}
*/
processResults: function(selector, data) {
var results = [];
var i = 0;
for (i = 0; i < data.length; i++) {
results[i] = {value: data[i].id, label: data[i].label};
}
return results;
return data;
},
/**
@ -62,12 +57,10 @@ define(['core/ajax', 'jquery', 'core/templates'], function(ajax, $, templates) {
filterstrings[$(element).attr('name')] = $(element).prop('checked');
});
var promise = ajax.call([{
ajax.call([{
methodname: 'mod_assign_list_participants',
args: {assignid: assignmentid, groupid: groupid, filter: query, limit: 30, includeenrolments: false}
}]);
promise[0].then(function(results) {
}])[0].then(function(results) {
var promises = [];
var identityfields = $('[data-showuseridentity]').data('showuseridentity').split(',');
@ -94,23 +87,18 @@ define(['core/ajax', 'jquery', 'core/templates'], function(ajax, $, templates) {
}
});
ctx.identity = identity.join(', ');
promises.push(templates.render('mod_assign/list_participant_user_summary', ctx));
promises.push(templates.render('mod_assign/list_participant_user_summary', ctx).then(function(html) {
return {value: user.id, label: html};
}));
}
});
// When all the templates have been rendered, call the success handler.
$.when.apply($.when, promises).then(function() {
var args = arguments,
i = 0;
$.each(results, function(index, user) {
user.label = args[i];
i++;
});
success(results);
});
}, failure);
// Do the dance for $.when()
return $.when.apply($, promises);
}).then(function() {
// Undo the $.when() dance from arguments object into an array..
var users = Array.prototype.slice.call(arguments);
success(users);
}).catch(failure);
}
};
});