Added ability to remember where you started lesson (ie. course or review)
This commit is contained in:
@@ -2,12 +2,13 @@ import { useLocation, useNavigate } from 'react-router-dom';
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import WrittenQuestionExercise from "../components/WrittenQuestionExercise"
|
import WrittenQuestionExercise from "../components/WrittenQuestionExercise"
|
||||||
import WrittenVocabularyExercise from "../components/WrittenVocabularyExercise"
|
import WrittenVocabularyExercise from "../components/WrittenVocabularyExercise"
|
||||||
|
import VerbalQuestionsExercise from "../components/VerbalQuestionsExercise"
|
||||||
import Progress from '../components/Progress';
|
import Progress from '../components/Progress';
|
||||||
|
|
||||||
export default function Course() {
|
export default function Lesson() {
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { questions } = location.state;
|
const { questions, home } = location.state;
|
||||||
const [currQuestion, setCurrQuestion] = useState<number>(0);
|
const [currQuestion, setCurrQuestion] = useState<number>(0);
|
||||||
|
|
||||||
const handleNavigateBack = () => {
|
const handleNavigateBack = () => {
|
||||||
@@ -18,11 +19,11 @@ export default function Course() {
|
|||||||
if (currQuestion < questions.length - 1) {
|
if (currQuestion < questions.length - 1) {
|
||||||
setCurrQuestion(currQuestion + 1);
|
setCurrQuestion(currQuestion + 1);
|
||||||
} else {
|
} else {
|
||||||
navigate("/review");
|
navigate(home);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const renderQuestion = (questionIndex: number) => {
|
const renderQuestion = (currIndex: number) => {
|
||||||
const question = questions[currQuestion];
|
const question = questions[currQuestion];
|
||||||
switch (question.type) {
|
switch (question.type) {
|
||||||
case 'written':
|
case 'written':
|
||||||
@@ -49,17 +50,25 @@ export default function Course() {
|
|||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// case 'verbal-listening':
|
case 'verbal-listening':
|
||||||
// switch (exercise) {
|
switch (question.exercise) {
|
||||||
// case 'questions':
|
case 'questions':
|
||||||
// return <VerbalQuestionsLesson />;
|
return <VerbalQuestionsExercise
|
||||||
|
key={currQuestion}
|
||||||
|
question={question.question}
|
||||||
|
wordBank={question.wordBank}
|
||||||
|
expected={question.expected}
|
||||||
|
chapter={"Travel"}
|
||||||
|
language={"Japanese"}
|
||||||
|
onQuestionSubmit={handleQuestionSubmit}
|
||||||
|
/>;
|
||||||
// case 'pronunciation':
|
// case 'pronunciation':
|
||||||
// return <VerbalPronunciationLesson />;
|
// return <VerbalPronunciationLesson />;
|
||||||
// default:
|
default:
|
||||||
// return null;
|
return null;
|
||||||
// }
|
}
|
||||||
// default:
|
default:
|
||||||
// return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
import { useNavigate } from "react-router-dom"
|
import { useLocation, useNavigate } from "react-router-dom"
|
||||||
import NavBar from "../components/NavBar"
|
import NavBar from "../components/NavBar"
|
||||||
import { getLanguage, getUsername } from "../logic/sdk";
|
import { getLanguage, getUsername } from "../logic/sdk";
|
||||||
|
|
||||||
export default function Review() {
|
export default function Review() {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const location = useLocation();
|
||||||
|
|
||||||
const writtenReview = ["Questions", "Vocabulary"];
|
const writtenReview = ["Questions", "Vocabulary"];
|
||||||
const verbalReview = ["Questions", "Pronunciation"];
|
const verbalReview = ["Questions", "Pronunciation"];
|
||||||
@@ -81,7 +82,7 @@ export default function Review() {
|
|||||||
exercise: 'vocabulary',
|
exercise: 'vocabulary',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
navigate('/lesson', { state: { questions: reviewQuestions } });
|
navigate('/lesson', { state: { questions: reviewQuestions, home: location.pathname } });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user