PageSourceSearch

https://www.codechef.com/build/react2/assets/CreateProblemPage-CVwuXR8Q.js

js codechef.com collected 2026-10-01 10:24:45 UTC 3,526 bytes, 1 lines download raw bytes

1import{r as o,Z as e,a3 as t}from"./vendor-mui-BWh-6WAH.js";import{A as x}from"./index.es-CLmToPHp.js";import{U as T,r as w,A as p,d as E,e as k,T as D,v as q,M as y,o as I,a as j,w as L}from"./index-Df_dD346.js";import{S as C}from"./InputFields-CYxZ5HcB.js";import{S as m}from"./Select-BWSf6Xh4.js";import{c as O,p as U,a as Z}from"./ProblemManageOptions-B9yIygg6.js";import{H}from"./HYCContainer-Bv84U2sK.js";import"./__commonjsHelpers__-BosuxZz1.js";import"./vendor-sweetalert2-CokzRhbv.js";import"./CheckBox-BcghMeM6.js";import"./TwoColumnLayout-Bc7zzK-7.js";import"./TopBanner-Db2bz9jS.js";import"./vendor-react-csv-DOigUwdE.js";import"./BreadCrumbs-BK-2gjVo.js";import"./TopBanner.module--qQpYJq9.js";import"./TwoColumnBox-HLeEW0cA.js";const K="_form_v140y_1",M="_formGroup_v140y_7",B="_inputGroup_v140y_17",$="_description_v140y_23",z="_error_v140y_23",r={form:K,formGroup:M,inputGroup:B,description:$,error:z},F=()=>[{link:"/",name:"Home"},{link:"/problems/dashboard",name:"My Problems"},{link:null,name:"Create Problem"}],Y=l=>l&&p.get(`api/validate/problem-code/${l}`),J=x(Y,500);function ue(){const l=o.useContext(T),{dispatch:n}=l,[c,f]=o.useState(""),[d,P]=o.useState(""),[u,v]=o.useState("0"),[h,_]=o.useState("0"),[b,N]=o.useState("3"),[i,g]=o.useState(null),S=w(),G=async a=>{a=a.toUpperCase(),f(a);try{await J(a),g(null)}catch(s){g(s.response.data.message)}};o.useEffect(()=>{const a=L(403,"It seems like you don't have access to create a problem. For any help, please reach out to [email protected].");(async()=>{try{await p.get("api/user-has-permission/problem_creation"),await n(E("Create Problem"))}catch{await n(k(a))}finally{await n(D(!1))}})()},[]);const A=async a=>{a.preventDefault(),await n(y(!0,"ajax"));try{const s=await p.post("api/problem/add",{problemCode:c,problemName:d,category:u,problemScenario:h,assessmentType:b});I(s,()=>{S(`/manage/problems/${c}`)})}catch(s){j(s)}finally{await n(y(!1,""))}};return e(H,{breadCrumbData:F(),rightColumnData:t("form",{className:r.form,onSubmit:A,children:[t("div",{className:r.formGroup,children:[e("label",{className:r.inputGroup,children:"Problem Code"}),e(C,{props:{maxLength:12,pattern:"[A-Z][A-Z0-9_]{1,11}",style:{borderColor:i?"red":""}},type:"text",handleChange:G,value:c,required:!0}),i?e("div",{className:r.error,children:i}):"",e("div",{className:r.description,children:"The code should be 2-12 characters long, consisting of only uppercase letters, digits or an underscore, and should start with a letter. This cannot be changed once created."})]}),t("div",{className:r.formGroup,children:[e("label",{className:r.inputGroup,children:"Problem Name"}),e(C,{type:"text",props:{maxLength:50,minLength:2,pattern:"[a-zA-Z0-9_,!()#;&\\s-]+"},handleChange:P,value:d,required:!0}),t("div",{className:r.description,children:["The problem name should be 2-50 characters long. Allowed special characters are ["," ",e("b",{children:"_ , ! ( ) # ; & -"})," ","]"]})]}),t("div",{className:r.formGroup,children:[e("label",{className:r.inputGroup,children:" Problem Category "}),e(m,{options:O.slice(0,-1),handleChange:v,selectedKey:u,required:!0})]}),t("div",{className:r.formGroup,children:[e("label",{className:r.inputGroup,children:" Problem Type "}),e(m,{options:U,handleChange:_,selectedKey:h,required:!0})]}),t("div",{className:r.formGroup,children:[e("label",{className:r.inputGroup,children:" Assessment Type "}),e(m,{options:Z,handleChange:N,selectedKey:b,required:!0})]}),e(q,{title:"Create Problem",type:"primary"})]})})}export{ue as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.