You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
8.3 KiB

define(["jquery","core/notification","core/str","core/form-autocomplete","core/ajax","mod_assign/grading_form_change_checker"],function(a,b,c,d,e,f){var g=function(e){this._regionSelector=e,this._region=a(e),this._filters=[],this._users=[],this._filteredUsers=[],this._lastXofYUpdate=0,this._firstLoadUsers=!0,this._loadAllUsers(),this._region.find('[data-action="previous-user"]').on("click",this._handlePreviousUser.bind(this)),this._region.find('[data-action="next-user"]').on("click",this._handleNextUser.bind(this)),this._region.find('[data-action="change-user"]').on("change",this._handleChangeUser.bind(this)),this._region.find('[data-region="user-filters"]').on("click",this._toggleExpandFilters.bind(this)),a(document).on("user-changed",this._refreshSelector.bind(this)),a(document).on("done-saving-show-next",this._handleNextUser.bind(this));var f=this._region.find('[data-region="user-filters"]'),g=a(document.getElementById(f.attr("aria-controls")));g.on("change","select",this._filterChanged.bind(this));var h=a('[data-region="grading-navigation-panel"]').data("first-userid");h&&this._selectUserById(h),c.get_string("changeuser","mod_assign").done(function(a){d.enhance("[data-action=change-user]",!1,"mod_assign/participant_selector",a)}).fail(b.exception),a(document).bind("start-loading-user",function(){this._isLoading=!0}.bind(this)),a(document).bind("finish-loading-user",function(){this._isLoading=!1}.bind(this))};return g.prototype._isLoading=!1,g.prototype._regionSelector=null,g.prototype._filters=null,g.prototype._users=null,g.prototype._region=null,g.prototype._lastFilters="",g.prototype._loadAllUsers=function(){var a=this._region.find("[data-action=change-user]"),c=a.attr("data-assignmentid"),d=a.attr("data-groupid"),f=this._region.find('[data-region="configure-filters"]'),g=f.find('select[name="filter"]').val(),h=f.find('select[name="workflowfilter"]');h&&(g+=","+h.val());var i=f.find('select[name="markerfilter"]');return i&&(g+=","+i.val()),this._lastFilters!=g&&(this._lastFilters=g,e.call([{methodname:"mod_assign_list_participants",args:{assignid:c,groupid:d,filter:"",onlyids:!0,tablesort:!0},done:this._usersLoaded.bind(this),fail:b.exception}]),!0)},g.prototype._usersLoaded=function(b){if(this._firstLoadUsers=!1,this._filteredUsers=this._users=b,this._users.length){var c=this._region.find('[data-region="user-filters"]'),d=a(document.getElementById(c.attr("aria-controls")));d.find('select[name="filter"]').trigger("change")}else this._selectNoUser();this._triggerNextUserEvent()},g.prototype._checkClickOutsideConfigureFilters=function(b){var c=this._region.find('[data-region="configure-filters"]');if(!c.is(b.target)&&0===c.has(b.target).length){var d=this._region.find('[data-region="user-filters"]');c.hide(),c.attr("aria-hidden","true"),d.attr("aria-expanded","false"),a(document).unbind("click.mod_assign_grading_navigation")}},g.prototype._updateFilterPreferences=function(b,c,d){var f=[],g=0;if(0==c.length||this._firstLoadUsers){var h=a.Deferred();return h.resolve(),h}for(g=0;g<c.length;g++){var i=c[g];"none"==i&&(i=""),f.push({userid:b,name:d[g],value:i})}return e.call([{methodname:"core_user_set_user_preferences",args:{preferences:f}}])[0]},g.prototype._filterChanged=function(){var d=this._region.find('[data-region="configure-filters"]'),e=d.find("select");this._filters=[],e.each(function(b,c){this._filters.push(a(c).val())}.bind(this));var f=[];d.find("option:checked").each(function(b,c){f[f.length]=a(c).text()}),f.length?this._region.find('[data-region="user-filters"] span').text(f.join(", ")):c.get_string("nofilters","mod_assign").done(function(a){this._region.find('[data-region="user-filters"] span').text(a)}.bind(this)).fail(b.exception);var g=this._region.find("[data-action=change-user]"),h=g.data("currentuserid"),i=["assign_filter","assign_workflowfilter","assign_markerfilter"];this._updateFilterPreferences(h,this._filters,i).done(function(){if(!this._loadAllUsers()){var b=parseInt(g.attr("data-selected")),c=0;a.each(this._filteredUsers,function(a,d){b==d.id&&(c=a)}),this._filteredUsers.length?this._selectU