Made it so the code remembers the user's previous answers to current exercises
This commit is contained in:
@@ -9,8 +9,8 @@ import {Fragment, useEffect, useState} from "react";
|
||||
import {toast} from "react-toastify";
|
||||
import Button from "../Low/Button";
|
||||
|
||||
export default function Writing({id, prompt, info, type, wordCounter, attachment, onNext, onBack}: WritingExercise & CommonProps) {
|
||||
const [inputText, setInputText] = useState("");
|
||||
export default function Writing({id, prompt, info, type, wordCounter, attachment, userSolutions, onNext, onBack}: WritingExercise & CommonProps) {
|
||||
const [inputText, setInputText] = useState(userSolutions.length === 1 ? userSolutions[0].solution : "");
|
||||
const [isSubmitEnabled, setIsSubmitEnabled] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -55,7 +55,11 @@ export default function Writing({id, prompt, info, type, wordCounter, attachment
|
||||
</div>
|
||||
|
||||
<div className="self-end flex justify-between w-full gap-8">
|
||||
<Button color="green" variant="outline" onClick={onBack} className="max-w-[200px] self-end w-full">
|
||||
<Button
|
||||
color="green"
|
||||
variant="outline"
|
||||
onClick={() => onBack({exercise: id, solutions: [inputText], score: {correct: 1, total: 1}, type})}
|
||||
className="max-w-[200px] self-end w-full">
|
||||
Back
|
||||
</Button>
|
||||
<Button
|
||||
|
||||
Reference in New Issue
Block a user