commit
						157979e25e
					
				| @ -24,6 +24,7 @@ import { CoreUtils } from '@services/utils/utils'; | ||||
| import { makeSingleton } from '@singletons'; | ||||
| 
 | ||||
| import { AddonModForumModuleHandlerService } from './module'; | ||||
| import { isSafeNumber } from '@/core/utils/types'; | ||||
| 
 | ||||
| /** | ||||
|  * Handler for forum push notifications clicks. | ||||
| @ -44,7 +45,8 @@ export class AddonModForumPushClickHandlerService implements CorePushNotificatio | ||||
|     async handles(notification: NotificationData): Promise<boolean> { | ||||
|         return CoreUtils.isTrueOrOne(notification.notif) | ||||
|             && notification.moodlecomponent == 'mod_forum' | ||||
|             && notification.name == 'posts'; | ||||
|             && notification.name == 'posts' | ||||
|             && !!(notification.contexturl || notification.customdata?.postid); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
| @ -58,13 +60,17 @@ export class AddonModForumPushClickHandlerService implements CorePushNotificatio | ||||
|         const data = notification.customdata || {}; | ||||
|         const courseId = Number(notification.courseid); | ||||
|         const discussionId = Number(contextUrlParams.d || data.discussionid); | ||||
|         const cmId = Number(data.cmid); | ||||
|         const cmId = data.cmid && Number(data.cmid); | ||||
|         const pageParams: Params = { | ||||
|             forumId: Number(data.instance), | ||||
|             cmId, | ||||
|             courseId, | ||||
|         }; | ||||
| 
 | ||||
|         if (!isSafeNumber(discussionId)) { | ||||
|             return; | ||||
|         } | ||||
| 
 | ||||
|         if (data.postid || contextUrlParams.urlHash) { | ||||
|             pageParams.postId = Number(data.postid || contextUrlParams.urlHash.replace('p', '')); | ||||
|         } | ||||
|  | ||||
| @ -12,6 +12,7 @@ | ||||
| // See the License for the specific language governing permissions and
 | ||||
| // limitations under the License.
 | ||||
| 
 | ||||
| import { isSafeNumber } from '@/core/utils/types'; | ||||
| import { Injectable } from '@angular/core'; | ||||
| 
 | ||||
| import { CoreGrades } from '@features/grades/services/grades'; | ||||
| @ -38,8 +39,12 @@ export class AddonModLessonPushClickHandlerService implements CorePushNotificati | ||||
|      * @returns Whether the notification click is handled by this handler. | ||||
|      */ | ||||
|     async handles(notification: NotificationData): Promise<boolean> { | ||||
|         if (CoreUtils.isTrueOrOne(notification.notif) && notification.moodlecomponent == 'mod_lesson' && | ||||
|                 notification.name == 'graded_essay') { | ||||
|         if ( | ||||
|             CoreUtils.isTrueOrOne(notification.notif) && | ||||
|             notification.moodlecomponent == 'mod_lesson' && | ||||
|             notification.name == 'graded_essay' && | ||||
|             notification.customdata?.cmid | ||||
|         ) { | ||||
| 
 | ||||
|             return CoreGrades.isPluginEnabledForCourse(Number(notification.courseid), notification.site); | ||||
|         } | ||||
| @ -53,11 +58,15 @@ export class AddonModLessonPushClickHandlerService implements CorePushNotificati | ||||
|      * @param notification The notification to check. | ||||
|      * @returns Promise resolved when done. | ||||
|      */ | ||||
|     handleClick(notification: NotificationData): Promise<void> { | ||||
|     async handleClick(notification: NotificationData): Promise<void> { | ||||
|         const data = notification.customdata || {}; | ||||
|         const courseId = Number(notification.courseid); | ||||
|         const moduleId = Number(data.cmid); | ||||
| 
 | ||||
|         if (!isSafeNumber(moduleId)) { | ||||
|             return; | ||||
|         } | ||||
| 
 | ||||
|         return CoreGradesHelper.goToGrades(courseId, undefined, moduleId, notification.site); | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -22,6 +22,7 @@ import { CoreUtils } from '@services/utils/utils'; | ||||
| import { makeSingleton } from '@singletons'; | ||||
| import { AddonModQuiz } from '../quiz'; | ||||
| import { AddonModQuizHelper } from '../quiz-helper'; | ||||
| import { isSafeNumber } from '@/core/utils/types'; | ||||
| 
 | ||||
| /** | ||||
|  * Handler for quiz push notifications clicks. | ||||
| @ -43,7 +44,8 @@ export class AddonModQuizPushClickHandlerService implements CorePushNotification | ||||
|      */ | ||||
|     async handles(notification: AddonModQuizPushNotificationData): Promise<boolean> { | ||||
|         return CoreUtils.isTrueOrOne(notification.notif) && notification.moodlecomponent == 'mod_quiz' && | ||||
|                 this.SUPPORTED_NAMES.indexOf(notification.name ?? '') != -1; | ||||
|                 this.SUPPORTED_NAMES.indexOf(notification.name ?? '') !== -1 && | ||||
|                 !!(notification.customdata?.instance || notification.contexturl); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
| @ -57,7 +59,12 @@ export class AddonModQuizPushClickHandlerService implements CorePushNotification | ||||
|         const data = notification.customdata || {}; | ||||
|         const courseId = Number(notification.courseid); | ||||
| 
 | ||||
|         if (notification.name == 'submission') { | ||||
|         if ( | ||||
|             notification.name === 'submission' && | ||||
|             data.instance !== undefined && | ||||
|             contextUrlParams.attempt !== undefined && | ||||
|             contextUrlParams.page !== undefined | ||||
|         ) { | ||||
|             // A student made a submission, go to view the attempt.
 | ||||
|             return AddonModQuizHelper.handleReviewLink( | ||||
|                 Number(contextUrlParams.attempt), | ||||
| @ -69,6 +76,9 @@ export class AddonModQuizPushClickHandlerService implements CorePushNotification | ||||
| 
 | ||||
|         // Open the activity.
 | ||||
|         const moduleId = Number(contextUrlParams.id); | ||||
|         if (!isSafeNumber(moduleId)) { | ||||
|             return; | ||||
|         } | ||||
| 
 | ||||
|         await CoreUtils.ignoreErrors(AddonModQuiz.invalidateContent(moduleId, courseId, notification.site)); | ||||
| 
 | ||||
|  | ||||
| @ -216,7 +216,7 @@ export class CoreFilterHelperProvider { | ||||
|                 options.filter = true; | ||||
| 
 | ||||
|                 // We cannot check which filters are available, apply them all.
 | ||||
|                 return CoreFilterDelegate.getEnabledFilters(contextLevel, instanceId); | ||||
|                 return await CoreFilterDelegate.getEnabledFilters(contextLevel, instanceId); | ||||
|             } | ||||
| 
 | ||||
|             const courseId = options.courseId; | ||||
| @ -239,21 +239,21 @@ export class CoreFilterHelperProvider { | ||||
|                 // Get all the modules filters with a single call to decrease the number of WS calls.
 | ||||
|                 const getFilters = () => this.getCourseModulesContexts(courseId, siteId); | ||||
| 
 | ||||
|                 return this.getCacheableFilters(contextLevel, instanceId, getFilters, options, site); | ||||
|                 return await this.getCacheableFilters(contextLevel, instanceId, getFilters, options, site); | ||||
| 
 | ||||
|             } else if (contextLevel == 'course') { | ||||
|                 // If enrolled, get all enrolled courses filters with a single call to decrease number of WS calls.
 | ||||
|                 const getFilters = () => this.getCourseContexts(instanceId, siteId); | ||||
| 
 | ||||
|                 return this.getCacheableFilters(contextLevel, instanceId, getFilters, options, site); | ||||
|                 return await this.getCacheableFilters(contextLevel, instanceId, getFilters, options, site); | ||||
|             } else if (contextLevel == 'block' && courseId && CoreCourse.canGetCourseBlocks(site)) { | ||||
|                 // Get all the course blocks filters with a single call to decrease number of WS calls.
 | ||||
|                 const getFilters = () => this.getBlocksContexts(courseId, siteId); | ||||
| 
 | ||||
|                 return this.getCacheableFilters(contextLevel, instanceId, getFilters, options, site); | ||||
|                 return await this.getCacheableFilters(contextLevel, instanceId, getFilters, options, site); | ||||
|             } | ||||
| 
 | ||||
|             return CoreFilter.getAvailableInContext(contextLevel, instanceId, siteId); | ||||
|             return await CoreFilter.getAvailableInContext(contextLevel, instanceId, siteId); | ||||
|         } catch (error) { | ||||
|             this.logger.error('Error getting filters, return an empty array', error, contextLevel, instanceId); | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user