Skip to content

Commit e288414

Browse files
committed
Testing: Restored Evaluate.tsx
1 parent b8e3cb1 commit e288414

File tree

2 files changed

+10
-36
lines changed

2 files changed

+10
-36
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@lambda-feedback-segp-sandbox/sandbox-addon",
3-
"version": "0.6.12",
3+
"version": "0.6.13",
44
"description": "lambda feedback sandbox addon",
55
"keywords": [
66
"storybook-addons",

src/components/Evaluate.tsx

Lines changed: 9 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -24,31 +24,9 @@ function parseStoredString(responseString: string): string | any[] | object {
2424
export function Evaluate() {
2525
const [response, updateResponse] = useState<string>("");
2626
const [args, updateArgs, resetArgs] = useArgs();
27-
2827
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"));
5230

5331
console.log("remote eval");
5432
console.log("url", url);
@@ -66,18 +44,14 @@ export function Evaluate() {
6644
const res = await axios.post("http://localhost:3070", request);
6745
console.log(res);
6846
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>)}
7954
}
80-
8155
return (
8256
<div style={evaluateStyles.mainDiv}>
8357
<div style={{ width: "100%", display: "table" }}>

0 commit comments

Comments
 (0)