MOBILE-4616 feedback: Workaround for incorrect URLs in page after submit
parent
ce87157622
commit
374929008e
|
@ -20,6 +20,7 @@ import { CoreCourseContentsPage } from '@features/course/pages/contents/contents
|
||||||
import { IonContent } from '@ionic/angular';
|
import { IonContent } from '@ionic/angular';
|
||||||
import { CoreGroupInfo, CoreGroups } from '@services/groups';
|
import { CoreGroupInfo, CoreGroups } from '@services/groups';
|
||||||
import { CoreNavigator } from '@services/navigator';
|
import { CoreNavigator } from '@services/navigator';
|
||||||
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreText } from '@singletons/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { CoreTimeUtils } from '@services/utils/time';
|
import { CoreTimeUtils } from '@services/utils/time';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
|
@ -202,6 +203,8 @@ export class AddonModFeedbackIndexComponent extends CoreCourseModuleMainActivity
|
||||||
try {
|
try {
|
||||||
this.feedback = await AddonModFeedback.getFeedback(this.courseId, this.module.id);
|
this.feedback = await AddonModFeedback.getFeedback(this.courseId, this.module.id);
|
||||||
|
|
||||||
|
await this.fixPageAfterSubmitFileUrls();
|
||||||
|
|
||||||
this.description = this.feedback.intro;
|
this.description = this.feedback.intro;
|
||||||
this.dataRetrieved.emit(this.feedback);
|
this.dataRetrieved.emit(this.feedback);
|
||||||
|
|
||||||
|
@ -244,6 +247,29 @@ export class AddonModFeedbackIndexComponent extends CoreCourseModuleMainActivity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fix incorrect file URLs in page after submit text.
|
||||||
|
*
|
||||||
|
* See bug MDL-83474.
|
||||||
|
*/
|
||||||
|
protected async fixPageAfterSubmitFileUrls(): Promise<void> {
|
||||||
|
const site = await CoreSites.getSite(this.siteId);
|
||||||
|
|
||||||
|
if (!site.isVersionGreaterEqualThan('4.2')
|
||||||
|
|| !this.feedback?.page_after_submit
|
||||||
|
|| !this.feedback.pageaftersubmitfiles) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Replace file URLs that do not have the /0/ in the path.
|
||||||
|
// Subdirectories are not allowed in this file area, so the sets of correct and incorrect URLs will never overlap.
|
||||||
|
for (const file of this.feedback.pageaftersubmitfiles) {
|
||||||
|
const incorrectUrl = file.fileurl.replace('/page_after_submit/0/', '/page_after_submit/');
|
||||||
|
const incorrectUrlRegex = new RegExp(CoreText.escapeForRegex(incorrectUrl), 'g');
|
||||||
|
this.feedback.page_after_submit = this.feedback.page_after_submit.replace(incorrectUrlRegex, file.fileurl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience function to get feedback overview data.
|
* Convenience function to get feedback overview data.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue