MOBILE-3213 assign: Fix not refreshed after copy previous submission
parent
f454ed291f
commit
af38ef2383
|
@ -119,6 +119,25 @@ export class AddonModAssignProvider {
|
||||||
return assign.submissiondrafts;
|
return assign.submissiondrafts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fix some submission status params.
|
||||||
|
*
|
||||||
|
* @param site Site to use.
|
||||||
|
* @param userId User Id (empty for current user).
|
||||||
|
* @param groupId Group Id (empty for all participants).
|
||||||
|
* @param isBlind If blind marking is enabled or not.
|
||||||
|
* @return Object with fixed params.
|
||||||
|
*/
|
||||||
|
protected fixSubmissionStatusParams(site: CoreSite, userId?: number, groupId?: number, isBlind?: boolean)
|
||||||
|
: {userId: number, groupId: number, isBlind: boolean} {
|
||||||
|
|
||||||
|
return {
|
||||||
|
isBlind: !userId ? false : !!isBlind,
|
||||||
|
groupId: site.isVersionGreaterEqualThan('3.5') ? groupId || 0 : 0,
|
||||||
|
userId: userId || site.getUserId(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an assignment by course module ID.
|
* Get an assignment by course module ID.
|
||||||
*
|
*
|
||||||
|
@ -502,24 +521,23 @@ export class AddonModAssignProvider {
|
||||||
getSubmissionStatus(assignId: number, userId?: number, groupId?: number, isBlind?: boolean, filter: boolean = true,
|
getSubmissionStatus(assignId: number, userId?: number, groupId?: number, isBlind?: boolean, filter: boolean = true,
|
||||||
ignoreCache?: boolean, siteId?: string): Promise<AddonModAssignGetSubmissionStatusResult> {
|
ignoreCache?: boolean, siteId?: string): Promise<AddonModAssignGetSubmissionStatusResult> {
|
||||||
|
|
||||||
userId = userId || 0;
|
|
||||||
|
|
||||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||||
groupId = site.isVersionGreaterEqualThan('3.5') ? groupId || 0 : 0;
|
const fixedParams = this.fixSubmissionStatusParams(site, userId, groupId, isBlind);
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
assignid: assignId,
|
assignid: assignId,
|
||||||
userid: userId
|
userid: fixedParams.userId
|
||||||
},
|
},
|
||||||
preSets: CoreSiteWSPreSets = {
|
preSets: CoreSiteWSPreSets = {
|
||||||
cacheKey: this.getSubmissionStatusCacheKey(assignId, userId, groupId, isBlind),
|
cacheKey: this.getSubmissionStatusCacheKey(assignId, fixedParams.userId, fixedParams.groupId,
|
||||||
|
fixedParams.isBlind),
|
||||||
getCacheUsingCacheKey: true, // We use the cache key to take isBlind into account.
|
getCacheUsingCacheKey: true, // We use the cache key to take isBlind into account.
|
||||||
filter: filter,
|
filter: filter,
|
||||||
rewriteurls: filter
|
rewriteurls: filter
|
||||||
};
|
};
|
||||||
|
|
||||||
if (groupId) {
|
if (fixedParams.groupId) {
|
||||||
params['groupid'] = groupId;
|
params['groupid'] = fixedParams.groupId;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ignoreCache) {
|
if (ignoreCache) {
|
||||||
|
@ -578,11 +596,6 @@ export class AddonModAssignProvider {
|
||||||
* @return Cache key.
|
* @return Cache key.
|
||||||
*/
|
*/
|
||||||
protected getSubmissionStatusCacheKey(assignId: number, userId: number, groupId?: number, isBlind?: boolean): string {
|
protected getSubmissionStatusCacheKey(assignId: number, userId: number, groupId?: number, isBlind?: boolean): string {
|
||||||
if (!userId) {
|
|
||||||
isBlind = false;
|
|
||||||
userId = this.sitesProvider.getCurrentSiteUserId();
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.getSubmissionsCacheKey(assignId) + ':' + userId + ':' + (isBlind ? 1 : 0) + ':' + groupId;
|
return this.getSubmissionsCacheKey(assignId) + ':' + userId + ':' + (isBlind ? 1 : 0) + ':' + groupId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -809,7 +822,10 @@ export class AddonModAssignProvider {
|
||||||
invalidateSubmissionStatusData(assignId: number, userId?: number, groupId?: number, isBlind?: boolean, siteId?: string):
|
invalidateSubmissionStatusData(assignId: number, userId?: number, groupId?: number, isBlind?: boolean, siteId?: string):
|
||||||
Promise<any> {
|
Promise<any> {
|
||||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||||
return site.invalidateWsCacheForKey(this.getSubmissionStatusCacheKey(assignId, userId, groupId, isBlind));
|
const fixedParams = this.fixSubmissionStatusParams(site, userId, groupId, isBlind);
|
||||||
|
|
||||||
|
return site.invalidateWsCacheForKey(this.getSubmissionStatusCacheKey(assignId, fixedParams.userId,
|
||||||
|
fixedParams.groupId, fixedParams.isBlind));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue