@@ -20,6 +20,7 @@ import { CoreCourseContentsPage } from '@features/course/pages/contents/contents
2020import { IonContent } from '@ionic/angular' ;
2121import { CoreGroupInfo , CoreGroups } from '@services/groups' ;
2222import { CoreNavigator } from '@services/navigator' ;
23+ import { CoreSites } from '@services/sites' ;
2324import { CoreText } from '@singletons/text' ;
2425import { CoreTimeUtils } from '@services/utils/time' ;
2526import { CoreUtils } from '@services/utils/utils' ;
@@ -202,6 +203,8 @@ export class AddonModFeedbackIndexComponent extends CoreCourseModuleMainActivity
202203 try {
203204 this . feedback = await AddonModFeedback . getFeedback ( this . courseId , this . module . id ) ;
204205
206+ await this . fixPageAfterSubmitFileUrls ( ) ;
207+
205208 this . description = this . feedback . intro ;
206209 this . dataRetrieved . emit ( this . feedback ) ;
207210
@@ -244,6 +247,29 @@ export class AddonModFeedbackIndexComponent extends CoreCourseModuleMainActivity
244247 }
245248 }
246249
250+ /**
251+ * Fix incorrect file URLs in page after submit text.
252+ *
253+ * See bug MDL-83474.
254+ */
255+ protected async fixPageAfterSubmitFileUrls ( ) : Promise < void > {
256+ const site = await CoreSites . getSite ( this . siteId ) ;
257+
258+ if ( ! site . isVersionGreaterEqualThan ( '4.2' )
259+ || ! this . feedback ?. page_after_submit
260+ || ! this . feedback . pageaftersubmitfiles ) {
261+ return ;
262+ }
263+
264+ // Replace file URLs that do not have the /0/ in the path.
265+ // Subdirectories are not allowed in this file area, so the sets of correct and incorrect URLs will never overlap.
266+ for ( const file of this . feedback . pageaftersubmitfiles ) {
267+ const incorrectUrl = file . fileurl . replace ( '/page_after_submit/0/' , '/page_after_submit/' ) ;
268+ const incorrectUrlRegex = new RegExp ( CoreText . escapeForRegex ( incorrectUrl ) , 'g' ) ;
269+ this . feedback . page_after_submit = this . feedback . page_after_submit . replace ( incorrectUrlRegex , file . fileurl ) ;
270+ }
271+ }
272+
247273 /**
248274 * Convenience function to get feedback overview data.
249275 */
0 commit comments