"use strict";(self.webpackChunkapp=self.webpackChunkapp||[]).push([[34021],{34021:(e,t,o)=>{o.r(t),o.d(t,{AddonModQuizPreflightModalComponent:()=>R});var n=o(10467),i=o(52749),r=o(63153),l=o(79555),a=o(15646),d=o(82907),s=o(86654),c=o(91416),u=o(25572),m=o(54438),p=o(89417),f=o(60177),h=o(2910),g=o(68162),_=o(64422),M=o(4060),b=o(86198),z=o(88246),C=o(43570),A=o(73955);const F=["preflightFormEl"];function AddonModQuizPreflightModalComponent_ng_container_15_core_spacer_4_Template(e,t){1&e&&m.nrm(0,"core-spacer")}function AddonModQuizPreflightModalComponent_ng_container_15_Template(e,t){if(1&e&&(m.qex(0),m.j41(1,"core-dynamic-component",10)(2,"p",11),m.EFF(3,"Couldn't find the directive to render this access rule."),m.k0s()(),m.DNE(4,AddonModQuizPreflightModalComponent_ng_container_15_core_spacer_4_Template,1,0,"core-spacer",12),m.bVm()),2&e){const e=t.$implicit,o=t.last;m.R7$(),m.Y8G("component",e.component)("data",e.data),m.R7$(3),m.Y8G("ngIf",!o)}}let R=(()=>{var e;class AddonModQuizPreflightModalComponent{constructor(e,t){this.elementRef=t,this.prefetch=!1,this.accessRulesData=[],this.loaded=!1,this.preflightForm=e.group({})}ngOnInit(){var e=this;return(0,n.A)((function*(){if(e.title=e.title||l.HT.instant("addon.mod_quiz.startattempt"),e.siteId=e.siteId||i.CoreSites.getCurrentSiteId(),e.rules=e.rules||[],e.quiz)try{const t=e.quiz;yield Promise.all(e.rules.map(function(){var o=(0,n.A)((function*(o){if(!(yield a.AddonModQuizAccessRuleDelegate.isPreflightCheckRequiredForRule(o,t,e.attempt,e.prefetch,e.siteId)))return;const n=yield a.AddonModQuizAccessRuleDelegate.getPreflightComponent(o);n&&e.accessRulesData.push({component:n,data:{rule:o,quiz:e.quiz,attempt:e.attempt,prefetch:e.prefetch,form:e.preflightForm,siteId:e.siteId}})}));return function(e){return o.apply(this,arguments)}}()))}catch(e){u.CoreAlerts.showError(e,{default:"Error loading rules"})}finally{e.loaded=!0}}))()}sendData(e){var t=this;return(0,n.A)((function*(){if(e.preventDefault(),e.stopPropagation(),t.preflightForm.valid)r.R.triggerFormSubmittedEvent(t.formElement,!1,t.siteId),l.W3.dismiss(t.preflightForm.value);else{(yield d.y.scrollToInputError(t.elementRef.nativeElement))||u.CoreAlerts.showError(l.HT.instant("core.errorinvalidform"))}}))()}closeModal(){r.R.triggerFormCancelledEvent(this.formElement,this.siteId),l.W3.dismiss()}}return(e=AddonModQuizPreflightModalComponent).ɵfac=function AddonModQuizPreflightModalComponent_Factory(t){return new(t||e)(m.rXU(p.ok),m.rXU(m.aKT))},e.ɵcmp=m.VBU({type:e,selectors:[["page-addon-mod-quiz-preflight-modal"]],viewQuery:function AddonModQuizPreflightModalComponent_Query(e,t){if(1&e&&m.GBs(F,5),2&e){let e;m.mGM(e=m.lsd())&&(t.formElement=e.first)}},inputs:{title:"title",quiz:"quiz",attempt:"attempt",prefetch:[m.Mj6.HasDecoratorInputTransform,"prefetch","prefetch",c.G],siteId:"siteId",rules:"rules"},standalone:!0,features:[m.GFd,m.aNF],decls:20,vars:12,consts:[["preflightFormEl",""],["slot","end"],["fill","clear",3,"click","ariaLabel"],["slot","icon-only","name","fas-xmark","aria-hidden","true"],[1,"addon-mod_quiz-preflight-modal"],[3,"hideUntil"],[3,"ngSubmit","formGroup"],[4,"ngFor","ngForOf"],["expand","block","type","submit",1,"ion-margin"],["type","submit",1,"core-submit-hidden-enter"],[3,"component","data"],[1,"ion-padding"],[4,"ngIf"]],template:function AddonModQuizPreflightModalComponent_Template(e,t){if(1&e){const e=m.RV6();m.j41(0,"ion-header")(1,"ion-toolbar")(2,"ion-title")(3,"h1"),m.EFF(4),m.nI1(5,"translate"),m.k0s()(),m.j41(6,"ion-buttons",1)(7,"ion-button",2),m.nI1(8,"translate"),m.bIt("click",(function AddonModQuizPreflightModalComponent_Template_ion_button_click_7_listener(){return m.eBV(e),m.Njj(t.closeModal())})),m.nrm(9,"ion-icon",3),m.k0s()()()(),m.j41(10,"ion-content",4)(11,"core-loading",5)(12,"form",6,0),m.bIt("ngSubmit",(function AddonModQuizPreflightModalComponent_Template_form_ngSubmit_12_listener(o){return m.eBV(e),m.Njj(t.sendData(o))})),m.j41(14,"ion-list"),m.DNE(15,AddonModQuizPreflightModalComponent_ng_container_15_Template,5,3,"ng-container",7),m.j41(16,"ion-button",8),m.EFF(17),m.nI1(18,"translate"),m.k0s(),m.nrm(19,"input",9),m.k0s()()()()}2&e&&(m.R7$(4),m.JRh(m.bMT(5,6,t.title)),m.R7$(3),m.Y8G("ariaLabel",m.bMT(8,8,"core.close")),m.R7$(4),m.Y8G("hideUntil",t.loaded),m.R7$(),m.Y8G("formGroup",t.preflightForm),m.R7$(3),m.Y8G("ngForOf",t.accessRulesData),m.R7$(2),m.SpI(" ",m.bMT(18,10,t.title)," "))},dependencies:[s.n,f.Sq,f.bT,p.qT,p.cb,h.Jm,h.QW,h.W9,h.eU,h.iq,h.nf,h.BC,h.ai,p.j4,g.m,_.R,M.f,b.t,z.i,C.T,A.D9],encapsulation:2}),AddonModQuizPreflightModalComponent})()}}]);