forked from EVOgeek/Vmeda.Online
		
	
						commit
						ab390098db
					
				| @ -14,7 +14,7 @@ | ||||
|     </ion-toolbar> | ||||
| </ion-header> | ||||
| <ion-content> | ||||
|     <ion-refresher slot="fixed" [disabled]="!assignComponent?.loaded" (ionRefresh)="assignComponent?.doRefresh($event)"> | ||||
|     <ion-refresher slot="fixed" [disabled]="!activityComponent?.loaded" (ionRefresh)="activityComponent?.doRefresh($event)"> | ||||
|         <ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content> | ||||
|     </ion-refresher> | ||||
| 
 | ||||
|  | ||||
| @ -12,11 +12,9 @@ | ||||
| // See the License for the specific language governing permissions and
 | ||||
| // limitations under the License.
 | ||||
| 
 | ||||
| import { Component, OnInit, ViewChild } from '@angular/core'; | ||||
| import { CoreCourseWSModule } from '@features/course/services/course'; | ||||
| import { CoreNavigator } from '@services/navigator'; | ||||
| import { Component, ViewChild } from '@angular/core'; | ||||
| import { CoreCourseModuleMainActivityPage } from '@features/course/classes/main-activity-page'; | ||||
| import { AddonModAssignIndexComponent } from '../../components/index/index'; | ||||
| import { AddonModAssignAssign } from '../../services/assign'; | ||||
| 
 | ||||
| /** | ||||
|  * Page that displays an assign. | ||||
| @ -25,44 +23,8 @@ import { AddonModAssignAssign } from '../../services/assign'; | ||||
|     selector: 'page-addon-mod-assign-index', | ||||
|     templateUrl: 'index.html', | ||||
| }) | ||||
| export class AddonModAssignIndexPage implements OnInit { | ||||
| export class AddonModAssignIndexPage extends CoreCourseModuleMainActivityPage<AddonModAssignIndexComponent> { | ||||
| 
 | ||||
|     @ViewChild(AddonModAssignIndexComponent) assignComponent?: AddonModAssignIndexComponent; | ||||
| 
 | ||||
|     title?: string; | ||||
|     module?: CoreCourseWSModule; | ||||
|     courseId?: number; | ||||
| 
 | ||||
|     /** | ||||
|      * Component being initialized. | ||||
|      */ | ||||
|     ngOnInit(): void { | ||||
|         this.module = CoreNavigator.getRouteParam('module'); | ||||
|         this.courseId = CoreNavigator.getRouteNumberParam('courseId'); | ||||
|         this.title = this.module?.name; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Update some data based on the assign instance. | ||||
|      * | ||||
|      * @param assign Assign instance. | ||||
|      */ | ||||
|     updateData(assign: AddonModAssignAssign): void { | ||||
|         this.title = assign.name || this.title; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * User entered the page. | ||||
|      */ | ||||
|     ionViewDidEnter(): void { | ||||
|         this.assignComponent?.ionViewDidEnter(); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * User left the page. | ||||
|      */ | ||||
|     ionViewDidLeave(): void { | ||||
|         this.assignComponent?.ionViewDidLeave(); | ||||
|     } | ||||
|     @ViewChild(AddonModAssignIndexComponent) activityComponent?: AddonModAssignIndexComponent; | ||||
| 
 | ||||
| } | ||||
|  | ||||
| @ -14,15 +14,25 @@ | ||||
| 
 | ||||
| import { NgModule } from '@angular/core'; | ||||
| import { RouterModule, Routes } from '@angular/router'; | ||||
| import { CoreSharedModule } from '@/core/shared.module'; | ||||
| import { AddonModBookComponentsModule } from './components/components.module'; | ||||
| import { AddonModBookIndexPage } from './pages/index/index.page'; | ||||
| 
 | ||||
| const routes: Routes = [ | ||||
|     { | ||||
|         path: ':courseId/:cmId', | ||||
|         loadChildren: () => import('./pages/index/index.module').then( m => m.AddonModBookIndexPageModule), | ||||
|         component: AddonModBookIndexPage, | ||||
|     }, | ||||
| ]; | ||||
| 
 | ||||
| @NgModule({ | ||||
|     imports: [RouterModule.forChild(routes)], | ||||
|     imports: [ | ||||
|         RouterModule.forChild(routes), | ||||
|         CoreSharedModule, | ||||
|         AddonModBookComponentsModule, | ||||
|     ], | ||||
|     declarations: [ | ||||
|         AddonModBookIndexPage, | ||||
|     ], | ||||
| }) | ||||
| export class AddonModBookLazyModule {} | ||||
|  | ||||
| @ -13,7 +13,7 @@ | ||||
|     </ion-toolbar> | ||||
| </ion-header> | ||||
| <ion-content> | ||||
|     <ion-refresher slot="fixed" [disabled]="!bookComponent?.loaded" (ionRefresh)="bookComponent?.doRefresh($event)"> | ||||
|     <ion-refresher slot="fixed" [disabled]="!activityComponent?.loaded" (ionRefresh)="activityComponent?.doRefresh($event)"> | ||||
|         <ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content> | ||||
|     </ion-refresher> | ||||
| 
 | ||||
|  | ||||
| @ -13,10 +13,9 @@ | ||||
| // limitations under the License.
 | ||||
| 
 | ||||
| import { Component, OnInit, ViewChild } from '@angular/core'; | ||||
| import { CoreCourseWSModule } from '@features/course/services/course'; | ||||
| import { CoreCourseModuleMainActivityPage } from '@features/course/classes/main-activity-page'; | ||||
| import { CoreNavigator } from '@services/navigator'; | ||||
| import { AddonModBookIndexComponent } from '../../components/index/index'; | ||||
| import { AddonModBookBookWSData } from '../../services/book'; | ||||
| 
 | ||||
| /** | ||||
|  * Page that displays a book. | ||||
| @ -25,33 +24,18 @@ import { AddonModBookBookWSData } from '../../services/book'; | ||||
|     selector: 'page-addon-mod-book-index', | ||||
|     templateUrl: 'index.html', | ||||
| }) | ||||
| export class AddonModBookIndexPage implements OnInit { | ||||
| export class AddonModBookIndexPage extends CoreCourseModuleMainActivityPage<AddonModBookIndexComponent> implements OnInit { | ||||
| 
 | ||||
|     @ViewChild(AddonModBookIndexComponent) bookComponent?: AddonModBookIndexComponent; | ||||
|     @ViewChild(AddonModBookIndexComponent) activityComponent?: AddonModBookIndexComponent; | ||||
| 
 | ||||
|     title?: string; | ||||
|     module?: CoreCourseWSModule; | ||||
|     courseId?: number; | ||||
|     chapterId?: number; | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Component being initialized. | ||||
|      */ | ||||
|     ngOnInit(): void { | ||||
|         this.module = CoreNavigator.getRouteParam('module'); | ||||
|         this.courseId = CoreNavigator.getRouteNumberParam('courseId'); | ||||
|         super.ngOnInit(); | ||||
|         this.chapterId = CoreNavigator.getRouteNumberParam('chapterId'); | ||||
|         this.title = this.module?.name; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Update some data based on the book instance. | ||||
|      * | ||||
|      * @param book Book instance. | ||||
|      */ | ||||
|     updateData(book: AddonModBookBookWSData): void { | ||||
|         this.title = book.name || this.title; | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| @ -13,28 +13,22 @@ | ||||
| // limitations under the License.
 | ||||
| 
 | ||||
| import { NgModule } from '@angular/core'; | ||||
| import { RouterModule, Routes } from '@angular/router'; | ||||
| 
 | ||||
| import { CoreSharedModule } from '@/core/shared.module'; | ||||
| import { AddonModPageComponentsModule } from '../../components/components.module'; | ||||
| import { AddonModPageIndexPage } from './index'; | ||||
| import { CoreCourseComponentsModule } from '@features/course/components/components.module'; | ||||
| 
 | ||||
| const routes: Routes = [ | ||||
|     { | ||||
|         path: '', | ||||
|         component: AddonModPageIndexPage, | ||||
|     }, | ||||
| ]; | ||||
| import { AddonModFolderIndexComponent } from './index/index'; | ||||
| 
 | ||||
| @NgModule({ | ||||
|     imports: [ | ||||
|         RouterModule.forChild(routes), | ||||
|         CoreSharedModule, | ||||
|         AddonModPageComponentsModule, | ||||
|     ], | ||||
|     declarations: [ | ||||
|         AddonModPageIndexPage, | ||||
|         AddonModFolderIndexComponent, | ||||
|     ], | ||||
|     imports: [ | ||||
|         CoreSharedModule, | ||||
|         CoreCourseComponentsModule, | ||||
|     ], | ||||
|     exports: [ | ||||
|         AddonModFolderIndexComponent, | ||||
|     ], | ||||
|     exports: [RouterModule], | ||||
| }) | ||||
| export class AddonModPageIndexPageModule {} | ||||
| export class AddonModFolderComponentsModule {} | ||||
| @ -0,0 +1,49 @@ | ||||
| <!-- Buttons to add to the header. --> | ||||
| <core-navbar-buttons slot="end"> | ||||
|     <core-context-menu> | ||||
|         <core-context-menu-item *ngIf="externalUrl" [priority]="900" [content]="'core.openinbrowser' | translate" | ||||
|             [href]="externalUrl" iconAction="fas-external-link-alt">> | ||||
|         </core-context-menu-item> | ||||
|         <core-context-menu-item *ngIf="description" [priority]="800" [content]="'core.moduleintro' | translate" | ||||
|             (action)="expandDescription()" iconAction="fas-arrow-right"> | ||||
|         </core-context-menu-item> | ||||
|         <core-context-menu-item *ngIf="blog" [priority]="750" content="{{'addon.blog.blog' | translate}}" | ||||
|              iconAction="far-newspaper" (action)="gotoBlog()"> | ||||
|         </core-context-menu-item> | ||||
|         <core-context-menu-item *ngIf="!subfolder" [priority]="700" [content]="'core.refresh' | translate" | ||||
|             (action)="doRefresh(null, $event)" [iconAction]="refreshIcon" [closeOnClick]="false"> | ||||
|         </core-context-menu-item> | ||||
|         <core-context-menu-item *ngIf="prefetchStatusIcon" [priority]="600" [content]="prefetchText" (action)="prefetch($event)" | ||||
|             [iconAction]="prefetchStatusIcon" [closeOnClick]="false"> | ||||
|         </core-context-menu-item> | ||||
|         <core-context-menu-item *ngIf="size" [priority]="500" [content]="'core.clearstoreddata' | translate:{$a: size}" | ||||
|             iconDescription="fas-archive" (action)="removeFiles($event)" iconAction="fas-trash" [closeOnClick]="false"> | ||||
|         </core-context-menu-item> | ||||
|     </core-context-menu> | ||||
| </core-navbar-buttons> | ||||
| 
 | ||||
| <!-- Content. --> | ||||
| <core-loading [hideUntil]="loaded" class="core-loading-center"> | ||||
| 
 | ||||
|     <core-course-module-description [description]="description" [component]="component" [componentId]="componentId" | ||||
|         contextLevel="module" [contextInstanceId]="module?.id" [courseId]="courseId"> | ||||
|     </core-course-module-description> | ||||
| 
 | ||||
|     <ion-list *ngIf="subfolder && (subfolder!.files.length + subfolder!.folders.length > 0)"> | ||||
|         <ng-container *ngFor="let folder of subfolder!.folders"> | ||||
|             <ion-item class="item-file" (click)="openFolder(folder)" detail="true"> | ||||
|                 <ion-icon name="fas-folder" slot="start"></ion-icon> | ||||
|                 <ion-label> | ||||
|                     <h2>{{folder.filename}}</h2> | ||||
|                 </ion-label> | ||||
|             </ion-item> | ||||
|         </ng-container> | ||||
|         <ng-container *ngFor="let file of subfolder!.files"> | ||||
|             <core-file [file]="file" [component]="component" [componentId]="componentId"></core-file> | ||||
|         </ng-container> | ||||
|     </ion-list> | ||||
| 
 | ||||
|     <core-empty-box *ngIf="!subfolder || (subfolder!.files.length + subfolder!.folders.length == 0)" icon="far-folder-open" | ||||
|         [message]=" 'addon.mod_folder.emptyfilelist' | translate"></core-empty-box> | ||||
| 
 | ||||
| </core-loading> | ||||
							
								
								
									
										137
									
								
								src/addons/mod/folder/components/index/index.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										137
									
								
								src/addons/mod/folder/components/index/index.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,137 @@ | ||||
| // (C) Copyright 2015 Moodle Pty Ltd.
 | ||||
| //
 | ||||
| // Licensed under the Apache License, Version 2.0 (the "License");
 | ||||
| // you may not use this file except in compliance with the License.
 | ||||
| // You may obtain a copy of the License at
 | ||||
| //
 | ||||
| //     http://www.apache.org/licenses/LICENSE-2.0
 | ||||
| //
 | ||||
| // Unless required by applicable law or agreed to in writing, software
 | ||||
| // distributed under the License is distributed on an "AS IS" BASIS,
 | ||||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | ||||
| // See the License for the specific language governing permissions and
 | ||||
| // limitations under the License.
 | ||||
| 
 | ||||
| import { CoreConstants } from '@/core/constants'; | ||||
| import { Component, Input, OnInit, Optional } from '@angular/core'; | ||||
| import { Params } from '@angular/router'; | ||||
| import { CoreCourseModuleMainResourceComponent } from '@features/course/classes/main-resource-component'; | ||||
| import { CoreCourseContentsPage } from '@features/course/pages/contents/contents'; | ||||
| import { CoreCourse } from '@features/course/services/course'; | ||||
| import { CoreApp } from '@services/app'; | ||||
| import { CoreNavigator } from '@services/navigator'; | ||||
| import { Md5 } from 'ts-md5'; | ||||
| import { AddonModFolder, AddonModFolderFolder, AddonModFolderProvider } from '../../services/folder'; | ||||
| import { AddonModFolderFolderFormattedData, AddonModFolderHelper } from '../../services/folder-helper'; | ||||
| 
 | ||||
| /** | ||||
|  * Component that displays a folder. | ||||
|  * | ||||
|  * @todo Adding a new file in a folder updates the revision of all the files, so they're all shown as outdated. | ||||
|  *       To ignore revision in folders we'll have to modify CoreCourseModulePrefetchDelegate, core-file and CoreFilepoolProvider. | ||||
|  */ | ||||
| @Component({ | ||||
|     selector: 'addon-mod-folder-index', | ||||
|     templateUrl: 'addon-mod-folder-index.html', | ||||
| }) | ||||
| export class AddonModFolderIndexComponent extends CoreCourseModuleMainResourceComponent implements OnInit { | ||||
| 
 | ||||
|     @Input() folderInstance?: AddonModFolderFolder; // The mod_folder instance.
 | ||||
|     @Input() subfolder?: AddonModFolderFolderFormattedData; // Subfolder to show.
 | ||||
| 
 | ||||
|     component = AddonModFolderProvider.COMPONENT; | ||||
|     canGetFolder = false; | ||||
| 
 | ||||
|     constructor(@Optional() courseContentsPage?: CoreCourseContentsPage) { | ||||
|         super('AddonModFolderIndexComponent', courseContentsPage); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Component being initialized. | ||||
|      */ | ||||
|     async ngOnInit(): Promise<void> { | ||||
|         super.ngOnInit(); | ||||
| 
 | ||||
|         this.canGetFolder = AddonModFolder.isGetFolderWSAvailable(); | ||||
| 
 | ||||
|         if (this.subfolder) { | ||||
|             this.description = this.folderInstance ? this.folderInstance.intro : this.module!.description; | ||||
| 
 | ||||
|             this.loaded = true; | ||||
|             this.refreshIcon = CoreConstants.ICON_REFRESH; | ||||
| 
 | ||||
|             return; | ||||
|         } | ||||
| 
 | ||||
|         try { | ||||
|             await this.loadContent(); | ||||
| 
 | ||||
|             try { | ||||
|                 await AddonModFolder.logView(this.module!.instance!, this.module!.name); | ||||
|                 CoreCourse.checkModuleCompletion(this.courseId!, this.module!.completiondata); | ||||
|             } catch { | ||||
|                 // Ignore errors.
 | ||||
|             } | ||||
|         } finally { | ||||
|             this.loaded = true; | ||||
|             this.refreshIcon = CoreConstants.ICON_REFRESH; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Perform the invalidate content function. | ||||
|      * | ||||
|      * @return Resolved when done. | ||||
|      */ | ||||
|     protected async invalidateContent(): Promise<void> { | ||||
|         await AddonModFolder.invalidateContent(this.module!.id, this.courseId!); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Download folder contents. | ||||
|      * | ||||
|      * @param refresh Whether we're refreshing data. | ||||
|      * @return Promise resolved when done. | ||||
|      */ | ||||
|     protected async fetchContent(refresh = false): Promise<void> { | ||||
|         try { | ||||
|             if (this.canGetFolder) { | ||||
|                 this.folderInstance = await AddonModFolder.getFolder(this.courseId!, this.module!.id); | ||||
|                 await CoreCourse.loadModuleContents(this.module!, this.courseId, undefined, false, refresh); | ||||
|             } else { | ||||
|                 const module = await CoreCourse.getModule(this.module!.id, this.courseId); | ||||
| 
 | ||||
|                 if (!module.contents.length && this.module!.contents.length && !CoreApp.isOnline()) { | ||||
|                     // The contents might be empty due to a cached data. Use the old ones.
 | ||||
|                     module.contents = this.module!.contents; | ||||
|                 } | ||||
|                 this.module = module; | ||||
|             } | ||||
| 
 | ||||
|             this.dataRetrieved.emit(this.folderInstance || this.module); | ||||
| 
 | ||||
|             this.description = this.folderInstance ? this.folderInstance.intro : this.module!.description; | ||||
|             this.subfolder = AddonModFolderHelper.formatContents(this.module!.contents); | ||||
|         } finally { | ||||
|             this.fillContextMenu(refresh); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Navigate to a subfolder. | ||||
|      * | ||||
|      * @param folder Folder data. | ||||
|      */ | ||||
|     openFolder(folder: AddonModFolderFolderFormattedData): void { | ||||
|         const params: Params = { | ||||
|             module: this.module, | ||||
|             folderInstance: this.folderInstance, | ||||
|             subfolder: folder, | ||||
|         }; | ||||
| 
 | ||||
|         const hash = <string> Md5.hashAsciiStr(folder.filepath); | ||||
| 
 | ||||
|         CoreNavigator.navigate('../' + hash, { params }); | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| @ -16,13 +16,19 @@ import { NgModule } from '@angular/core'; | ||||
| import { RouterModule, Routes } from '@angular/router'; | ||||
| 
 | ||||
| import { CoreSharedModule } from '@/core/shared.module'; | ||||
| import { AddonModBookComponentsModule } from '../../components/components.module'; | ||||
| import { AddonModBookIndexPage } from './index'; | ||||
| import { AddonModFolderComponentsModule } from './components/components.module'; | ||||
| 
 | ||||
| import { AddonModFolderIndexPage } from './pages/index/index.page'; | ||||
| 
 | ||||
| const routes: Routes = [ | ||||
|     { | ||||
|         path: '', | ||||
|         component: AddonModBookIndexPage, | ||||
|         path: ':courseId/:cmId/:hash', | ||||
|         component: AddonModFolderIndexPage, | ||||
|     }, | ||||
|     { | ||||
|         path: ':courseId/:cmId', | ||||
|         redirectTo: ':courseId/:cmId/', // Fake "hash".
 | ||||
|         pathMatch: 'full', | ||||
|     }, | ||||
| ]; | ||||
| 
 | ||||
| @ -30,11 +36,10 @@ const routes: Routes = [ | ||||
|     imports: [ | ||||
|         RouterModule.forChild(routes), | ||||
|         CoreSharedModule, | ||||
|         AddonModBookComponentsModule, | ||||
|         AddonModFolderComponentsModule, | ||||
|     ], | ||||
|     declarations: [ | ||||
|         AddonModBookIndexPage, | ||||
|         AddonModFolderIndexPage, | ||||
|     ], | ||||
|     exports: [RouterModule], | ||||
| }) | ||||
| export class AddonModBookIndexPageModule {} | ||||
| export class AddonModFolderLazyModule {} | ||||
							
								
								
									
										56
									
								
								src/addons/mod/folder/folder.module.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								src/addons/mod/folder/folder.module.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,56 @@ | ||||
| // (C) Copyright 2015 Moodle Pty Ltd.
 | ||||
| //
 | ||||
| // Licensed under the Apache License, Version 2.0 (the "License");
 | ||||
| // you may not use this file except in compliance with the License.
 | ||||
| // You may obtain a copy of the License at
 | ||||
| //
 | ||||
| //     http://www.apache.org/licenses/LICENSE-2.0
 | ||||
| //
 | ||||
| // Unless required by applicable law or agreed to in writing, software
 | ||||
| // distributed under the License is distributed on an "AS IS" BASIS,
 | ||||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | ||||
| // See the License for the specific language governing permissions and
 | ||||
| // limitations under the License.
 | ||||
| 
 | ||||
| import { APP_INITIALIZER, NgModule } from '@angular/core'; | ||||
| import { Routes } from '@angular/router'; | ||||
| import { CoreContentLinksDelegate } from '@features/contentlinks/services/contentlinks-delegate'; | ||||
| import { CoreCourseModuleDelegate } from '@features/course/services/module-delegate'; | ||||
| import { CoreCourseModulePrefetchDelegate } from '@features/course/services/module-prefetch-delegate'; | ||||
| import { CoreMainMenuTabRoutingModule } from '@features/mainmenu/mainmenu-tab-routing.module'; | ||||
| import { CorePluginFileDelegate } from '@services/plugin-file-delegate'; | ||||
| import { AddonModFolderComponentsModule } from './components/components.module'; | ||||
| import { AddonModFolderIndexLinkHandler } from './services/handlers/index-link'; | ||||
| import { AddonModFolderListLinkHandler } from './services/handlers/list-link'; | ||||
| import { AddonModFolderModuleHandler, AddonModFolderModuleHandlerService } from './services/handlers/module'; | ||||
| import { AddonModFolderPluginFileHandler } from './services/handlers/pluginfile'; | ||||
| import { AddonModFolderPrefetchHandler } from './services/handlers/prefetch'; | ||||
| 
 | ||||
| const routes: Routes = [ | ||||
|     { | ||||
|         path: AddonModFolderModuleHandlerService.PAGE_NAME, | ||||
|         loadChildren: () => import('./folder-lazy.module').then(m => m.AddonModFolderLazyModule), | ||||
|     }, | ||||
| ]; | ||||
| 
 | ||||
| @NgModule({ | ||||
|     imports: [ | ||||
|         CoreMainMenuTabRoutingModule.forChild(routes), | ||||
|         AddonModFolderComponentsModule, | ||||
|     ], | ||||
|     providers: [ | ||||
|         { | ||||
|             provide: APP_INITIALIZER, | ||||
|             multi: true, | ||||
|             deps: [], | ||||
|             useFactory: () => () => { | ||||
|                 CoreCourseModuleDelegate.registerHandler(AddonModFolderModuleHandler.instance); | ||||
|                 CoreContentLinksDelegate.registerHandler(AddonModFolderIndexLinkHandler.instance); | ||||
|                 CoreContentLinksDelegate.registerHandler(AddonModFolderListLinkHandler.instance); | ||||
|                 CoreCourseModulePrefetchDelegate.registerHandler(AddonModFolderPrefetchHandler.instance); | ||||
|                 CorePluginFileDelegate.registerHandler(AddonModFolderPluginFileHandler.instance); | ||||
|             }, | ||||
|         }, | ||||
|     ], | ||||
| }) | ||||
| export class AddonModFolderModule {} | ||||
							
								
								
									
										4
									
								
								src/addons/mod/folder/lang.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								src/addons/mod/folder/lang.json
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,4 @@ | ||||
| { | ||||
|     "emptyfilelist": "There are no files to show.", | ||||
|     "modulenameplural": "Folders" | ||||
| } | ||||
							
								
								
									
										25
									
								
								src/addons/mod/folder/pages/index/index.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								src/addons/mod/folder/pages/index/index.html
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,25 @@ | ||||
| <ion-header> | ||||
|     <ion-toolbar> | ||||
|         <ion-buttons slot="start"> | ||||
|             <ion-back-button [attr.aria-label]="'core.back' | translate"></ion-back-button> | ||||
|         </ion-buttons> | ||||
|         <ion-title> | ||||
|             <core-format-text [text]="title" contextLevel="module" [contextInstanceId]="module?.id" [courseId]="courseId"> | ||||
|             </core-format-text> | ||||
|         </ion-title> | ||||
| 
 | ||||
|         <ion-buttons slot="end"> | ||||
|             <!-- The buttons defined by the component will be added in here. --> | ||||
|         </ion-buttons> | ||||
|     </ion-toolbar> | ||||
| </ion-header> | ||||
| <ion-content> | ||||
|     <ion-refresher slot="fixed" [disabled]="subfolder || !activityComponent?.loaded" | ||||
|         (ionRefresh)="activityComponent?.doRefresh($event)"> | ||||
|         <ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content> | ||||
|     </ion-refresher> | ||||
| 
 | ||||
|     <addon-mod-folder-index [module]="module" [courseId]="courseId" [folderInstance]="folderInstance" [subfolder]="subfolder" | ||||
|         (dataRetrieved)="updateData($event)"> | ||||
|     </addon-mod-folder-index> | ||||
| </ion-content> | ||||
							
								
								
									
										45
									
								
								src/addons/mod/folder/pages/index/index.page.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								src/addons/mod/folder/pages/index/index.page.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,45 @@ | ||||
| // (C) Copyright 2015 Moodle Pty Ltd.
 | ||||
| //
 | ||||
| // Licensed under the Apache License, Version 2.0 (the "License");
 | ||||
| // you may not use this file except in compliance with the License.
 | ||||
| // You may obtain a copy of the License at
 | ||||
| //
 | ||||
| //     http://www.apache.org/licenses/LICENSE-2.0
 | ||||
| //
 | ||||
| // Unless required by applicable law or agreed to in writing, software
 | ||||
| // distributed under the License is distributed on an "AS IS" BASIS,
 | ||||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | ||||
| // See the License for the specific language governing permissions and
 | ||||
| // limitations under the License.
 | ||||
| 
 | ||||
| import { Component, OnInit, ViewChild } from '@angular/core'; | ||||
| import { CoreCourseModuleMainActivityPage } from '@features/course/classes/main-activity-page'; | ||||
| import { CoreNavigator } from '@services/navigator'; | ||||
| import { AddonModFolderIndexComponent } from '../../components/index'; | ||||
| import { AddonModFolderFolder } from '../../services/folder'; | ||||
| import { AddonModFolderFolderFormattedData } from '../../services/folder-helper'; | ||||
| 
 | ||||
| /** | ||||
|  * Page that displays a folder. | ||||
|  */ | ||||
| @Component({ | ||||
|     selector: 'page-addon-mod-folder-index', | ||||
|     templateUrl: 'index.html', | ||||
| }) | ||||
| export class AddonModFolderIndexPage extends CoreCourseModuleMainActivityPage<AddonModFolderIndexComponent> implements OnInit { | ||||
| 
 | ||||
|     @ViewChild(AddonModFolderIndexComponent) activityComponent?: AddonModFolderIndexComponent; | ||||
| 
 | ||||
|     folderInstance?: AddonModFolderFolder; | ||||
|     subfolder?: AddonModFolderFolderFormattedData; | ||||
| 
 | ||||
|     /** | ||||
|      * Component being initialized. | ||||
|      */ | ||||
|     ngOnInit(): void { | ||||
|         super.ngOnInit(); | ||||
|         this.folderInstance = CoreNavigator.getRouteParam<AddonModFolderFolder>('folderInstance'); | ||||
|         this.subfolder = CoreNavigator.getRouteParam<AddonModFolderFolderFormattedData>('subfolder'); | ||||
|     } | ||||
| 
 | ||||
| } | ||||
							
								
								
									
										99
									
								
								src/addons/mod/folder/services/folder-helper.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										99
									
								
								src/addons/mod/folder/services/folder-helper.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,99 @@ | ||||
| // (C) Copyright 2015 Moodle Pty Ltd.
 | ||||
| //
 | ||||
| // Licensed under the Apache License, Version 2.0 (the "License");
 | ||||
| // you may not use this file except in compliance with the License.
 | ||||
| // You may obtain a copy of the License at
 | ||||
| //
 | ||||
| //     http://www.apache.org/licenses/LICENSE-2.0
 | ||||
| //
 | ||||
| // Unless required by applicable law or agreed to in writing, software
 | ||||
| // distributed under the License is distributed on an "AS IS" BASIS,
 | ||||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | ||||
| // See the License for the specific language governing permissions and
 | ||||
| // limitations under the License.
 | ||||
| 
 | ||||
| import { Injectable } from '@angular/core'; | ||||
| import { CoreCourseModuleContentFile } from '@features/course/services/course'; | ||||
| import { makeSingleton } from '@singletons'; | ||||
| 
 | ||||
| /** | ||||
|  * Service that provides some features for folder. | ||||
|  */ | ||||
| @Injectable({ providedIn: 'root' }) | ||||
| export class AddonModFolderHelperProvider { | ||||
| 
 | ||||
|     /** | ||||
|      * Format folder contents, creating directory structure. | ||||
|      * Folders found in filepaths are added to the array. Each folder has the properties: name, fileicon, | ||||
|      * type (folder), filepath and contents (array with files and subfolders). | ||||
|      * | ||||
|      * @param fileEntries Folder contents. | ||||
|      * @return Formatted contents. | ||||
|      */ | ||||
|     formatContents(fileEntries: CoreCourseModuleContentFile[]): AddonModFolderFolderFormattedData { | ||||
|         const rootFolder: AddonModFolderFolderFormattedData = { | ||||
|             type: 'root', | ||||
|             filename: '', | ||||
|             filepath: '', | ||||
|             folders: [], | ||||
|             files: [], | ||||
|         }; | ||||
| 
 | ||||
|         fileEntries.forEach((fileEntry) => { | ||||
|             // Root level. Just add.
 | ||||
|             if (fileEntry.filepath === '/') { | ||||
|                 rootFolder.files.push(fileEntry); | ||||
| 
 | ||||
|                 return; | ||||
|             } | ||||
| 
 | ||||
|             // It's a file in a subfolder. Lets treat the path to add the subfolders to the array.
 | ||||
|             let currentFolder = rootFolder; // Start at root level.
 | ||||
|             let path = fileEntry.filepath; | ||||
|             let completePath = ''; | ||||
| 
 | ||||
|             // Remove first and last slash if needed.
 | ||||
|             if (path.substr(0, 1) === '/') { | ||||
|                 path = path.substr(1); | ||||
|             } | ||||
|             if (path.substr(path.length - 1) === '/') { | ||||
|                 path = path.slice(0, -1); | ||||
|             } | ||||
| 
 | ||||
|             const directories: string[] = path.split('/'); | ||||
| 
 | ||||
|             directories.forEach((directory) => { | ||||
|                 completePath = completePath + '/' + directory; | ||||
|                 // Search if the directory is already stored in folders array.
 | ||||
|                 let subFolder = currentFolder.folders.find((list) => list.filename === directory); | ||||
| 
 | ||||
|                 if (!subFolder) { | ||||
|                     // Directory not found. Add it to the array.
 | ||||
|                     subFolder = { | ||||
|                         type: 'folder', | ||||
|                         filename: directory, | ||||
|                         filepath: completePath, | ||||
|                         folders: [], | ||||
|                         files: [], | ||||
|                     }; | ||||
|                     currentFolder.folders.push(subFolder); | ||||
|                 } | ||||
|                 currentFolder = subFolder; | ||||
|             }); | ||||
| 
 | ||||
|             currentFolder.files.push(fileEntry); | ||||
|         }); | ||||
| 
 | ||||
|         return rootFolder; | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| export const AddonModFolderHelper = makeSingleton(AddonModFolderHelperProvider); | ||||
| 
 | ||||
| export type AddonModFolderFolderFormattedData = { | ||||
|     type: string; // A file or a folder or external link.
 | ||||
|     filename: string; | ||||
|     filepath: string; | ||||
|     folders: AddonModFolderFolderFormattedData[]; | ||||
|     files: CoreCourseModuleContentFile[]; | ||||
| }; | ||||
							
								
								
									
										206
									
								
								src/addons/mod/folder/services/folder.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										206
									
								
								src/addons/mod/folder/services/folder.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,206 @@ | ||||
| // (C) Copyright 2015 Moodle Pty Ltd.
 | ||||
| //
 | ||||
| // Licensed under the Apache License, Version 2.0 (the "License");
 | ||||
| // you may not use this file except in compliance with the License.
 | ||||
| // You may obtain a copy of the License at
 | ||||
| //
 | ||||
| //     http://www.apache.org/licenses/LICENSE-2.0
 | ||||
| //
 | ||||
| // Unless required by applicable law or agreed to in writing, software
 | ||||
| // distributed under the License is distributed on an "AS IS" BASIS,
 | ||||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | ||||
| // See the License for the specific language governing permissions and
 | ||||
| // limitations under the License.
 | ||||
| 
 | ||||
| import { Injectable } from '@angular/core'; | ||||
| import { CoreError } from '@classes/errors/error'; | ||||
| import { CoreSite, CoreSiteWSPreSets } from '@classes/site'; | ||||
| import { CoreCourse } from '@features/course/services/course'; | ||||
| import { CoreCourseLogHelper } from '@features/course/services/log-helper'; | ||||
| import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites'; | ||||
| import { CoreUtils } from '@services/utils/utils'; | ||||
| import { CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws'; | ||||
| import { makeSingleton } from '@singletons'; | ||||
| 
 | ||||
| const ROOT_CACHE_KEY = 'mmaModFolder:'; | ||||
| 
 | ||||
| /** | ||||
|  * Service that provides some features for folder. | ||||
|  */ | ||||
| @Injectable({ providedIn: 'root' }) | ||||
| export class AddonModFolderProvider { | ||||
| 
 | ||||
|     static readonly COMPONENT = 'mmaModFolder'; | ||||
| 
 | ||||
|     /** | ||||
|      * Get a folder by course module ID. | ||||
|      * | ||||
|      * @param courseId Course ID. | ||||
|      * @param cmId Course module ID. | ||||
|      * @param options Other options. | ||||
|      * @return Promise resolved when the book is retrieved. | ||||
|      */ | ||||
|     getFolder(courseId: number, cmId: number, options?: CoreSitesCommonWSOptions): Promise<AddonModFolderFolder> { | ||||
|         return this.getFolderByKey(courseId, 'coursemodule', cmId, options); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Get a folder. | ||||
|      * | ||||
|      * @param courseId Course ID. | ||||
|      * @param key Name of the property to check. | ||||
|      * @param value Value to search. | ||||
|      * @param options Other options. | ||||
|      * @return Promise resolved when the book is retrieved. | ||||
|      */ | ||||
|     protected async getFolderByKey( | ||||
|         courseId: number, | ||||
|         key: string, | ||||
|         value: number, | ||||
|         options: CoreSitesCommonWSOptions = {}, | ||||
|     ): Promise<AddonModFolderFolder> { | ||||
|         const site = await CoreSites.getSite(options.siteId); | ||||
| 
 | ||||
|         const params: AddonModFolderGetFoldersByCoursesWSParams = { | ||||
|             courseids: [courseId], | ||||
|         }; | ||||
| 
 | ||||
|         const preSets: CoreSiteWSPreSets = { | ||||
|             cacheKey: this.getFolderCacheKey(courseId), | ||||
|             updateFrequency: CoreSite.FREQUENCY_RARELY, | ||||
|             component: AddonModFolderProvider.COMPONENT, | ||||
|             ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), | ||||
|         }; | ||||
| 
 | ||||
|         const response = | ||||
|             await site.read<AddonModFolderGetFoldersByCoursesWSResponse>('mod_folder_get_folders_by_courses', params, preSets); | ||||
| 
 | ||||
|         const currentFolder = response.folders.find((folder) => folder[key] == value); | ||||
|         if (currentFolder) { | ||||
|             return currentFolder; | ||||
|         } | ||||
| 
 | ||||
|         throw new CoreError('Folder not found'); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Get cache key for folder data WS calls. | ||||
|      * | ||||
|      * @param courseId Course ID. | ||||
|      * @return Cache key. | ||||
|      */ | ||||
|     protected getFolderCacheKey(courseId: number): string { | ||||
|         return ROOT_CACHE_KEY + 'folder:' + courseId; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Invalidate the prefetched content. | ||||
|      * | ||||
|      * @param moduleId The module ID. | ||||
|      * @param courseId Course ID of the module. | ||||
|      * @param siteId Site ID. If not defined, current site. | ||||
|      */ | ||||
|     async invalidateContent(moduleId: number, courseId: number, siteId?: string): Promise<void> { | ||||
|         const promises: Promise<void>[] = []; | ||||
| 
 | ||||
|         promises.push(this.invalidateFolderData(courseId, siteId)); | ||||
|         promises.push(CoreCourse.invalidateModule(moduleId, siteId)); | ||||
| 
 | ||||
|         await CoreUtils.allPromises(promises); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Invalidates folder data. | ||||
|      * | ||||
|      * @param courseId Course ID. | ||||
|      * @param siteId Site ID. If not defined, current site. | ||||
|      * @return Promise resolved when the data is invalidated. | ||||
|      */ | ||||
|     async invalidateFolderData(courseId: number, siteId?: string): Promise<void> { | ||||
|         const site = await CoreSites.getSite(siteId); | ||||
| 
 | ||||
|         await site.invalidateWsCacheForKey(this.getFolderCacheKey(courseId)); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Returns whether or not getFolder WS available or not. | ||||
|      * | ||||
|      * @return If WS is avalaible. | ||||
|      * @since 3.3 | ||||
|      */ | ||||
|     isGetFolderWSAvailable(): boolean { | ||||
|         return CoreSites.wsAvailableInCurrentSite('mod_folder_get_folders_by_courses'); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Report a folder as being viewed. | ||||
|      * | ||||
|      * @param id Module ID. | ||||
|      * @param name Name of the folder. | ||||
|      * @param siteId Site ID. If not defined, current site. | ||||
|      * @return Promise resolved when the WS call is successful. | ||||
|      */ | ||||
|     async logView(id: number, name?: string, siteId?: string): Promise<void> { | ||||
|         const params: AddonModFolderViewFolderWSParams = { | ||||
|             folderid: id, | ||||
|         }; | ||||
| 
 | ||||
|         await CoreCourseLogHelper.logSingle( | ||||
|             'mod_folder_view_folder', | ||||
|             params, | ||||
|             AddonModFolderProvider.COMPONENT, | ||||
|             id, | ||||
|             name, | ||||
|             'folder', | ||||
|             {}, | ||||
|             siteId, | ||||
|         ); | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| export const AddonModFolder = makeSingleton(AddonModFolderProvider); | ||||
| 
 | ||||
| 
 | ||||
| /** | ||||
|  * Folder returned by mod_folder_get_folders_by_courses. | ||||
|  */ | ||||
| export type AddonModFolderFolder = { | ||||
|     id: number; // Module id.
 | ||||
|     coursemodule: number; // Course module id.
 | ||||
|     course: number; // Course id.
 | ||||
|     name: string; // Page name.
 | ||||
|     intro: string; // Summary.
 | ||||
|     introformat?: number; // Intro format (1 = HTML, 0 = MOODLE, 2 = PLAIN or 4 = MARKDOWN).
 | ||||
|     introfiles: CoreWSExternalFile[]; | ||||
|     revision: number; // Incremented when after each file changes, to avoid cache.
 | ||||
|     timemodified: number; // Last time the folder was modified.
 | ||||
|     display: number; // Display type of folder contents on a separate page or inline.
 | ||||
|     showexpanded: number; // 1 = expanded, 0 = collapsed for sub-folders.
 | ||||
|     showdownloadfolder: number; // Whether to show the download folder button.
 | ||||
|     section: number; // Course section id.
 | ||||
|     visible: number; // Module visibility.
 | ||||
|     groupmode: number; // Group mode.
 | ||||
|     groupingid: number; // Grouping id.
 | ||||
| }; | ||||
| 
 | ||||
| /** | ||||
|  * Params of mod_folder_get_folders_by_courses WS. | ||||
|  */ | ||||
| type AddonModFolderGetFoldersByCoursesWSParams = { | ||||
|     courseids?: number[]; // Array of course ids.
 | ||||
| }; | ||||
| 
 | ||||
| /** | ||||
|  * Data returned by mod_folder_get_folders_by_courses WS. | ||||
|  */ | ||||
| type AddonModFolderGetFoldersByCoursesWSResponse = { | ||||
|     folders: AddonModFolderFolder[]; | ||||
|     warnings?: CoreWSExternalWarning[]; | ||||
| }; | ||||
| 
 | ||||
| /** | ||||
|  * Params of mod_folder_view_folder WS. | ||||
|  */ | ||||
| type AddonModFolderViewFolderWSParams = { | ||||
|     folderid: number; // Folder instance id.
 | ||||
| }; | ||||
							
								
								
									
										32
									
								
								src/addons/mod/folder/services/handlers/index-link.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								src/addons/mod/folder/services/handlers/index-link.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,32 @@ | ||||
| // (C) Copyright 2015 Moodle Pty Ltd.
 | ||||
| //
 | ||||
| // Licensed under the Apache License, Version 2.0 (the "License");
 | ||||
| // you may not use this file except in compliance with the License.
 | ||||
| // You may obtain a copy of the License at
 | ||||
| //
 | ||||
| //     http://www.apache.org/licenses/LICENSE-2.0
 | ||||
| //
 | ||||
| // Unless required by applicable law or agreed to in writing, software
 | ||||
| // distributed under the License is distributed on an "AS IS" BASIS,
 | ||||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | ||||
| // See the License for the specific language governing permissions and
 | ||||
| // limitations under the License.
 | ||||
| 
 | ||||
| import { Injectable } from '@angular/core'; | ||||
| import { CoreContentLinksModuleIndexHandler } from '@features/contentlinks/classes/module-index-handler'; | ||||
| import { makeSingleton } from '@singletons'; | ||||
| 
 | ||||
| /** | ||||
|  * Handler to treat links to resource. | ||||
|  */ | ||||
| @Injectable({ providedIn: 'root' }) | ||||
| export class AddonModFolderIndexLinkHandlerService extends CoreContentLinksModuleIndexHandler { | ||||
| 
 | ||||
|     name = 'AddonModFolderLinkHandler'; | ||||
| 
 | ||||
|     constructor() { | ||||
|         super('AddonModFolder', 'folder', 'f'); | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| export const AddonModFolderIndexLinkHandler = makeSingleton(AddonModFolderIndexLinkHandlerService); | ||||
							
								
								
									
										32
									
								
								src/addons/mod/folder/services/handlers/list-link.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								src/addons/mod/folder/services/handlers/list-link.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,32 @@ | ||||
| // (C) Copyright 2015 Moodle Pty Ltd.
 | ||||
| //
 | ||||
| // Licensed under the Apache License, Version 2.0 (the "License");
 | ||||
| // you may not use this file except in compliance with the License.
 | ||||
| // You may obtain a copy of the License at
 | ||||
| //
 | ||||
| //     http://www.apache.org/licenses/LICENSE-2.0
 | ||||
| //
 | ||||
| // Unless required by applicable law or agreed to in writing, software
 | ||||
| // distributed under the License is distributed on an "AS IS" BASIS,
 | ||||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | ||||
| // See the License for the specific language governing permissions and
 | ||||
| // limitations under the License.
 | ||||
| 
 | ||||
| import { Injectable } from '@angular/core'; | ||||
| import { CoreContentLinksModuleListHandler } from '@features/contentlinks/classes/module-list-handler'; | ||||
| import { makeSingleton } from '@singletons'; | ||||
| 
 | ||||
| /** | ||||
|  * Handler to treat links to folder list page. | ||||
|  */ | ||||
| @Injectable({ providedIn: 'root' }) | ||||
| export class AddonModFolderListLinkHandlerService extends CoreContentLinksModuleListHandler { | ||||
| 
 | ||||
|     name = 'AddonModFolderListLinkHandler'; | ||||
| 
 | ||||
|     constructor() { | ||||
|         super('AddonModFolder', 'folder'); | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| export const AddonModFolderListLinkHandler = makeSingleton(AddonModFolderListLinkHandlerService); | ||||
							
								
								
									
										82
									
								
								src/addons/mod/folder/services/handlers/module.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										82
									
								
								src/addons/mod/folder/services/handlers/module.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,82 @@ | ||||
| // (C) Copyright 2015 Moodle Pty Ltd.
 | ||||
| //
 | ||||
| // Licensed under the Apache License, Version 2.0 (the "License");
 | ||||
| // you may not use this file except in compliance with the License.
 | ||||
| // You may obtain a copy of the License at
 | ||||
| //
 | ||||
| //     http://www.apache.org/licenses/LICENSE-2.0
 | ||||
| //
 | ||||
| // Unless required by applicable law or agreed to in writing, software
 | ||||
| // distributed under the License is distributed on an "AS IS" BASIS,
 | ||||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | ||||
| // See the License for the specific language governing permissions and
 | ||||
| // limitations under the License.
 | ||||
| 
 | ||||
| import { CoreConstants } from '@/core/constants'; | ||||
| import { Injectable, Type } from '@angular/core'; | ||||
| import { CoreCourse, CoreCourseAnyModuleData } from '@features/course/services/course'; | ||||
| import { CoreCourseModule } from '@features/course/services/course-helper'; | ||||
| import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@features/course/services/module-delegate'; | ||||
| import { CoreNavigationOptions, CoreNavigator } from '@services/navigator'; | ||||
| import { makeSingleton } from '@singletons'; | ||||
| import { AddonModFolderIndexComponent } from '../../components/index'; | ||||
| 
 | ||||
| /** | ||||
|  * Handler to support folder modules. | ||||
|  */ | ||||
| @Injectable({ providedIn: 'root' }) | ||||
| export class AddonModFolderModuleHandlerService implements CoreCourseModuleHandler { | ||||
| 
 | ||||
|     static readonly PAGE_NAME = 'mod_folder'; | ||||
| 
 | ||||
|     name = 'AddonModFolder'; | ||||
|     modName = 'folder'; | ||||
| 
 | ||||
|     supportedFeatures = { | ||||
|         [CoreConstants.FEATURE_MOD_ARCHETYPE]: CoreConstants.MOD_ARCHETYPE_RESOURCE, | ||||
|         [CoreConstants.FEATURE_GROUPS]: false, | ||||
|         [CoreConstants.FEATURE_GROUPINGS]: false, | ||||
|         [CoreConstants.FEATURE_MOD_INTRO]: true, | ||||
|         [CoreConstants.FEATURE_COMPLETION_TRACKS_VIEWS]: true, | ||||
|         [CoreConstants.FEATURE_GRADE_HAS_GRADE]: false, | ||||
|         [CoreConstants.FEATURE_GRADE_OUTCOMES]: false, | ||||
|         [CoreConstants.FEATURE_BACKUP_MOODLE2]: true, | ||||
|         [CoreConstants.FEATURE_SHOW_DESCRIPTION]: true, | ||||
|     }; | ||||
| 
 | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     async isEnabled(): Promise<boolean> { | ||||
|         return true; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     getData(module: CoreCourseAnyModuleData): CoreCourseModuleHandlerData { | ||||
|         return { | ||||
|             icon: CoreCourse.getModuleIconSrc(this.modName, 'modicon' in module ? module.modicon : undefined), | ||||
|             title: module.name, | ||||
|             class: 'addon-mod_folder-handler', | ||||
|             showDownloadButton: true, | ||||
|             action(event: Event, module: CoreCourseModule, courseId: number, options?: CoreNavigationOptions): void { | ||||
|                 options = options || {}; | ||||
|                 options.params = options.params || {}; | ||||
|                 Object.assign(options.params, { module }); | ||||
|                 const routeParams = '/' + courseId + '/' + module.id; | ||||
| 
 | ||||
|                 CoreNavigator.navigateToSitePath(AddonModFolderModuleHandlerService.PAGE_NAME + routeParams, options); | ||||
|             }, | ||||
|         }; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     async getMainComponent(): Promise<Type<unknown> | undefined> { | ||||
|         return AddonModFolderIndexComponent; | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| export const AddonModFolderModuleHandler = makeSingleton(AddonModFolderModuleHandlerService); | ||||
							
								
								
									
										55
									
								
								src/addons/mod/folder/services/handlers/pluginfile.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										55
									
								
								src/addons/mod/folder/services/handlers/pluginfile.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,55 @@ | ||||
| // (C) Copyright 2015 Moodle Pty Ltd.
 | ||||
| //
 | ||||
| // Licensed under the Apache License, Version 2.0 (the "License");
 | ||||
| // you may not use this file except in compliance with the License.
 | ||||
| // You may obtain a copy of the License at
 | ||||
| //
 | ||||
| //     http://www.apache.org/licenses/LICENSE-2.0
 | ||||
| //
 | ||||
| // Unless required by applicable law or agreed to in writing, software
 | ||||
| // distributed under the License is distributed on an "AS IS" BASIS,
 | ||||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | ||||
| // See the License for the specific language governing permissions and
 | ||||
| // limitations under the License.
 | ||||
| 
 | ||||
| import { Injectable } from '@angular/core'; | ||||
| import { CorePluginFileHandler } from '@services/plugin-file-delegate'; | ||||
| import { makeSingleton } from '@singletons'; | ||||
| 
 | ||||
| /** | ||||
|  * Handler to treat links to folder. | ||||
|  */ | ||||
| @Injectable({ providedIn: 'root' }) | ||||
| export class AddonModFolderPluginFileHandlerService implements CorePluginFileHandler { | ||||
| 
 | ||||
|     name = 'AddonModFolderPluginFileHandler'; | ||||
|     component = 'mod_folder'; | ||||
| 
 | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     getComponentRevisionRegExp(args: string[]): RegExp | undefined { | ||||
|         // Check filearea.
 | ||||
|         if (args[2] == 'content') { | ||||
|             // Component + Filearea + Revision
 | ||||
|             return new RegExp('/mod_folder/content/([0-9]+)/'); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     getComponentRevisionReplace(): string { | ||||
|         // Component + Filearea + Revision
 | ||||
|         return '/mod_folder/content/0/'; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     async isEnabled(): Promise<boolean> { | ||||
|         return true; | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| export const AddonModFolderPluginFileHandler = makeSingleton(AddonModFolderPluginFileHandlerService); | ||||
							
								
								
									
										66
									
								
								src/addons/mod/folder/services/handlers/prefetch.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								src/addons/mod/folder/services/handlers/prefetch.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,66 @@ | ||||
| // (C) Copyright 2015 Moodle Pty Ltd.
 | ||||
| //
 | ||||
| // Licensed under the Apache License, Version 2.0 (the "License");
 | ||||
| // you may not use this file except in compliance with the License.
 | ||||
| // You may obtain a copy of the License at
 | ||||
| //
 | ||||
| //     http://www.apache.org/licenses/LICENSE-2.0
 | ||||
| //
 | ||||
| // Unless required by applicable law or agreed to in writing, software
 | ||||
| // distributed under the License is distributed on an "AS IS" BASIS,
 | ||||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | ||||
| // See the License for the specific language governing permissions and
 | ||||
| // limitations under the License.
 | ||||
| 
 | ||||
| import { Injectable } from '@angular/core'; | ||||
| import { CoreCourseResourcePrefetchHandlerBase } from '@features/course/classes/resource-prefetch-handler'; | ||||
| import { CoreCourse, CoreCourseAnyModuleData, CoreCourseWSModule } from '@features/course/services/course'; | ||||
| import { makeSingleton } from '@singletons'; | ||||
| import { AddonModFolder, AddonModFolderProvider } from '../folder'; | ||||
| 
 | ||||
| /** | ||||
|  * Handler to prefetch folders. | ||||
|  */ | ||||
| @Injectable({ providedIn: 'root' }) | ||||
| export class AddonModFolderPrefetchHandlerService extends CoreCourseResourcePrefetchHandlerBase { | ||||
| 
 | ||||
|     name = 'AddonModFolder'; | ||||
|     modName = 'folder'; | ||||
|     component = AddonModFolderProvider.COMPONENT; | ||||
| 
 | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     async downloadOrPrefetch(module: CoreCourseWSModule, courseId: number, prefetch?: boolean): Promise<void> { | ||||
|         const promises: Promise<unknown>[] = []; | ||||
| 
 | ||||
|         promises.push(super.downloadOrPrefetch(module, courseId, prefetch)); | ||||
| 
 | ||||
|         if (AddonModFolder.isGetFolderWSAvailable()) { | ||||
|             promises.push(AddonModFolder.getFolder(courseId, module.id)); | ||||
|         } | ||||
| 
 | ||||
|         await Promise.all(promises); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     async invalidateContent(moduleId: number, courseId: number): Promise<void> { | ||||
|         return AddonModFolder.invalidateContent(moduleId, courseId); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      */ | ||||
|     async invalidateModule(module: CoreCourseAnyModuleData, courseId: number): Promise<void> { | ||||
|         const promises: Promise<void>[] = []; | ||||
| 
 | ||||
|         promises.push(AddonModFolder.invalidateFolderData(courseId)); | ||||
|         promises.push(CoreCourse.invalidateModule(module.id)); | ||||
| 
 | ||||
|         await Promise.all(promises); | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| export const AddonModFolderPrefetchHandler = makeSingleton(AddonModFolderPrefetchHandlerService); | ||||
| @ -20,7 +20,7 @@ import { CoreScreen } from '@services/screen'; | ||||
| import { CoreSharedModule } from '@/core/shared.module'; | ||||
| 
 | ||||
| import { AddonModForumComponentsModule } from './components/components.module'; | ||||
| import { AddonModForumIndexPage } from './pages/index'; | ||||
| import { AddonModForumIndexPage } from './pages/index/index.page'; | ||||
| 
 | ||||
| const mobileRoutes: Routes = [ | ||||
|     { | ||||
|  | ||||
| @ -4,7 +4,7 @@ | ||||
|             <ion-back-button [attr.aria-label]="'core.back' | translate"></ion-back-button> | ||||
|         </ion-buttons> | ||||
|         <ion-title> | ||||
|             <core-format-text [text]="title" contextLevel="module" [contextInstanceId]="module?.id" [courseId]="courseId"> | ||||
|             <core-format-text [text]="title" contextLevel="module" [contextInstanceId]="module.id" [courseId]="courseId"> | ||||
|             </core-format-text> | ||||
|         </ion-title> | ||||
|         <ion-buttons slot="end"> | ||||
|  | ||||
							
								
								
									
										28
									
								
								src/addons/mod/forum/pages/index/index.page.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								src/addons/mod/forum/pages/index/index.page.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,28 @@ | ||||
| // (C) Copyright 2015 Moodle Pty Ltd.
 | ||||
| //
 | ||||
| // Licensed under the Apache License, Version 2.0 (the "License");
 | ||||
| // you may not use this file except in compliance with the License.
 | ||||
| // You may obtain a copy of the License at
 | ||||
| //
 | ||||
| //     http://www.apache.org/licenses/LICENSE-2.0
 | ||||
| //
 | ||||
| // Unless required by applicable law or agreed to in writing, software
 | ||||
| // distributed under the License is distributed on an "AS IS" BASIS,
 | ||||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | ||||
| // See the License for the specific language governing permissions and
 | ||||
| // limitations under the License.
 | ||||
| 
 | ||||
| import { Component, ViewChild } from '@angular/core'; | ||||
| 
 | ||||
| import { CoreCourseModuleMainActivityPage } from '@features/course/classes/main-activity-page'; | ||||
| import { AddonModForumIndexComponent } from '../../components/index'; | ||||
| 
 | ||||
| @Component({ | ||||
|     selector: 'page-addon-mod-forum-index', | ||||
|     templateUrl: 'index.html', | ||||
| }) | ||||
| export class AddonModForumIndexPage extends CoreCourseModuleMainActivityPage<AddonModForumIndexComponent> { | ||||
| 
 | ||||
|     @ViewChild(AddonModForumIndexComponent) activityComponent?: AddonModForumIndexComponent; | ||||
| 
 | ||||
| } | ||||
| @ -15,7 +15,7 @@ | ||||
| import { Component, Input } from '@angular/core'; | ||||
| 
 | ||||
| import { ModalController } from '@singletons'; | ||||
| import { AddonModLessonPlayerPage } from '../../pages/player/player'; | ||||
| import { AddonModLessonPlayerPage } from '../../pages/player/player.page'; | ||||
| 
 | ||||
| /** | ||||
|  * Modal that renders the lesson menu and media file. | ||||
|  | ||||
| @ -15,10 +15,15 @@ | ||||
| import { NgModule } from '@angular/core'; | ||||
| import { RouterModule, Routes } from '@angular/router'; | ||||
| 
 | ||||
| import { CoreSharedModule } from '@/core/shared.module'; | ||||
| import { AddonModLessonComponentsModule } from './components/components.module'; | ||||
| 
 | ||||
| import { AddonModLessonIndexPage } from './pages/index/index.page'; | ||||
| 
 | ||||
| const routes: Routes = [ | ||||
|     { | ||||
|         path: ':courseId/:cmId', | ||||
|         loadChildren: () => import('./pages/index/index.module').then( m => m.AddonModLessonIndexPageModule), | ||||
|         component: AddonModLessonIndexPage, | ||||
|     }, | ||||
|     { | ||||
|         path: 'player/:courseId/:lessonId', | ||||
| @ -31,6 +36,13 @@ const routes: Routes = [ | ||||
| ]; | ||||
| 
 | ||||
| @NgModule({ | ||||
|     imports: [RouterModule.forChild(routes)], | ||||
|     imports: [ | ||||
|         RouterModule.forChild(routes), | ||||
|         CoreSharedModule, | ||||
|         AddonModLessonComponentsModule, | ||||
|     ], | ||||
|     declarations: [ | ||||
|         AddonModLessonIndexPage, | ||||
|     ], | ||||
| }) | ||||
| export class AddonModLessonLazyModule {} | ||||
|  | ||||
| @ -13,11 +13,11 @@ | ||||
|     </ion-toolbar> | ||||
| </ion-header> | ||||
| <ion-content> | ||||
|     <ion-refresher slot="fixed" [disabled]="!lessonComponent?.loaded" (ionRefresh)="lessonComponent?.doRefresh($event)"> | ||||
|     <ion-refresher slot="fixed" [disabled]="!activityComponent?.loaded" (ionRefresh)="activityComponent?.doRefresh($event)"> | ||||
|         <ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content> | ||||
|     </ion-refresher> | ||||
| 
 | ||||
|     <addon-mod-lesson-index [module]="module" [courseId]="courseId" [group]="group" [action]="action" | ||||
|         (dataRetrieved)="updateData($event)"> | ||||
|     </addon-mod-lesson-index> | ||||
| </ion-content> | ||||
| </ion-content> | ||||
|  | ||||
| @ -1,40 +0,0 @@ | ||||
| // (C) Copyright 2015 Moodle Pty Ltd.
 | ||||
| //
 | ||||
| // Licensed under the Apache License, Version 2.0 (the "License");
 | ||||
| // you may not use this file except in compliance with the License.
 | ||||
| // You may obtain a copy of the License at
 | ||||
| //
 | ||||
| //     http://www.apache.org/licenses/LICENSE-2.0
 | ||||
| //
 | ||||
| // Unless required by applicable law or agreed to in writing, software
 | ||||
| // distributed under the License is distributed on an "AS IS" BASIS,
 | ||||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | ||||
| // See the License for the specific language governing permissions and
 | ||||
| // limitations under the License.
 | ||||
| 
 | ||||
| import { NgModule } from '@angular/core'; | ||||
| import { RouterModule, Routes } from '@angular/router'; | ||||
| 
 | ||||
| import { CoreSharedModule } from '@/core/shared.module'; | ||||
| import { AddonModLessonComponentsModule } from '../../components/components.module'; | ||||
| import { AddonModLessonIndexPage } from './index'; | ||||
| 
 | ||||
| const routes: Routes = [ | ||||
|     { | ||||
|         path: '', | ||||
|         component: AddonModLessonIndexPage, | ||||
|     }, | ||||
| ]; | ||||
| 
 | ||||
| @NgModule({ | ||||
|     imports: [ | ||||
|         RouterModule.forChild(routes), | ||||
|         CoreSharedModule, | ||||
|         AddonModLessonComponentsModule, | ||||
|     ], | ||||
|     declarations: [ | ||||
|         AddonModLessonIndexPage, | ||||
|     ], | ||||
|     exports: [RouterModule], | ||||
| }) | ||||
| export class AddonModLessonIndexPageModule {} | ||||
| @ -13,11 +13,9 @@ | ||||
| // limitations under the License.
 | ||||
| 
 | ||||
| import { Component, OnInit, ViewChild } from '@angular/core'; | ||||
| 
 | ||||
| import { CoreCourseWSModule } from '@features/course/services/course'; | ||||
| import { CoreCourseModuleMainActivityPage } from '@features/course/classes/main-activity-page'; | ||||
| import { CoreNavigator } from '@services/navigator'; | ||||
| import { AddonModLessonIndexComponent } from '../../components/index/index'; | ||||
| import { AddonModLessonLessonWSData } from '../../services/lesson'; | ||||
| 
 | ||||
| /** | ||||
|  * Page that displays the lesson entry page. | ||||
| @ -26,13 +24,10 @@ import { AddonModLessonLessonWSData } from '../../services/lesson'; | ||||
|     selector: 'page-addon-mod-lesson-index', | ||||
|     templateUrl: 'index.html', | ||||
| }) | ||||
| export class AddonModLessonIndexPage implements OnInit { | ||||
| export class AddonModLessonIndexPage extends CoreCourseModuleMainActivityPage<AddonModLessonIndexComponent> implements OnInit { | ||||
| 
 | ||||
|     @ViewChild(AddonModLessonIndexComponent) lessonComponent?: AddonModLessonIndexComponent; | ||||
|     @ViewChild(AddonModLessonIndexComponent) activityComponent?: AddonModLessonIndexComponent; | ||||
| 
 | ||||
|     title?: string; | ||||
|     module?: CoreCourseWSModule; | ||||
|     courseId?: number; | ||||
|     group?: number; // The group to display.
 | ||||
|     action?: string; // The "action" to display first.
 | ||||
| 
 | ||||
| @ -40,34 +35,9 @@ export class AddonModLessonIndexPage implements OnInit { | ||||
|      * Component being initialized. | ||||
|      */ | ||||
|     ngOnInit(): void { | ||||
|         this.module = CoreNavigator.getRouteParam('module'); | ||||
|         this.courseId = CoreNavigator.getRouteNumberParam('courseId'); | ||||
|         super.ngOnInit(); | ||||
|         this.group = CoreNavigator.getRouteNumberParam('group'); | ||||
|         this.action = CoreNavigator.getRouteParam('action'); | ||||
|         this.title = this.module?.name; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Update some data based on the lesson instance. | ||||
|      * | ||||
|      * @param lesson Lesson instance. | ||||
|      */ | ||||
|     updateData(lesson: AddonModLessonLessonWSData): void { | ||||
|         this.title = lesson.name || this.title; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * User entered the page. | ||||
|      */ | ||||
|     ionViewDidEnter(): void { | ||||
|         this.lessonComponent?.ionViewDidEnter(); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * User left the page. | ||||
|      */ | ||||
|     ionViewDidLeave(): void { | ||||
|         this.lessonComponent?.ionViewDidLeave(); | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| @ -16,7 +16,7 @@ import { NgModule } from '@angular/core'; | ||||
| import { RouterModule, Routes } from '@angular/router'; | ||||
| 
 | ||||
| import { CoreSharedModule } from '@/core/shared.module'; | ||||
| import { AddonModLessonPlayerPage } from './player'; | ||||
| import { AddonModLessonPlayerPage } from './player.page'; | ||||
| import { CoreEditorComponentsModule } from '@features/editor/components/components.module'; | ||||
| import { CanLeaveGuard } from '@guards/can-leave'; | ||||
| 
 | ||||
|  | ||||
| @ -16,7 +16,7 @@ import { NgModule } from '@angular/core'; | ||||
| import { RouterModule, Routes } from '@angular/router'; | ||||
| 
 | ||||
| import { CoreSharedModule } from '@/core/shared.module'; | ||||
| import { AddonModLessonUserRetakePage } from './user-retake'; | ||||
| import { AddonModLessonUserRetakePage } from './user-retake.page'; | ||||
| 
 | ||||
| const routes: Routes = [ | ||||
|     { | ||||
|  | ||||
| @ -16,6 +16,7 @@ import { NgModule } from '@angular/core'; | ||||
| 
 | ||||
| import { AddonModAssignModule } from './assign/assign.module'; | ||||
| import { AddonModBookModule } from './book/book.module'; | ||||
| import { AddonModFolderModule } from './folder/folder.module'; | ||||
| import { AddonModForumModule } from './forum/forum.module'; | ||||
| import { AddonModLabelModule } from './label/label.module'; | ||||
| import { AddonModLessonModule } from './lesson/lesson.module'; | ||||
| @ -32,6 +33,7 @@ import { AddonModQuizModule } from './quiz/quiz.module'; | ||||
|         AddonModPageModule, | ||||
|         AddonModQuizModule, | ||||
|         AddonModLabelModule, | ||||
|         AddonModFolderModule, | ||||
|     ], | ||||
|     providers: [], | ||||
|     exports: [], | ||||
|  | ||||
| @ -15,14 +15,25 @@ | ||||
| import { NgModule } from '@angular/core'; | ||||
| import { RouterModule, Routes } from '@angular/router'; | ||||
| 
 | ||||
| import { CoreSharedModule } from '@/core/shared.module'; | ||||
| import { AddonModPageComponentsModule } from './components/components.module'; | ||||
| import { AddonModPageIndexPage } from './pages/index/index.page'; | ||||
| 
 | ||||
| const routes: Routes = [ | ||||
|     { | ||||
|         path: ':courseId/:cmId', | ||||
|         loadChildren: () => import('./pages/index/index.module').then( m => m.AddonModPageIndexPageModule), | ||||
|         component: AddonModPageIndexPage, | ||||
|     }, | ||||
| ]; | ||||
| 
 | ||||
| @NgModule({ | ||||
|     imports: [RouterModule.forChild(routes)], | ||||
|     imports: [ | ||||
|         RouterModule.forChild(routes), | ||||
|         CoreSharedModule, | ||||
|         AddonModPageComponentsModule, | ||||
|     ], | ||||
|     declarations: [ | ||||
|         AddonModPageIndexPage, | ||||
|     ], | ||||
| }) | ||||
| export class AddonModPageLazyModule {} | ||||
|  | ||||
| @ -13,7 +13,7 @@ | ||||
|     </ion-toolbar> | ||||
| </ion-header> | ||||
| <ion-content> | ||||
|     <ion-refresher slot="fixed" [disabled]="!pageComponent?.loaded" (ionRefresh)="pageComponent?.doRefresh($event)"> | ||||
|     <ion-refresher slot="fixed" [disabled]="!activityComponent?.loaded" (ionRefresh)="activityComponent?.doRefresh($event)"> | ||||
|         <ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content> | ||||
|     </ion-refresher> | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										30
									
								
								src/addons/mod/page/pages/index/index.page.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								src/addons/mod/page/pages/index/index.page.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,30 @@ | ||||
| // (C) Copyright 2015 Moodle Pty Ltd.
 | ||||
| //
 | ||||
| // Licensed under the Apache License, Version 2.0 (the "License");
 | ||||
| // you may not use this file except in compliance with the License.
 | ||||
| // You may obtain a copy of the License at
 | ||||
| //
 | ||||
| //     http://www.apache.org/licenses/LICENSE-2.0
 | ||||
| //
 | ||||
| // Unless required by applicable law or agreed to in writing, software
 | ||||
| // distributed under the License is distributed on an "AS IS" BASIS,
 | ||||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | ||||
| // See the License for the specific language governing permissions and
 | ||||
| // limitations under the License.
 | ||||
| 
 | ||||
| import { Component, ViewChild } from '@angular/core'; | ||||
| import { CoreCourseModuleMainActivityPage } from '@features/course/classes/main-activity-page'; | ||||
| import { AddonModPageIndexComponent } from '../../components/index/index'; | ||||
| 
 | ||||
| /** | ||||
|  * Page that displays a page. | ||||
|  */ | ||||
| @Component({ | ||||
|     selector: 'page-addon-mod-page-index', | ||||
|     templateUrl: 'index.html', | ||||
| }) | ||||
| export class AddonModPageIndexPage extends CoreCourseModuleMainActivityPage<AddonModPageIndexComponent> { | ||||
| 
 | ||||
|     @ViewChild(AddonModPageIndexComponent) activityComponent?: AddonModPageIndexComponent; | ||||
| 
 | ||||
| } | ||||
| @ -1,54 +0,0 @@ | ||||
| // (C) Copyright 2015 Moodle Pty Ltd.
 | ||||
| //
 | ||||
| // Licensed under the Apache License, Version 2.0 (the "License");
 | ||||
| // you may not use this file except in compliance with the License.
 | ||||
| // You may obtain a copy of the License at
 | ||||
| //
 | ||||
| //     http://www.apache.org/licenses/LICENSE-2.0
 | ||||
| //
 | ||||
| // Unless required by applicable law or agreed to in writing, software
 | ||||
| // distributed under the License is distributed on an "AS IS" BASIS,
 | ||||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | ||||
| // See the License for the specific language governing permissions and
 | ||||
| // limitations under the License.
 | ||||
| 
 | ||||
| import { Component, OnInit, ViewChild } from '@angular/core'; | ||||
| import { CoreCourseWSModule } from '@features/course/services/course'; | ||||
| import { CoreNavigator } from '@services/navigator'; | ||||
| import { AddonModPageIndexComponent } from '../../components/index/index'; | ||||
| import { AddonModPagePage } from '../../services/page'; | ||||
| 
 | ||||
| /** | ||||
|  * Page that displays a page. | ||||
|  */ | ||||
| @Component({ | ||||
|     selector: 'page-addon-mod-page-index', | ||||
|     templateUrl: 'index.html', | ||||
| }) | ||||
| export class AddonModPageIndexPage implements OnInit { | ||||
| 
 | ||||
|     @ViewChild(AddonModPageIndexComponent) pageComponent?: AddonModPageIndexComponent; | ||||
| 
 | ||||
|     title?: string; | ||||
|     module?: CoreCourseWSModule; | ||||
|     courseId?: number; | ||||
| 
 | ||||
|     /** | ||||
|      * Component being initialized. | ||||
|      */ | ||||
|     ngOnInit(): void { | ||||
|         this.module = CoreNavigator.getRouteParam('module'); | ||||
|         this.courseId = CoreNavigator.getRouteNumberParam('courseId'); | ||||
|         this.title = this.module?.name; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Update some data based on the page instance. | ||||
|      * | ||||
|      * @param page Page instance. | ||||
|      */ | ||||
|     updateData(page: CoreCourseWSModule | AddonModPagePage): void { | ||||
|         this.title = 'name' in page ? page.name : this.title; | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| @ -16,7 +16,7 @@ import { NgModule } from '@angular/core'; | ||||
| import { RouterModule, Routes } from '@angular/router'; | ||||
| 
 | ||||
| import { CoreSharedModule } from '@/core/shared.module'; | ||||
| import { AddonModQuizAttemptPage } from './attempt'; | ||||
| import { AddonModQuizAttemptPage } from './attempt.page'; | ||||
| 
 | ||||
| const routes: Routes = [ | ||||
|     { | ||||
|  | ||||
| @ -14,7 +14,7 @@ | ||||
|     </ion-toolbar> | ||||
| </ion-header> | ||||
| <ion-content> | ||||
|     <ion-refresher slot="fixed" [disabled]="!quizComponent?.loaded" (ionRefresh)="quizComponent?.doRefresh($event)"> | ||||
|     <ion-refresher slot="fixed" [disabled]="!activityComponent?.loaded" (ionRefresh)="activityComponent?.doRefresh($event)"> | ||||
|         <ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content> | ||||
|     </ion-refresher> | ||||
| 
 | ||||
|  | ||||
| @ -1,40 +0,0 @@ | ||||
| // (C) Copyright 2015 Moodle Pty Ltd.
 | ||||
| //
 | ||||
| // Licensed under the Apache License, Version 2.0 (the "License");
 | ||||
| // you may not use this file except in compliance with the License.
 | ||||
| // You may obtain a copy of the License at
 | ||||
| //
 | ||||
| //     http://www.apache.org/licenses/LICENSE-2.0
 | ||||
| //
 | ||||
| // Unless required by applicable law or agreed to in writing, software
 | ||||
| // distributed under the License is distributed on an "AS IS" BASIS,
 | ||||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | ||||
| // See the License for the specific language governing permissions and
 | ||||
| // limitations under the License.
 | ||||
| 
 | ||||
| import { NgModule } from '@angular/core'; | ||||
| import { RouterModule, Routes } from '@angular/router'; | ||||
| 
 | ||||
| import { CoreSharedModule } from '@/core/shared.module'; | ||||
| import { AddonModQuizComponentsModule } from '../../components/components.module'; | ||||
| import { AddonModQuizIndexPage } from './index'; | ||||
| 
 | ||||
| const routes: Routes = [ | ||||
|     { | ||||
|         path: '', | ||||
|         component: AddonModQuizIndexPage, | ||||
|     }, | ||||
| ]; | ||||
| 
 | ||||
| @NgModule({ | ||||
|     imports: [ | ||||
|         RouterModule.forChild(routes), | ||||
|         CoreSharedModule, | ||||
|         AddonModQuizComponentsModule, | ||||
|     ], | ||||
|     declarations: [ | ||||
|         AddonModQuizIndexPage, | ||||
|     ], | ||||
|     exports: [RouterModule], | ||||
| }) | ||||
| export class AddonModQuizIndexPageModule {} | ||||
							
								
								
									
										30
									
								
								src/addons/mod/quiz/pages/index/index.page.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								src/addons/mod/quiz/pages/index/index.page.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,30 @@ | ||||
| // (C) Copyright 2015 Moodle Pty Ltd.
 | ||||
| //
 | ||||
| // Licensed under the Apache License, Version 2.0 (the "License");
 | ||||
| // you may not use this file except in compliance with the License.
 | ||||
| // You may obtain a copy of the License at
 | ||||
| //
 | ||||
| //     http://www.apache.org/licenses/LICENSE-2.0
 | ||||
| //
 | ||||
| // Unless required by applicable law or agreed to in writing, software
 | ||||
| // distributed under the License is distributed on an "AS IS" BASIS,
 | ||||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | ||||
| // See the License for the specific language governing permissions and
 | ||||
| // limitations under the License.
 | ||||
| 
 | ||||
| import { Component, ViewChild } from '@angular/core'; | ||||
| import { CoreCourseModuleMainActivityPage } from '@features/course/classes/main-activity-page'; | ||||
| import { AddonModQuizIndexComponent } from '../../components/index/index'; | ||||
| 
 | ||||
| /** | ||||
|  * Page that displays the quiz entry page. | ||||
|  */ | ||||
| @Component({ | ||||
|     selector: 'page-addon-mod-quiz-index', | ||||
|     templateUrl: 'index.html', | ||||
| }) | ||||
| export class AddonModQuizIndexPage extends CoreCourseModuleMainActivityPage<AddonModQuizIndexComponent> { | ||||
| 
 | ||||
|     @ViewChild(AddonModQuizIndexComponent) activityComponent?: AddonModQuizIndexComponent; | ||||
| 
 | ||||
| } | ||||
| @ -1,69 +0,0 @@ | ||||
| // (C) Copyright 2015 Moodle Pty Ltd.
 | ||||
| //
 | ||||
| // Licensed under the Apache License, Version 2.0 (the "License");
 | ||||
| // you may not use this file except in compliance with the License.
 | ||||
| // You may obtain a copy of the License at
 | ||||
| //
 | ||||
| //     http://www.apache.org/licenses/LICENSE-2.0
 | ||||
| //
 | ||||
| // Unless required by applicable law or agreed to in writing, software
 | ||||
| // distributed under the License is distributed on an "AS IS" BASIS,
 | ||||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | ||||
| // See the License for the specific language governing permissions and
 | ||||
| // limitations under the License.
 | ||||
| 
 | ||||
| import { Component, OnInit, ViewChild } from '@angular/core'; | ||||
| 
 | ||||
| import { CoreCourseWSModule } from '@features/course/services/course'; | ||||
| import { CoreNavigator } from '@services/navigator'; | ||||
| import { AddonModQuizIndexComponent } from '../../components/index'; | ||||
| import { AddonModQuizQuizWSData } from '../../services/quiz'; | ||||
| 
 | ||||
| /** | ||||
|  * Page that displays the quiz entry page. | ||||
|  */ | ||||
| @Component({ | ||||
|     selector: 'page-addon-mod-quiz-index', | ||||
|     templateUrl: 'index.html', | ||||
| }) | ||||
| export class AddonModQuizIndexPage implements OnInit { | ||||
| 
 | ||||
|     @ViewChild(AddonModQuizIndexComponent) quizComponent?: AddonModQuizIndexComponent; | ||||
| 
 | ||||
|     title?: string; | ||||
|     module?: CoreCourseWSModule; | ||||
|     courseId?: number; | ||||
| 
 | ||||
|     /** | ||||
|      * Component being initialized. | ||||
|      */ | ||||
|     ngOnInit(): void { | ||||
|         this.module = CoreNavigator.getRouteParam('module'); | ||||
|         this.courseId = CoreNavigator.getRouteNumberParam('courseId'); | ||||
|         this.title = this.module?.name; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Update some data based on the quiz instance. | ||||
|      * | ||||
|      * @param quiz Quiz instance. | ||||
|      */ | ||||
|     updateData(quiz: AddonModQuizQuizWSData): void { | ||||
|         this.title = quiz.name || this.title; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * User entered the page. | ||||
|      */ | ||||
|     ionViewDidEnter(): void { | ||||
|         this.quizComponent?.ionViewDidEnter(); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * User left the page. | ||||
|      */ | ||||
|     ionViewDidLeave(): void { | ||||
|         this.quizComponent?.ionViewDidLeave(); | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| @ -18,7 +18,7 @@ import { RouterModule, Routes } from '@angular/router'; | ||||
| 
 | ||||
| import { CoreQuestionComponentsModule } from '@features/question/components/components.module'; | ||||
| import { CanLeaveGuard } from '@guards/can-leave'; | ||||
| import { AddonModQuizPlayerPage } from './player'; | ||||
| import { AddonModQuizPlayerPage } from './player.page'; | ||||
| 
 | ||||
| const routes: Routes = [ | ||||
|     { | ||||
|  | ||||
| @ -17,7 +17,7 @@ import { RouterModule, Routes } from '@angular/router'; | ||||
| 
 | ||||
| import { CoreSharedModule } from '@/core/shared.module'; | ||||
| import { CoreQuestionComponentsModule } from '@features/question/components/components.module'; | ||||
| import { AddonModQuizReviewPage } from './review'; | ||||
| import { AddonModQuizReviewPage } from './review.page'; | ||||
| 
 | ||||
| const routes: Routes = [ | ||||
|     { | ||||
|  | ||||
| @ -15,10 +15,15 @@ | ||||
| import { NgModule } from '@angular/core'; | ||||
| import { RouterModule, Routes } from '@angular/router'; | ||||
| 
 | ||||
| import { CoreSharedModule } from '@/core/shared.module'; | ||||
| import { AddonModQuizComponentsModule } from './components/components.module'; | ||||
| 
 | ||||
| import { AddonModQuizIndexPage } from './pages/index/index.page'; | ||||
| 
 | ||||
| const routes: Routes = [ | ||||
|     { | ||||
|         path: ':courseId/:cmId', | ||||
|         loadChildren: () => import('./pages/index/index.module').then( m => m.AddonModQuizIndexPageModule), | ||||
|         component: AddonModQuizIndexPage, | ||||
|     }, | ||||
|     { | ||||
|         path: ':courseId/:cmId/player', | ||||
| @ -35,6 +40,13 @@ const routes: Routes = [ | ||||
| ]; | ||||
| 
 | ||||
| @NgModule({ | ||||
|     imports: [RouterModule.forChild(routes)], | ||||
|     imports: [ | ||||
|         RouterModule.forChild(routes), | ||||
|         CoreSharedModule, | ||||
|         AddonModQuizComponentsModule, | ||||
|     ], | ||||
|     declarations: [ | ||||
|         AddonModQuizIndexPage, | ||||
|     ], | ||||
| }) | ||||
| export class AddonModQuizLazyModule {} | ||||
|  | ||||
| @ -42,7 +42,7 @@ | ||||
|         </ion-list> | ||||
| 
 | ||||
|         <!-- Message telling there are no files. --> | ||||
|         <core-empty-box *ngIf="!files || !files.length" icon="folder" [message]="'addon.privatefiles.emptyfilelist' | translate"> | ||||
|         <core-empty-box *ngIf="!files || !files.length" icon="far-folder-open" [message]="'addon.privatefiles.emptyfilelist' | translate"> | ||||
|         </core-empty-box> | ||||
|     </core-loading> | ||||
| 
 | ||||
|  | ||||
| @ -13,23 +13,28 @@ | ||||
| // limitations under the License.
 | ||||
| 
 | ||||
| import { Component, OnInit } from '@angular/core'; | ||||
| 
 | ||||
| import { AddonModForumData } from '@addons/mod/forum/services/forum'; | ||||
| import { CoreCourseAnyModuleData } from '@features/course/services/course'; | ||||
| import { CoreNavigator } from '@services/navigator'; | ||||
| import { CoreCourseAnyModuleData } from '../services/course'; | ||||
| import { CoreCourseModuleMainResourceComponent } from './main-resource-component'; | ||||
| 
 | ||||
| /** | ||||
| /** | ||||
|  * Template class to easily create CoreCourseModuleMainComponent of resources (or activities without syncing). | ||||
|  */ | ||||
| @Component({ | ||||
|     selector: 'page-addon-mod-forum-index', | ||||
|     templateUrl: 'index.html', | ||||
|     template: '', | ||||
| }) | ||||
| export class AddonModForumIndexPage implements OnInit { | ||||
| export class CoreCourseModuleMainActivityPage<ActivityType extends CoreCourseModuleMainResourceComponent> implements OnInit { | ||||
| 
 | ||||
|     activityComponent?: ActivityType; | ||||
| 
 | ||||
|     title!: string; | ||||
|     module!: CoreCourseAnyModuleData; | ||||
|     courseId!: number; | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * @inheritdoc | ||||
|      * Component being initialized. | ||||
|      */ | ||||
|     ngOnInit(): void { | ||||
|         this.module = CoreNavigator.getRouteParam<CoreCourseAnyModuleData>('module')!; | ||||
| @ -38,12 +43,26 @@ export class AddonModForumIndexPage implements OnInit { | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Update some data based on the forum instance. | ||||
|      * Update some data based on the activity instance. | ||||
|      * | ||||
|      * @param forum Forum instance. | ||||
|      * @param activity Activity instance. | ||||
|      */ | ||||
|     updateData(forum: AddonModForumData): void { | ||||
|         this.title = forum.name || this.title; | ||||
|     updateData(activity: { name: string}): void { | ||||
|         this.title = activity.name || this.title; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * User entered the page. | ||||
|      */ | ||||
|     ionViewDidEnter(): void { | ||||
|         this.activityComponent?.ionViewDidEnter(); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * User left the page. | ||||
|      */ | ||||
|     ionViewDidLeave(): void { | ||||
|         this.activityComponent?.ionViewDidLeave(); | ||||
|     } | ||||
| 
 | ||||
| } | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user