@@ -38,24 +38,28 @@ angular.module('mm.core')
3838 * @name $mmGroups#getActivityAllowedGroups
3939 * @param {Number } cmid Course module ID.
4040 * @param {Number } [userid] User ID. If not defined, use current user.
41+ * @param {String } [siteId] Site ID. If not defined, current site.
4142 * @return {Promise } Promise resolved when the groups are retrieved.
4243 */
43- self . getActivityAllowedGroups = function ( cmid , userid ) {
44+ self . getActivityAllowedGroups = function ( cmid , userid , siteId ) {
4445 userid = userid || $mmSite . getUserId ( ) ;
46+ siteId = siteId || $mmSite . getId ( ) ;
47+
48+ return $mmSitesManager . getSite ( siteId ) . then ( function ( site ) {
49+ var params = {
50+ cmid : cmid ,
51+ userid : userid
52+ } ,
53+ preSets = {
54+ cacheKey : getActivityAllowedGroupsCacheKey ( cmid , userid )
55+ } ;
4556
46- var params = {
47- cmid : cmid ,
48- userid : userid
49- } ,
50- preSets = {
51- cacheKey : getActivityAllowedGroupsCacheKey ( cmid , userid )
52- } ;
53-
54- return $mmSite . read ( 'core_group_get_activity_allowed_groups' , params , preSets ) . then ( function ( response ) {
55- if ( ! response || ! response . groups ) {
56- return $q . reject ( ) ;
57- }
58- return response . groups ;
57+ return site . read ( 'core_group_get_activity_allowed_groups' , params , preSets ) . then ( function ( response ) {
58+ if ( ! response || ! response . groups ) {
59+ return $q . reject ( ) ;
60+ }
61+ return response . groups ;
62+ } ) ;
5963 } ) ;
6064 } ;
6165
@@ -76,21 +80,26 @@ angular.module('mm.core')
7680 * @ngdoc method
7781 * @name $mmGroups#getActivityGroupMode
7882 * @param {Number } cmid Course module ID.
83+ * @param {String } [siteId] Site ID. If not defined, current site.
7984 * @return {Promise } Promise resolved when the group mode is retrieved.
8085 */
81- self . getActivityGroupMode = function ( cmid ) {
82- var params = {
83- cmid : cmid
84- } ,
85- preSets = {
86- cacheKey : getActivityGroupModeCacheKey ( cmid )
87- } ;
88-
89- return $mmSite . read ( 'core_group_get_activity_groupmode' , params , preSets ) . then ( function ( response ) {
90- if ( ! response || typeof response . groupmode == 'undefined' ) {
91- return $q . reject ( ) ;
92- }
93- return response . groupmode ;
86+ self . getActivityGroupMode = function ( cmid , siteId ) {
87+ siteId = siteId || $mmSite . getId ( ) ;
88+
89+ return $mmSitesManager . getSite ( siteId ) . then ( function ( site ) {
90+ var params = {
91+ cmid : cmid
92+ } ,
93+ preSets = {
94+ cacheKey : getActivityGroupModeCacheKey ( cmid )
95+ } ;
96+
97+ return site . read ( 'core_group_get_activity_groupmode' , params , preSets ) . then ( function ( response ) {
98+ if ( ! response || typeof response . groupmode == 'undefined' ) {
99+ return $q . reject ( ) ;
100+ }
101+ return response . groupmode ;
102+ } ) ;
94103 } ) ;
95104 } ;
96105
0 commit comments