File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
src/addons/block/courselist/services Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,8 @@ import { Injectable } from '@angular/core';
1616import { CoreBlockHandlerData } from '@features/block/services/block-delegate' ;
1717import { CoreBlockBaseHandler } from '@features/block/classes/base-block-handler' ;
1818import { makeSingleton } from '@singletons' ;
19+ import { CoreCourses } from '@features/courses/services/courses' ;
20+ import { CoreSites } from '@services/sites' ;
1921
2022/**
2123 * Block handler.
@@ -32,6 +34,22 @@ export class AddonBlockCourseListHandlerService extends CoreBlockBaseHandler {
3234 async getDisplayData ( ) : Promise < CoreBlockHandlerData > {
3335 const { CoreBlockOnlyTitleComponent } = await import ( '@features/block/components/only-title-block/only-title-block' ) ;
3436
37+ let showCategories = CoreSites . getRequiredCurrentSite ( ) . isAdmin ( ) ;
38+ if ( ! showCategories ) {
39+ const courses = await CoreCourses . getUserCourses ( ) ;
40+
41+ showCategories = courses . length === 0 ;
42+ }
43+
44+ if ( showCategories ) { // Admins and users without courses, show categories.
45+ return {
46+ title : 'core.courses.categories' ,
47+ class : 'addon-block-course-list' ,
48+ component : CoreBlockOnlyTitleComponent ,
49+ link : 'courses/categories' ,
50+ } ;
51+ }
52+
3553 return {
3654 title : 'core.courses.mycourses' ,
3755 class : 'addon-block-course-list' ,
You can’t perform that action at this time.
0 commit comments