@@ -52,6 +52,7 @@ const Editor = (props) => {
5252 const sendToFileApi = async ( ) => {
5353 console . log ( "Not finished yet" ) ;
5454 toast . info ( "This is incomplete" ) ;
55+ await uploadChallenge ( '' ) ;
5556 return ;
5657 const isValid = await validateNewChallege ( ) ;
5758 if ( isValid ) {
@@ -97,41 +98,38 @@ const Editor = (props) => {
9798 fileId : fileId ,
9899 } ;
99100
100- const body = {
101- id : props . id ,
102- challengeInfo,
103- assignmentInfo : props . assignmentInfo . assignmentInfo ,
104- username : localStorage . getItem ( 'username' ) ,
105- } ;
101+ console . log ( challengeInfo ) ;
106102
107- const url = `${ process . env . NEXT_PUBLIC_API_URL } /classroom-assignments/create-fork-assignment/${ classCode } ` ;
108- const data = await request ( url , 'POST' , body ) ;
103+ /*
104+ const url = `${process.env.NEXT_PUBLIC_API_URL}/challenges/update-assignment-challenge`;
105+ const data = await request(url, 'PUT', challengeInfo);
109106
110107 if (data && data.success) {
111108 window.location.href = ``;
112109 }
110+ */
113111 } ;
114112
115- function loadProps ( ) {
116- setClassCode ( props . classCode ) ;
117- setHints ( props . challenge . hints ) ;
118- setContentPreview ( props . challenge . content ) ;
119- setSolution ( props . challenge . solution ) ;
120- setDifficulty ( props . challenge . difficulty ) ;
121- setCategory ( props . challenge . category ) ;
122- setExistingConfig ( props . challenge . commands ) ;
123- setNewChallengeName ( props . challenge . title ) ;
124- setAssignmentName ( props . assignmentName ) ;
125- let hintPoints = [ ] ;
126- let hintMessage = [ ] ;
127- let h = props . challenge . hints ;
128- for ( let i = 0 ; i < h . length ; i ++ ) {
129- hintMessage . push ( h [ i ] . message ) ;
130- hintPoints . push ( h [ i ] . penalty ) ;
113+ function loadProps ( ) {
114+ setClassCode ( props . classCode ) ;
115+ setHints ( props . challenge . hints ) ;
116+ setContentPreview ( props . challenge . content ) ;
117+ setSolution ( props . challenge . solution ) ;
118+ setDifficulty ( props . challenge . difficulty ) ;
119+ setCategory ( props . challenge . category ) ;
120+ setExistingConfig ( props . challenge . commands ) ;
121+ setNewChallengeName ( props . challenge . title ) ;
122+ setAssignmentName ( props . assignmentName ) ;
123+ let hintPoints = [ ] ;
124+ let hintMessage = [ ] ;
125+ let h = props . challenge . hints ;
126+ for ( let i = 0 ; i < h . length ; i ++ ) {
127+ hintMessage . push ( h [ i ] . message ) ;
128+ hintPoints . push ( h [ i ] . penalty ) ;
129+ }
130+ setPenalty ( hintPoints ) ;
131+ setHints ( hintMessage ) ;
131132 }
132- setPenalty ( hintPoints ) ;
133- setHints ( hintMessage ) ;
134- }
135133
136134
137135 useEffect ( ( ) => {
@@ -467,7 +465,7 @@ function loadProps() {
467465 disabled = { isCreating }
468466 className = "mr-2 mt-6 rounded-lg border-green-600 bg-green-900 px-4 py-2 text-2xl text-white shadow-lg hover:bg-green-800"
469467 >
470- < i class = "fas fa-send" > </ i > { isCreating ? "Creating ..." : "Create Challenge" }
468+ < i class = "fas fa-send" > </ i > { isCreating ? "Updating ..." : "Update Challenge" }
471469 </ button >
472470
473471 < button className = "mr-2 mt-6 hidden rounded-sm border-blue-600 bg-blue-700 px-4 py-2 text-2xl text-white shadow-lg hover:bg-blue-800" >
0 commit comments