11import React from 'react' ;
22import PropTypes from 'prop-types' ;
33import * as commonmark from 'commonmark' ;
4- import Assessment from './Assessment.js' ;
54
65import ADASEditor from './editors/ADASEditor.jsx' ;
76import CobbDouglasEditor from './editors/CobbDouglasEditor.jsx' ;
@@ -25,12 +24,9 @@ import PositiveExternalityIndustryEditor from
2524
2625import ExportGraphButton from './buttons/ExportGraphButton.jsx' ;
2726import ResetGraphButton from './buttons/ResetGraphButton.jsx' ;
28- import SubmitButton from './buttons/SubmitButton.jsx' ;
2927import JXGBoard from './JXGBoard.jsx' ;
3028import Feedback from './Feedback.jsx' ;
31- import {
32- forceFloat , getOrCreateSubmission , BOARD_WIDTH , BOARD_HEIGHT
33- } from './utils' ;
29+ import { BOARD_WIDTH , BOARD_HEIGHT } from './utils' ;
3430import RevenueElasticityEditor from './editors/RevenueElasticityEditor.jsx' ;
3531import TaxRevenueEditor from './editors/TaxRevenueEditor.jsx' ;
3632
@@ -214,7 +210,7 @@ export default class GraphViewer extends React.Component {
214210 < div className = "GraphViewer" >
215211 { titleEl }
216212 { instructionsEl }
217- < form onSubmit = { this . handleSubmit . bind ( this ) } action = { action } method = "post" >
213+ < form action = { action } method = "post" >
218214 < input type = "hidden" name = "csrfmiddlewaretoken" value = { token } />
219215 < input type = "hidden" name = "score" value = { this . state . score } />
220216 < input type = "hidden" name = "next" value = { successUrl } />
@@ -228,17 +224,13 @@ export default class GraphViewer extends React.Component {
228224
229225 { rightSide }
230226
227+ < hr />
228+
231229 < ResetGraphButton
232230 initialState = { initialState }
233231 updateGraph = { this . updateGraph } />
234232
235233 < ExportGraphButton />
236-
237- < SubmitButton
238- assessment = { this . props . assessment }
239- gNeedsSubmit = { this . props . gNeedsSubmit }
240- submission = { this . props . submission }
241- isInstructor = { isInstructor } />
242234 </ form >
243235 </ div >
244236 ) ;
@@ -301,7 +293,7 @@ export default class GraphViewer extends React.Component {
301293 < div className = "GraphViewer" >
302294 { titleEl }
303295 { instructionsEl }
304- < form onSubmit = { this . handleSubmit . bind ( this ) } action = { action } method = "post" >
296+ < form action = { action } method = "post" >
305297 < input type = "hidden" name = "csrfmiddlewaretoken" value = { token } />
306298 < input type = "hidden" name = "score" value = { this . state . score } />
307299 < input type = "hidden" name = "next" value = { successUrl } />
@@ -315,17 +307,13 @@ export default class GraphViewer extends React.Component {
315307
316308 { rightSide }
317309
310+ < hr />
311+
318312 < ResetGraphButton
319313 initialState = { initialState }
320314 updateGraph = { this . updateGraph } />
321315
322316 < ExportGraphButton />
323-
324- < SubmitButton
325- assessment = { this . props . assessment }
326- gNeedsSubmit = { this . props . gNeedsSubmit }
327- submission = { this . props . submission }
328- isInstructor = { isInstructor } />
329317 </ form >
330318 </ div >
331319 ) ;
@@ -363,7 +351,7 @@ export default class GraphViewer extends React.Component {
363351 < div className = "GraphViewer" >
364352 { titleEl }
365353 { instructionsEl }
366- < form onSubmit = { this . handleSubmit . bind ( this ) } action = { action } method = "post" >
354+ < form action = { action } method = "post" >
367355 < input type = "hidden" name = "csrfmiddlewaretoken" value = { token } />
368356 < input type = "hidden" name = "score" value = { this . state . score } />
369357 < input type = "hidden" name = "next" value = { successUrl } />
@@ -381,98 +369,19 @@ export default class GraphViewer extends React.Component {
381369 < div className = "col-lg-6" >
382370 { rightSide }
383371
372+ < hr />
373+
384374 < ResetGraphButton
385375 initialState = { initialState }
386376 updateGraph = { this . updateGraph } />
387377
388378 < ExportGraphButton />
389-
390- < SubmitButton
391- assessment = { this . props . assessment }
392- gNeedsSubmit = { this . props . gNeedsSubmit }
393- submission = { this . props . submission }
394- isInstructor = { isInstructor } />
395379 </ div >
396380 </ div >
397381 </ form >
398382 </ div >
399383 ) ;
400384 }
401- // When the submission is loaded by the Viewer, see if
402- // this.state.currentFeedback should be updated.
403- componentDidUpdate ( prevProps ) {
404- if ( prevProps . submission !== this . props . submission ) {
405- this . loadFeedback (
406- this . props . submission . feedback_unfulfilled ,
407- this . props . submission . feedback_fulfilled ) ;
408- }
409- }
410- loadFeedback ( unfulfilledFeedback , fulfilledFeedback ) {
411- const currentFeedback = [ ] ;
412-
413- unfulfilledFeedback = unfulfilledFeedback . split ( ';;' ) ;
414- fulfilledFeedback = fulfilledFeedback . split ( ';;' ) ;
415-
416- unfulfilledFeedback . forEach ( e => {
417- if ( e ) {
418- currentFeedback . push ( {
419- feedback : e ,
420- fulfilled : false
421- } ) ;
422- }
423- } ) ;
424- fulfilledFeedback . forEach ( e => {
425- if ( e ) {
426- currentFeedback . push ( {
427- feedback : e ,
428- fulfilled : true
429- } ) ;
430- }
431- } ) ;
432-
433- this . setState ( { currentFeedback : currentFeedback } ) ;
434- }
435- handleSubmit ( event ) {
436- event . preventDefault ( ) ;
437- const assessment = new Assessment ( this . props . assessment ) ;
438- const responses = assessment . evalState ( this . props ) ;
439-
440- if ( this . props . gNeedsSubmit ) {
441- // LTI Assessment graph submitted. Create a Submission
442- // object and submit to Canvas with LTI.
443- const form = event . target ;
444-
445- // Sum up the scores for all fulfilled rules.
446- const scores = responses . map ( x => forceFloat ( x . score ) ) ;
447- const score = scores . reduce ( ( a , b ) => a + b , 0 ) ;
448-
449- this . setState ( { score : score } ) ;
450-
451- // Save the user's feedback on their Submission object to
452- // make it persistent.
453- const fulfilledFeedback = responses
454- . filter ( x => x . fulfilled )
455- . map ( x => x . feedback )
456- . join ( ';;' ) ;
457- const unfulfilledFeedback = responses
458- . filter ( x => ! x . fulfilled )
459- . map ( x => x . feedback )
460- . join ( ';;' ) ;
461-
462- getOrCreateSubmission ( {
463- graph : this . props . gId ,
464- feedback_fulfilled : fulfilledFeedback ,
465- feedback_unfulfilled : unfulfilledFeedback ,
466- score : score
467- } ) . then ( function ( ) {
468- form . submit ( ) ;
469- } ) ;
470- } else {
471- // Practice Assessment submitted. Show feedback
472- // immediately.
473- this . setState ( { currentFeedback : responses } ) ;
474- }
475- }
476385 updateGraph ( state ) {
477386 this . setState ( { currentFeedback : state . currentFeedback } ) ;
478387 return this . props . updateGraph ( state ) ;
@@ -484,7 +393,6 @@ GraphViewer.propTypes = {
484393 gType : PropTypes . number ,
485394 gTitle : PropTypes . string ,
486395 gInstructions : PropTypes . string ,
487- gNeedsSubmit : PropTypes . bool ,
488396 gAssignmentType : PropTypes . number . isRequired ,
489397
490398 gShowIntersection : PropTypes . bool . isRequired ,
@@ -603,7 +511,5 @@ GraphViewer.propTypes = {
603511 gExpression2 : PropTypes . string ,
604512 gExpression3 : PropTypes . string ,
605513
606- assessment : PropTypes . array ,
607- submission : PropTypes . object ,
608514 updateGraph : PropTypes . func . isRequired
609515} ;
0 commit comments