forked from CIT/Vmeda.Online
		
	MOBILE-3657 workshop: Add siteplugins support
This commit is contained in:
		
							parent
							
								
									8a5ea5e76f
								
							
						
					
					
						commit
						cb835f7031
					
				@ -0,0 +1,70 @@
 | 
			
		||||
// (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 { AddonWorkshopAssessmentStrategyHandler } from '@addons/mod/workshop/services/assessment-strategy-delegate';
 | 
			
		||||
import { AddonModWorkshopGetAssessmentFormFieldsParsedData } from '@addons/mod/workshop/services/workshop';
 | 
			
		||||
import { Type } from '@angular/core';
 | 
			
		||||
import {
 | 
			
		||||
    CoreSitePluginsWorkshopAssessmentStrategyComponent,
 | 
			
		||||
} from '@features/siteplugins/components/workshop-assessment-strategy/workshop-assessment-strategy';
 | 
			
		||||
import { CoreFormFields } from '@singletons/form';
 | 
			
		||||
import { CoreSitePluginsBaseHandler } from './base-handler';
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Handler to display a workshop assessment strategy site plugin.
 | 
			
		||||
 */
 | 
			
		||||
export class CoreSitePluginsWorkshopAssessmentStrategyHandler
 | 
			
		||||
    extends CoreSitePluginsBaseHandler
 | 
			
		||||
    implements AddonWorkshopAssessmentStrategyHandler {
 | 
			
		||||
 | 
			
		||||
    constructor(public name: string, public strategyName: string) {
 | 
			
		||||
        super(name);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @inheritdoc
 | 
			
		||||
     */
 | 
			
		||||
    getComponent(): Type<unknown> {
 | 
			
		||||
        return CoreSitePluginsWorkshopAssessmentStrategyComponent;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @inheritdoc
 | 
			
		||||
     */
 | 
			
		||||
    async getOriginalValues(): Promise<AddonModWorkshopGetAssessmentFormFieldsParsedData[]> {
 | 
			
		||||
        return [];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @inheritdoc
 | 
			
		||||
     */
 | 
			
		||||
    hasDataChanged(): boolean {
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @inheritdoc
 | 
			
		||||
     */
 | 
			
		||||
    async isEnabled(): Promise<boolean> {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @inheritdoc
 | 
			
		||||
     */
 | 
			
		||||
    async prepareAssessmentData(): Promise<CoreFormFields> {
 | 
			
		||||
        return {};
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -25,8 +25,7 @@ import { CoreSitePluginsQuestionBehaviourComponent } from './question-behaviour/
 | 
			
		||||
import { CoreSitePluginsQuizAccessRuleComponent } from './quiz-access-rule/quiz-access-rule';
 | 
			
		||||
import { CoreSitePluginsAssignFeedbackComponent } from './assign-feedback/assign-feedback';
 | 
			
		||||
import { CoreSitePluginsAssignSubmissionComponent } from './assign-submission/assign-submission';
 | 
			
		||||
// @todo
 | 
			
		||||
// import { CoreSitePluginsWorkshopAssessmentStrategyComponent } from './workshop-assessment-strategy/workshop-assessment-strategy';
 | 
			
		||||
import { CoreSitePluginsWorkshopAssessmentStrategyComponent } from './workshop-assessment-strategy/workshop-assessment-strategy';
 | 
			
		||||
import { CoreSitePluginsBlockComponent } from './block/block';
 | 
			
		||||
import { CoreSitePluginsOnlyTitleBlockComponent } from './only-title-block/only-title-block';
 | 
			
		||||
 | 
			
		||||
@ -43,7 +42,7 @@ import { CoreSitePluginsOnlyTitleBlockComponent } from './only-title-block/only-
 | 
			
		||||
        CoreSitePluginsQuizAccessRuleComponent,
 | 
			
		||||
        CoreSitePluginsAssignFeedbackComponent,
 | 
			
		||||
        CoreSitePluginsAssignSubmissionComponent,
 | 
			
		||||
        // @todo CoreSitePluginsWorkshopAssessmentStrategyComponent,
 | 
			
		||||
        CoreSitePluginsWorkshopAssessmentStrategyComponent,
 | 
			
		||||
    ],
 | 
			
		||||
    imports: [
 | 
			
		||||
        CoreSharedModule,
 | 
			
		||||
@ -61,7 +60,7 @@ import { CoreSitePluginsOnlyTitleBlockComponent } from './only-title-block/only-
 | 
			
		||||
        CoreSitePluginsQuizAccessRuleComponent,
 | 
			
		||||
        CoreSitePluginsAssignFeedbackComponent,
 | 
			
		||||
        CoreSitePluginsAssignSubmissionComponent,
 | 
			
		||||
        // @todo CoreSitePluginsWorkshopAssessmentStrategyComponent,
 | 
			
		||||
        CoreSitePluginsWorkshopAssessmentStrategyComponent,
 | 
			
		||||
    ],
 | 
			
		||||
})
 | 
			
		||||
export class CoreSitePluginsComponentsModule {}
 | 
			
		||||
 | 
			
		||||
@ -0,0 +1 @@
 | 
			
		||||
<core-compile-html [text]="content" [jsData]="jsData" (created)="componentCreated($event)"></core-compile-html>
 | 
			
		||||
@ -0,0 +1,54 @@
 | 
			
		||||
// (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 { AddonWorkshopAssessmentStrategyDelegate } from '@addons/mod/workshop/services/assessment-strategy-delegate';
 | 
			
		||||
import { AddonModWorkshopGetAssessmentFormFieldsParsedData } from '@addons/mod/workshop/services/workshop';
 | 
			
		||||
import { AddonModWorkshopSubmissionAssessmentWithFormData } from '@addons/mod/workshop/services/workshop-helper';
 | 
			
		||||
import { Component, OnInit, Input } from '@angular/core';
 | 
			
		||||
import { CoreSitePluginsCompileInitComponent } from '@features/siteplugins/classes/compile-init-component';
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Component that displays a workshop assessment strategy plugin created using a site plugin.
 | 
			
		||||
 */
 | 
			
		||||
@Component({
 | 
			
		||||
    selector: 'core-siteplugins-workshop-assessment-strategy',
 | 
			
		||||
    templateUrl: 'core-siteplugins-workshop-assessment-strategy.html',
 | 
			
		||||
})
 | 
			
		||||
export class CoreSitePluginsWorkshopAssessmentStrategyComponent extends CoreSitePluginsCompileInitComponent implements OnInit {
 | 
			
		||||
 | 
			
		||||
    @Input() workshopId!: number;
 | 
			
		||||
    @Input() assessment!: AddonModWorkshopSubmissionAssessmentWithFormData;
 | 
			
		||||
    @Input() edit!: boolean;
 | 
			
		||||
    @Input() selectedValues!: AddonModWorkshopGetAssessmentFormFieldsParsedData[];
 | 
			
		||||
    @Input() fieldErrors!: Record<string, string>;
 | 
			
		||||
    @Input() strategy!: string;
 | 
			
		||||
    @Input() moduleId!: number;
 | 
			
		||||
    @Input() courseId?: number;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @inheritdoc
 | 
			
		||||
     */
 | 
			
		||||
    ngOnInit(): void {
 | 
			
		||||
        // Pass the input and output data to the component.
 | 
			
		||||
        this.jsData.workshopId = this.workshopId;
 | 
			
		||||
        this.jsData.assessment = this.assessment;
 | 
			
		||||
        this.jsData.edit = this.edit;
 | 
			
		||||
        this.jsData.selectedValues = this.selectedValues;
 | 
			
		||||
        this.jsData.fieldErrors = this.fieldErrors;
 | 
			
		||||
        this.jsData.strategy = this.strategy;
 | 
			
		||||
 | 
			
		||||
        this.getHandlerData(AddonWorkshopAssessmentStrategyDelegate.getHandlerName(this.strategy));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -79,6 +79,8 @@ import {
 | 
			
		||||
import { makeSingleton } from '@singletons';
 | 
			
		||||
import { CoreMainMenuHomeDelegate } from '@features/mainmenu/services/home-delegate';
 | 
			
		||||
import { CoreSitePluginsMainMenuHomeHandler } from '../classes/handlers/main-menu-home-handler';
 | 
			
		||||
import { AddonWorkshopAssessmentStrategyDelegate } from '@addons/mod/workshop/services/assessment-strategy-delegate';
 | 
			
		||||
import { CoreSitePluginsWorkshopAssessmentStrategyHandler } from '../classes/handlers/workshop-assessment-strategy-handler';
 | 
			
		||||
 | 
			
		||||
const HANDLER_DISABLED = 'core_site_plugins_helper_handler_disabled';
 | 
			
		||||
 | 
			
		||||
@ -1094,27 +1096,23 @@ export class CoreSitePluginsHelperProvider {
 | 
			
		||||
     * @param handlerName Name of the handler in the plugin.
 | 
			
		||||
     * @param handlerSchema Data about the handler.
 | 
			
		||||
     * @return Promise resolved with a string to identify the handler.
 | 
			
		||||
     * @todo
 | 
			
		||||
     */
 | 
			
		||||
    protected registerWorkshopAssessmentStrategyHandler(
 | 
			
		||||
        plugin: CoreSitePluginsPlugin, // eslint-disable-line @typescript-eslint/no-unused-vars
 | 
			
		||||
        handlerName: string, // eslint-disable-line @typescript-eslint/no-unused-vars
 | 
			
		||||
        handlerSchema: CoreSitePluginsHandlerCommonData, // eslint-disable-line @typescript-eslint/no-unused-vars
 | 
			
		||||
        plugin: CoreSitePluginsPlugin,
 | 
			
		||||
        handlerName: string,
 | 
			
		||||
        handlerSchema: CoreSitePluginsHandlerCommonData,
 | 
			
		||||
    ): Promise<string | undefined> {
 | 
			
		||||
        // @todo
 | 
			
		||||
        return Promise.resolve('');
 | 
			
		||||
        return this.registerComponentInitHandler(
 | 
			
		||||
            plugin,
 | 
			
		||||
            handlerName,
 | 
			
		||||
            handlerSchema,
 | 
			
		||||
            AddonWorkshopAssessmentStrategyDelegate.instance,
 | 
			
		||||
            (uniqueName) => {
 | 
			
		||||
                const strategyName = (handlerSchema.moodlecomponent || plugin.component).replace('workshopform_', '');
 | 
			
		||||
 | 
			
		||||
        // return this.registerComponentInitHandler(
 | 
			
		||||
        //     plugin,
 | 
			
		||||
        //     handlerName,
 | 
			
		||||
        //     handlerSchema,
 | 
			
		||||
        //     this.workshopAssessmentStrategyDelegate,
 | 
			
		||||
        //     (uniqueName, result) => {
 | 
			
		||||
        //         const strategyName = (handlerSchema.moodlecomponent || plugin.component).replace('workshopform_', '');
 | 
			
		||||
 | 
			
		||||
        //         return new CoreSitePluginsWorkshopAssessmentStrategyHandler(uniqueName, strategyName);
 | 
			
		||||
        //     },
 | 
			
		||||
        // );
 | 
			
		||||
                return new CoreSitePluginsWorkshopAssessmentStrategyHandler(uniqueName, strategyName);
 | 
			
		||||
            },
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user