Skip to content

Commit

Permalink
Merge branch 'MDL-57604-master' of git://github.com/danpoltawski/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
stronk7 committed Jan 18, 2017
2 parents 2156bb4 + 76bab36 commit 3610259
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 26 deletions.
2 changes: 1 addition & 1 deletion mod/assign/amd/build/participant_selector.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 13 additions & 25 deletions mod/assign/amd/src/participant_selector.js
Expand Up @@ -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;
},

/**
Expand All @@ -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(',');

Expand All @@ -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);
}
};
});

0 comments on commit 3610259

Please sign in to comment.