@@ -24,31 +24,9 @@ function parseStoredString(responseString: string): string | any[] | object {
24
24
export function Evaluate ( ) {
25
25
const [ response , updateResponse ] = useState < string > ( "" ) ;
26
26
const [ args , updateArgs , resetArgs ] = useArgs ( ) ;
27
-
28
27
async function evaluate ( url : string , params : JSON ) {
29
- // Check if sessionStorage items exist before parsing
30
- const wizardInput = sessionStorage . getItem ( "wizard.input" ) ;
31
- const studentInput = sessionStorage . getItem ( "student.input" ) ;
32
-
33
- // Safely parse the wizard input if it exists, otherwise use a fallback value
34
- let answer : { defaultAnswer : string } = { defaultAnswer : '' } ; // Default value for answer
35
-
36
- try {
37
- const wizardInput = sessionStorage . getItem ( "wizard.input" ) ;
38
-
39
- // Safely parse the wizard input if it exists, otherwise use a fallback value
40
- if ( wizardInput ) {
41
- const parsedWizardInput = JSON . parse ( wizardInput ) ;
42
-
43
- // Ensure that parsedWizardInput.answer is a string or use fallback
44
- answer = parsedWizardInput ?. answer ?
45
- { defaultAnswer : String ( parsedWizardInput . answer ) } :
46
- { defaultAnswer : '' } ; // Fallback value if wizard.input is malformed
47
- }
48
- } catch ( error ) { }
49
-
50
- // Safely parse the student input if it exists, otherwise use a fallback value
51
- const response = studentInput ? parseStoredString ( studentInput ) : { defaultResponse : '' } ; // Fallback value if student.input is null
28
+ const answer = parseStoredString ( JSON . stringify ( JSON . parse ( localStorage . getItem ( "wizard.input" ) ) . answer ) ) ;
29
+ const response = parseStoredString ( localStorage . getItem ( "student.input" ) ) ;
52
30
53
31
console . log ( "remote eval" ) ;
54
32
console . log ( "url" , url ) ;
@@ -66,18 +44,14 @@ export function Evaluate() {
66
44
const res = await axios . post ( "http://localhost:3070" , request ) ;
67
45
console . log ( res ) ;
68
46
updateResponse ( JSON . stringify ( res . data ) ) ;
69
-
70
- const feedback = {
71
- isCorrect : res . data . result . is_correct ,
72
- isError : res . data . result . is_error ?? false ,
73
- feedback :
74
- res . data . result . feedback ??
75
- ( res . data . result . is_correct ? "Correct" : "Incorrect" ) ,
76
- color : res . data . result . is_correct ? "green" : "red" ,
77
- } ;
78
- updateArgs ( { feedback : feedback } ) ;
47
+ const feedback = { isCorrect : res . data . result . is_correct ,
48
+ isError : res . data . result . is_error ?? false ,
49
+ feedback : res . data . result . feedback
50
+ ?? ( res . data . result . is_correct ? "Correct" : "Incorrect" ) ,
51
+ color : res . data . result . is_correct ? 'green' :'red' } ;
52
+ updateArgs ( { feedback : feedback } ) ;
53
+ // {homes.map(home => <div>{home.name}</div>) }
79
54
}
80
-
81
55
return (
82
56
< div style = { evaluateStyles . mainDiv } >
83
57
< div style = { { width : "100%" , display : "table" } } >
0 commit comments