This repository was archived by the owner on Sep 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path8533.badfb557.chunk.js
1 lines (1 loc) · 12 KB
/
8533.badfb557.chunk.js
1
"use strict";(self.webpackChunkacellus=self.webpackChunkacellus||[]).push([[8533],{28533:function(e,n,t){t.r(n),t.d(n,{default:function(){return E}});var a=t(1413),r=t(29439),i=t(4942),o=t(43681),d=t(47313),l=t(72159),s=t(20388),c=t(51083),u=t(58500),g=t(72363),p=t(41066),m=t(98592),h=t(92109),x=t(16533),v=t(81570),f=t(11360),b=t(58229),j=t(44531),w=t(46417),y=["First","Second","Third","Fourth","Last"].map((function(e,n){return{name:e,value:n}})),C=f.oN.long.slice(1,6).map((function(e,n){return{name:e,value:n}})),Z=f.e7.map((function(e,n){return{name:e,value:n}})),I=[{value:1,name:"1 per full-year course"},{value:2,name:"2 per full-year course"},{value:5,name:"5 per full-year course"},{value:10,name:"10 per full-year course"}],k=/^grading\.scale\[\d+\]\./,T=function(){var e;return e={},(0,i.Z)(e,crypto.randomUUID(),{}),(0,i.Z)(e,crypto.randomUUID(),{}),(0,i.Z)(e,crypto.randomUUID(),{}),(0,i.Z)(e,crypto.randomUUID(),{}),e};function E(){var e,n,t,o,c,f,j,E,G,R,V,z,N,$,Q,H,J,K,X,_,ee,ne=(0,p.Av)(),te=ne.settings,ae=ne.schoolYear,re=ae.beginWeek,ie=ae.beginWeekday,oe=ae.beginMonth,de=ae.endWeek,le=ae.endWeekday,se=ae.endMonth,ce=(0,d.useState)(T),ue=(0,r.Z)(ce,2),ge=ue[0],pe=ue[1],me=Object.entries(ge);(0,d.useEffect)((function(){var e,n,t;if(null===te||void 0===te||null===(e=te.grading)||void 0===e||null===(n=e.scale)||void 0===n||!n.length)return pe(T);pe(Object.fromEntries(null===(t=te.grading)||void 0===t?void 0:t.scale.map((function(e){return[crypto.randomUUID(),e]}))))}),[null===te||void 0===te||null===(e=te.grading)||void 0===e?void 0:e.scale]);var he=(0,h.Z)((function(e,n,t){switch(e){case"grading.weights.attendance":case"grading.weights.unitExams":case"grading.weights.problems":case"grading.weights.midExams":case"grading.weights.finalExams":var a=e.split(".").pop().replace(/([A-Z])/g," $1");a=(a=a.charAt(0).toUpperCase()+a.slice(1)).replace("Mid","Mid-Term");var r=Number(n)||0;if(t.totalWeight=(t.totalWeight||0)+r,!n.length)return{text:"Required",tooltip:"".concat(a," is required.")};if(r<0)return{text:"Invalid",tooltip:"".concat(a," must at least be 0.")};if(r>100)return{text:"Invalid",tooltip:"".concat(a," cannot exceed 100.")}}if(k.test(e))switch(e.split(".").pop()){case"l":if(!n.length)return{text:"Required",tooltip:"Letter is required."};if(n.length>3)return{text:"Invalid",tooltip:"Letter can only be at most 3 characters long."};break;case"s":if(!n.length)return{text:"Required",tooltip:"Percentage is required."};var i=Number(n)||0;if(i<0)return{text:"Invalid",tooltip:"Percentage must at least be 0."};if(i>100)return{text:"Invalid",tooltip:"Percentage cannot exceed 100."};0===i&&(t.hasZero=!0);break;case"p":if(!n.length)return{text:"Required",tooltip:"Grade Points is required."}}}),(function(e){var n=!0;return 100!==e.totalWeight&&(je(toast.error("Grading weights must total to 100%.")),n=!1),me.length<4&&(je(toast.error("Must have at least 4 grading levels.")),n=!1),e.hasZero||(je(toast.error("Must have a scale with a percentage of 0")),n=!1),n})),xe=he.fetcher,ve=he.errors,fe=he.isDirty,be=he.setIsDirty,je=he.addToast,we=he.handleSubmit,ye=he.handleBlur,Ce=he.handleChange,Ze=he.handleFocus,Ie=he.clearErrors,ke=he.checkError,Te=(0,x.G)("Leave without saving?",fe).toastRef;(0,d.useEffect)((function(){return(0,b.Oo)("toast-confirm",(function(e){e.detail.id===Te.current&&e.detail.confirmed&&be(!1)}))}),[be,Te]);var Ee=function(e,n,t){return Ie(t)},Se=function(e,n,t){Ie(t),be(!0)},Fe=function(e,n,t){return ke(t,n)},De=function(e,n){pe((function(t){var r=(0,a.Z)({},t);return r[e]=(0,a.Z)((0,a.Z)({},r[e]),{},(0,i.Z)({},n.target.name.split(".").pop(),n.target.value)),r})),Ce(n)};return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(S,{children:[(0,w.jsx)("h2",{children:"Grading Scale"}),(0,w.jsx)("p",{children:"Update your school's grade settings here."})]}),(0,w.jsx)(F,{children:(0,w.jsxs)(D,{children:[(0,w.jsx)(u.e5,{children:(0,w.jsx)("p",{children:"Letter"})}),(0,w.jsx)(u.e5,{children:(0,w.jsx)("p",{children:"Percentage"})}),(0,w.jsx)(u.e5,{children:(0,w.jsx)("p",{children:"Grade Points"})})]})}),(0,w.jsx)(B,{children:(0,w.jsxs)(xe.Form,{noValidate:!0,action:"/teacher/settings",method:"post",onSubmit:we,children:[(0,w.jsx)("div",{children:(0,w.jsxs)(L,{children:[me.map((function(e,n){var t,i,o,s,c,g,p=(0,r.Z)(e,2),h=p[0],x=p[1],v=De.bind(void 0,h);return(0,w.jsxs)(d.Fragment,{children:[(0,w.jsx)(u.e5,{children:(0,w.jsx)(l.II,{type:"text",name:"grading.scale[".concat(n,"].l"),error:null===(t=ve["grading.scale[".concat(n,"].l")])||void 0===t?void 0:t.text,errorTooltip:null===(i=ve["grading.scale[".concat(n,"].l")])||void 0===i?void 0:i.tooltip,value:x.l||"",placeholder:"Letter",onChange:v,onFocus:Ze,onBlur:ye,maxLength:3,children:(0,w.jsx)(U,{children:"\u2265"})})}),(0,w.jsx)(u.e5,{children:(0,w.jsx)(l.II,{type:"number",name:"grading.scale[".concat(n,"].s"),error:null===(o=ve["grading.scale[".concat(n,"].s")])||void 0===o?void 0:o.text,errorTooltip:null===(s=ve["grading.scale[".concat(n,"].s")])||void 0===s?void 0:s.tooltip,value:x.s||0,onChange:v,onFocus:Ze,onBlur:ye,max:"100",min:"0",children:(0,w.jsx)(U,{children:"%"})})}),(0,w.jsxs)(W,{children:[(0,w.jsx)(l.II,{type:"number",name:"grading.scale[".concat(n,"].p"),error:null===(c=ve["grading.scale[".concat(n,"].p")])||void 0===c?void 0:c.text,errorTooltip:null===(g=ve["grading.scale[".concat(n,"].p")])||void 0===g?void 0:g.tooltip,value:x.p||0,onChange:v,onFocus:Ze,onBlur:ye,step:".01"}),(0,w.jsx)(m.z,{"aria-label":me.length<=4?"Clear":"Delete",onClick:function(){return function(e){be(!0),pe((function(n){var t=(0,a.Z)({},n);return Object.values(t).length<=4?t[e]={}:delete t[e],t}))}(h)},"data-tooltip":"title",type:"button",children:(0,w.jsx)(m.p,{"aria-hidden":"true","data-testid":"delete-grade-button"})})]})]},h)})),(0,w.jsx)(u.BQ,{children:(0,w.jsx)(g.Z,{color:"teacherBlue",colorNum:600,onClick:function(){pe((function(e){return(0,a.Z)((0,a.Z)({},e),{},(0,i.Z)({},crypto.randomUUID(),{}))})),be(!0)},width:"100%","data-testid":"add-grade-button",type:"button",children:"Add Scale"})}),(0,w.jsx)(u.v$,{})]})}),(0,w.jsx)(O,{children:"Grading Weights"}),(0,w.jsxs)(u.n5,{children:[(0,w.jsx)(u.fY,{children:(0,w.jsx)(l.II,{type:"number","data-testid":"percent-input",name:"grading.weights.attendance",error:null===(n=ve["grading.weights.attendance"])||void 0===n?void 0:n.text,errorTooltip:null===(t=ve["grading.weights.attendance"])||void 0===t?void 0:t.tooltip,defaultValue:(null===(o=te.grading)||void 0===o||null===(c=o.weights)||void 0===c?void 0:c.attendance)||0,labelText:"Attendance",placeholder:"Attendance",onChange:Ce,onFocus:Ze,onBlur:ye,min:0,max:100,children:(0,w.jsx)(U,{children:"%"})})}),(0,w.jsx)(u.fY,{children:(0,w.jsx)(l.II,{type:"number","data-testid":"problems",name:"grading.weights.problems",error:null===(f=ve["grading.weights.problems"])||void 0===f?void 0:f.text,errorTooltip:null===(j=ve["grading.weights.problems"])||void 0===j?void 0:j.tooltip,defaultValue:(null===(E=te.grading)||void 0===E||null===(G=E.weights)||void 0===G?void 0:G.problems)||0,labelText:"Lesson Problems",onChange:Ce,onFocus:Ze,onBlur:ye,min:0,max:100,placeholder:"Lesson Problems",children:(0,w.jsx)(U,{children:"%"})})}),(0,w.jsx)(u.fY,{children:(0,w.jsx)(l.II,{"data-testid":"unit-exams",type:"number",name:"grading.weights.unitExams",percent:!0,error:null===(R=ve["grading.weights.unitExams"])||void 0===R?void 0:R.text,errorTooltip:null===(V=ve["grading.weights.unitExams"])||void 0===V?void 0:V.tooltip,defaultValue:(null===(z=te.grading)||void 0===z||null===(N=z.weights)||void 0===N?void 0:N.unitExams)||0,labelText:"Unit Exams",onChange:Ce,onFocus:Ze,onBlur:ye,min:0,max:100,placeholder:"Unit Exams",children:(0,w.jsx)(U,{children:"%"})})}),(0,w.jsx)(u.fY,{children:(0,w.jsx)(l.II,{"data-testid":"mid-exam",type:"number",name:"grading.weights.midExams",error:null===($=ve["grading.weights.midExams"])||void 0===$?void 0:$.text,errorTooltip:null===(Q=ve["grading.weights.midExams"])||void 0===Q?void 0:Q.tooltip,defaultValue:(null===(H=te.grading)||void 0===H||null===(J=H.weights)||void 0===J?void 0:J.midExams)||0,labelText:"Mid-Term Exams",onChange:Ce,onFocus:Ze,onBlur:ye,min:0,max:100,placeholder:"Mid-Term Exams",children:(0,w.jsx)(U,{children:"%"})})}),(0,w.jsx)(u.fY,{children:(0,w.jsx)(l.II,{"data-testid":"final-exam",type:"number",name:"grading.weights.finalExams",error:null===(K=ve["grading.weights.finalExams"])||void 0===K?void 0:K.text,errorTooltip:null===(X=ve["grading.weights.finalExams"])||void 0===X?void 0:X.tooltip,defaultValue:(null===(_=te.grading)||void 0===_||null===(ee=_.weights)||void 0===ee?void 0:ee.finalExams)||0,labelText:"Final Exams",onChange:Ce,onFocus:Ze,onBlur:ye,min:0,max:100,placeholder:"Final Exams",children:(0,w.jsx)(U,{children:"%"})})})]}),(0,w.jsx)(O,{children:"School Year"}),(0,w.jsx)(M,{children:(0,w.jsxs)(P,{children:[(0,w.jsx)(q,{children:(0,w.jsx)(s.Z,{name:"termData.beginWeek",labelText:"Start Date",data:y,onChange:Se,onOpen:Ee,onClose:Fe,defaultSelected:y[re]})}),(0,w.jsx)(A,{children:(0,w.jsx)(s.Z,{name:"termData.beginWeekday",data:C,onChange:Se,onOpen:Ee,onClose:Fe,defaultSelected:C[ie]})}),(0,w.jsx)(q,{children:(0,w.jsx)(s.Z,{name:"termData.beginMonth",data:Z,onChange:Se,onOpen:Ee,onClose:Fe,defaultSelected:Z[oe]})}),(0,w.jsx)(Y,{children:(0,w.jsx)(s.Z,{name:"termData.endWeek",labelText:"End Date",data:y,onChange:Se,onOpen:Ee,onClose:Fe,defaultSelected:y[de]})}),(0,w.jsx)(A,{children:(0,w.jsx)(s.Z,{name:"termData.endWeekday",data:C,onChange:Se,onOpen:Ee,onClose:Fe,defaultSelected:C[le]})}),(0,w.jsx)(q,{children:(0,w.jsx)(s.Z,{name:"termData.endMonth",data:Z,onChange:Se,onOpen:Ee,onClose:Fe,defaultSelected:Z[se]})})]})}),(0,w.jsx)(O,{children:"Credit System"}),(0,w.jsx)(L,{children:(0,w.jsx)(u.F4,{children:(0,w.jsx)(s.Z,{labelText:"Choose a Credit System",name:"grading.creditSystem",error:ve["grading.creditSystem"],data:I,onChange:Se,onOpen:Ee,onClose:Fe,placeholder:"Select a Credit System",defaultSelected:I.find((function(e){var n;return e.value===(null===(n=te.grading)||void 0===n?void 0:n.creditSystem)}))})})}),(0,w.jsx)(u.ZL,{isSubmitting:"submitting"===xe.state,error:xe.data instanceof v.Z||!(0,b.z)(ve),noBottomPadding:!0})]})})]})}var S=(0,o.Z)(c.i)({padding:"var(--spacing)",paddingBottom:"1.5rem","@media (min-width: 1024px)":{paddingTop:"2.5rem"}}),F=(0,o.Z)(c.i)({position:"sticky",top:"7rem",zIndex:"10",marginTop:"0.5rem",marginBottom:"0.5rem",borderBottomWidth:"1px","--tw-border-opacity":"1",borderColor:"rgb(255 255 255 / var(--tw-border-opacity))",backgroundColor:"rgb(255 255 255 / 0.3)","--tw-bg-opacity":"0.8",paddingLeft:"var(--spacing)",paddingRight:"var(--spacing)",paddingTop:"1rem",paddingBottom:"1rem","--tw-backdrop-blur":"blur(8px)",backdropFilter:"var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)","@media (min-width: 1280px)":{top:"7.4rem"}}),D=o.Z.div({display:"grid",maxWidth:"150rem",gridTemplateColumns:"repeat(12, minmax(0, 1fr))",gap:"2.5rem"}),B=(0,o.Z)(j.SubpageWrapper)({paddingTop:"0px !important"}),U=o.Z.span({pointerEvents:"none",position:"absolute",right:"1rem",top:"1rem",touchAction:"none",fontSize:"1.6rem",color:"rgb(163 163 163 / 0.9)",transitionDuration:"100ms",transitionTimingFunction:"cubic-bezier(0.4, 0, 0.2, 1)","@media (min-width: 1024px)":{".group:has(input[type=number]):hover &":{opacity:"0"},".group:has(input[type=number]:focus) &":{opacity:"0"}}}),W=(0,o.Z)(u.e5)({display:"flex",alignItems:"center",gap:"1.5rem"}),L=(0,o.Z)(u.n5)({marginTop:"0px !important",alignItems:"flex-end"}),O=o.Z.h2({marginTop:"4rem"}),M=o.Z.div({display:"flex",justifyContent:"space-between"}),P=(0,o.Z)(u.n5)({gridTemplateColumns:"repeat(24, minmax(0, 1fr))"}),q=o.Z.div({gridColumn:"span 24/span 24","@media (min-width: 640px)":{gridColumn:"span 7 / span 7"},"@media (min-width: 1280px)":{gridColumn:"span 3 / span 3"}}),A=o.Z.div({gridColumn:"span 24/span 24","@media (min-width: 640px)":{gridColumn:"span 10 / span 10"},"@media (min-width: 1280px)":{gridColumn:"span 5 / span 5"}}),Y=(0,o.Z)(q)({"@media (min-width: 1280px)":{gridColumnStart:"14"}})}}]);