@@ -15,6 +15,7 @@ import DialogActions from '@mui/material/DialogActions';
1515import DialogContent from '@mui/material/DialogContent' ;
1616import { getCssVariables } from 'utils/theme.utils'
1717import { Button as MuiButton , StyledEngineProvider } from '@mui/material'
18+ import TextProblemModal from './textProblemModal'
1819/*import Dropdown, { Option } from 'components/shared/inputs/dropdown';*/
1920//import Select from 'react-select/src/Select'
2021
@@ -218,32 +219,31 @@ setFiles;
218219 }
219220 }*/
220221
221- const [ addProblemModal , setAddProblemModal ] = useState ( false )
222- const [ addProblemForm , setAddProblemForm ] = useState ( {
223- assignmentId : currentAssignmentId ,
224- problemName : '' ,
225- maxScore : 0 ,
226- } )
227- const openAddProblemModal = ( ) => { setAddProblemModal ( true ) }
228- const handleCloseAddProblemModal = ( ) => { setAddProblemModal ( false ) }
229-
230- const handleAddProblemChange = ( value : String , e : React . ChangeEvent < HTMLInputElement > ) => {
231- const key = e . target . id
232- setAddProblemForm ( prevState => ( { ...prevState , [ key ] : value } ) )
233- }
234- const handleAddProblem = ( ) => {
235- RequestService . post ( `/api/course/${ courseId } /assignment/${ currentAssignmentId } /assignment-problems` , addProblemForm )
236- . then ( ( ) => {
237- setAlert ( { autoDelete : true , type : 'success' , message : 'Problem Added' } )
238- setAddProblemModal ( false )
239- setAddProblemForm ( {
240- assignmentId : currentAssignmentId ,
241- problemName : '' ,
242- maxScore : 0 ,
243- } )
244- fetchAssignmentProblems ( )
245- } )
246- }
222+ const [ textModal , setTextModal ] = useState ( false )
223+ // const [addProblemForm, setAddProblemForm] = useState({
224+ // assignmentId: currentAssignmentId,
225+ // problemName: '',
226+ // maxScore: 0,
227+ // })
228+ const handleCloseTextModal = ( ) => { setTextModal ( false ) }
229+
230+ // const handleAddProblemChange = (value: String, e: React.ChangeEvent<HTMLInputElement>) => {
231+ // const key = e.target.id
232+ // setAddProblemForm(prevState => ({ ...prevState, [key]: value }))
233+ // }
234+ // const handleAddProblem = () => {
235+ // RequestService.post(`/api/course/${courseId}/assignment/${currentAssignmentId}/assignment-problems`, addProblemForm)
236+ // .then(() => {
237+ // setAlert({ autoDelete: true, type: 'success', message: 'Problem Added' })
238+ // setAddProblemModal(false)
239+ // setAddProblemForm({
240+ // assignmentId: currentAssignmentId,
241+ // problemName: '',
242+ // maxScore: 0,
243+ // })
244+ // fetchAssignmentProblems()
245+ // })
246+ // }
247247
248248 const handleDeleteProblem = ( problemId : number ) => {
249249 RequestService . delete ( `/api/course/${ courseId } /assignment/${ currentAssignmentId } /assignment-problems/${ problemId } ` )
@@ -269,17 +269,8 @@ setFiles;
269269 </ DialogContent >
270270 </ Dialog >
271271
272- < Dialog open = { addProblemModal } onClose = { handleCloseAddProblemModal } >
273- < DialogContent sx = { { bgcolor :theme . listItemBackground } } >
274- < h3 className = { styles . header } > Add Problem</ h3 >
275- < TextField id = "problemName" label = { 'Problem Name' } onChange = { handleAddProblemChange } />
276- < TextField id = "maxScore" label = { 'Max Score' } onChange = { handleAddProblemChange } />
277- < DialogActions >
278- < Button onClick = { handleAddProblem } > Add</ Button >
279- < Button onClick = { handleCloseAddProblemModal } > Close</ Button >
280- </ DialogActions >
281- </ DialogContent >
282- </ Dialog >
272+ < TextProblemModal open = { textModal } onClose = { handleCloseTextModal } />
273+
283274 < div className = { styles . pageHeader } >
284275 < h1 style = { { gridColumnStart :2 } } > Edit Assignment</ h1 >
285276 < Button className = { `btnPrimary ${ styles . backToCourse } ` } onClick = { ( ) => { history . goBack ( ) } } > back to course</ Button >
@@ -381,7 +372,7 @@ setFiles;
381372 < h2 className = { styles . header } > Add Problems</ h2 >
382373 < div className = { styles . buttonContainer } >
383374 < Button onClick = { ( ) => setAlert ( { autoDelete : true , type : 'error' , message : 'Setup Code/File Input creation modal' } ) } className = 'btnSecondary' > Code/File Input</ Button >
384- < Button onClick = { openAddProblemModal } className = 'btnSecondary' > Text Input</ Button >
375+ < Button onClick = { ( ) => { setTextModal ( true ) } } className = 'btnSecondary' > Text Input</ Button >
385376 < Button onClick = { ( ) => setAlert ( { autoDelete : true , type : 'error' , message : 'Setup Multiple Choice creation modal' } ) } className = 'btnSecondary' > Multiple Choice</ Button >
386377 </ div >
387378 < h2 className = { styles . header } > Add Graders</ h2 >
0 commit comments