mirror of
https://github.com/ets-cfuhrman-pfe/EvalueTonSavoir.git
synced 2025-08-11 21:23:54 -04:00
Compare commits
No commits in common. "241d0d1cf70c7f376b9ca5501753df86192172b0" and "de50b6c4f021692e4423741977772b36e1c4e1e0" have entirely different histories.
241d0d1cf7
...
de50b6c4f0
7 changed files with 18 additions and 29 deletions
|
|
@ -13,6 +13,7 @@ const MultipleChoiceQuestionDisplay: React.FC = () => {
|
|||
console.log("questions", index);
|
||||
|
||||
const answer = answers[Number(index)]?.answer;
|
||||
|
||||
const question = questions[Number(index)].question as MultipleChoiceQuestion;
|
||||
|
||||
const [actualAnswer, setActualAnswer] = useState<AnswerType>(() => {
|
||||
|
|
@ -61,7 +62,7 @@ const MultipleChoiceQuestionDisplay: React.FC = () => {
|
|||
|
||||
return (
|
||||
<QuizContext.Consumer>
|
||||
{({ showAnswer, isTeacherMode }) => (
|
||||
{({ showAnswer }) => (
|
||||
<div className="question-container">
|
||||
<div className="question content">
|
||||
<div dangerouslySetInnerHTML={{ __html: FormattedTextTemplate(question.formattedStem) }} />
|
||||
|
|
@ -75,7 +76,7 @@ const MultipleChoiceQuestionDisplay: React.FC = () => {
|
|||
<Button
|
||||
variant="text"
|
||||
className="button-wrapper"
|
||||
disabled={disableButton || isTeacherMode}
|
||||
disabled={disableButton}
|
||||
onClick={() => !showAnswer && handleOnClickAnswer(choice.formattedText.text)}
|
||||
>
|
||||
{showAnswer ? (
|
||||
|
|
@ -114,7 +115,7 @@ const MultipleChoiceQuestionDisplay: React.FC = () => {
|
|||
/>
|
||||
</div>
|
||||
)}
|
||||
{!showAnswer && submitAnswer && !isTeacherMode &&(
|
||||
{!showAnswer && submitAnswer && (
|
||||
<Button
|
||||
variant="contained"
|
||||
onClick={() =>
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ const NumericalQuestionDisplay: React.FC = () => {
|
|||
|
||||
return (
|
||||
<QuizContext.Consumer>
|
||||
{({ showAnswer, isTeacherMode }) => (
|
||||
{({ showAnswer }) => (
|
||||
<div className="question-wrapper">
|
||||
<div>
|
||||
<div dangerouslySetInnerHTML={{ __html: FormattedTextTemplate(question.formattedStem) }} />
|
||||
|
|
@ -71,7 +71,6 @@ const NumericalQuestionDisplay: React.FC = () => {
|
|||
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
setActualAnswer([e.target.valueAsNumber]);
|
||||
}}
|
||||
disabled={showAnswer || isTeacherMode}
|
||||
inputProps={{ 'data-testid': 'number-input' }}
|
||||
/>
|
||||
</div>
|
||||
|
|
@ -80,7 +79,7 @@ const NumericalQuestionDisplay: React.FC = () => {
|
|||
<div dangerouslySetInnerHTML={{ __html: FormattedTextTemplate(question.formattedGlobalFeedback) }} />
|
||||
</div>
|
||||
)}
|
||||
{submitAnswer && !isTeacherMode &&(
|
||||
{submitAnswer && (
|
||||
<Button
|
||||
variant="contained"
|
||||
onClick={() =>
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ const ShortAnswerQuestionDisplay: React.FC = () => {
|
|||
|
||||
return (
|
||||
<QuizContext.Consumer>
|
||||
{({ showAnswer, isTeacherMode }) => (
|
||||
{({ showAnswer }) => (
|
||||
<div className="question-wrapper">
|
||||
<div className="question content">
|
||||
<div dangerouslySetInnerHTML={{ __html: FormattedTextTemplate(question.formattedStem) }} />
|
||||
|
|
@ -60,11 +60,11 @@ const ShortAnswerQuestionDisplay: React.FC = () => {
|
|||
onChange={(e) => {
|
||||
setActualAnswer([e.target.value]);
|
||||
}}
|
||||
disabled={showAnswer || isTeacherMode}
|
||||
disabled={showAnswer}
|
||||
aria-label="short-answer-input"
|
||||
/>
|
||||
</div>
|
||||
{submitAnswer && !isTeacherMode && (
|
||||
{submitAnswer && (
|
||||
<Button
|
||||
variant="contained"
|
||||
onClick={() =>
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ const TrueFalseQuestionDisplay: React.FC = () => {
|
|||
|
||||
return (
|
||||
<QuizContext.Consumer>
|
||||
{({ showAnswer, isTeacherMode }) => (
|
||||
{({ showAnswer }) => (
|
||||
<div className="question-container">
|
||||
<div className="question content">
|
||||
<div
|
||||
|
|
@ -60,7 +60,7 @@ const TrueFalseQuestionDisplay: React.FC = () => {
|
|||
className="button-wrapper"
|
||||
onClick={() => !showAnswer && handleOnClickAnswer(true)}
|
||||
fullWidth
|
||||
disabled={disableButton || isTeacherMode}
|
||||
disabled={disableButton}
|
||||
>
|
||||
{showAnswer ? (
|
||||
<div> {question.isTrue ? '✅' : '❌'}</div>
|
||||
|
|
@ -86,7 +86,7 @@ const TrueFalseQuestionDisplay: React.FC = () => {
|
|||
className="button-wrapper"
|
||||
onClick={() => !showAnswer && handleOnClickAnswer(false)}
|
||||
fullWidth
|
||||
disabled={disableButton || isTeacherMode}
|
||||
disabled={disableButton}
|
||||
>
|
||||
{showAnswer ? (
|
||||
<div> {!question.isTrue ? '✅' : '❌'}</div>
|
||||
|
|
@ -120,7 +120,7 @@ const TrueFalseQuestionDisplay: React.FC = () => {
|
|||
/>
|
||||
</div>
|
||||
)}
|
||||
{!showAnswer && submitAnswer && !isTeacherMode && (
|
||||
{!showAnswer && submitAnswer && (
|
||||
<Button
|
||||
variant="contained"
|
||||
onClick={() =>
|
||||
|
|
|
|||
|
|
@ -16,8 +16,6 @@ export const QuizContext = React.createContext<{
|
|||
updateIndex: (questionId: number | null) => void; // Add a function to update the index
|
||||
submitAnswer: (answer: AnswerType, idQuestion?: number) => void; // Updated submitAnswer signature
|
||||
isQuestionSent: boolean;
|
||||
isTeacherMode: boolean; // Flag to indicate if the user is in teacher mode
|
||||
setisTeacherMode: Dispatch<SetStateAction<boolean>>; // Setter for isTeacherMode
|
||||
setIsQuestionSent: Dispatch<SetStateAction<boolean>>;
|
||||
roomName: string;
|
||||
setRoomName: Dispatch<SetStateAction<string>>;
|
||||
|
|
@ -38,8 +36,6 @@ export const QuizContext = React.createContext<{
|
|||
index: null, // Default value for index
|
||||
updateIndex: () => {}, // Default no-op function
|
||||
submitAnswer: () => {}, // Default no-op function
|
||||
isTeacherMode: false,
|
||||
setisTeacherMode: () => {}, // Default no-op function
|
||||
isQuestionSent: false,
|
||||
setIsQuestionSent: () => {},
|
||||
username: '', // Default value for username
|
||||
|
|
|
|||
|
|
@ -25,9 +25,6 @@ export const QuizProvider: React.FC<{ children: React.ReactNode }> = ({ children
|
|||
|
||||
const [isQuestionSent, setIsQuestionSent] = useState(false);
|
||||
|
||||
const [isTeacherMode, setisTeacherMode] = useState(false);
|
||||
|
||||
|
||||
const [username, setUsername] = useState<string>(ApiService.getUsername());
|
||||
|
||||
const [roomName, setRoomName] = useState<string>(''); // Add roomName state
|
||||
|
|
@ -81,8 +78,6 @@ export const QuizProvider: React.FC<{ children: React.ReactNode }> = ({ children
|
|||
submitAnswer, // Expose submitAnswer in the context
|
||||
isQuestionSent,
|
||||
setIsQuestionSent,
|
||||
isTeacherMode,
|
||||
setisTeacherMode,
|
||||
username,
|
||||
setUsername,
|
||||
roomName,
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ const ManageRoom: React.FC = () => {
|
|||
setQuestions,
|
||||
index,
|
||||
updateIndex,
|
||||
setisTeacherMode,
|
||||
} = useQuizContext();
|
||||
|
||||
|
||||
|
|
@ -55,6 +54,7 @@ const ManageRoom: React.FC = () => {
|
|||
console.log(`!quizStarted: returning.... `);
|
||||
return;
|
||||
}
|
||||
|
||||
if (quizMode === 'teacher') {
|
||||
webSocketService.nextQuestion({
|
||||
roomName: formattedRoomName,
|
||||
|
|
@ -253,7 +253,7 @@ const ManageRoom: React.FC = () => {
|
|||
}, [socket, index, questions]);
|
||||
|
||||
const nextQuestion = () => {
|
||||
if (!questions || index == null || !quiz?.content) return;
|
||||
if (!questions || !index || !quiz?.content) return;
|
||||
|
||||
const nextQuestionIndex = index +1;
|
||||
|
||||
|
|
@ -301,7 +301,6 @@ const ManageRoom: React.FC = () => {
|
|||
}
|
||||
|
||||
updateIndex(0);
|
||||
setisTeacherMode(true);
|
||||
webSocketService.nextQuestion({roomName: formattedRoomName, questions: questions, questionIndex: 0, isLaunch: true});
|
||||
};
|
||||
|
||||
|
|
@ -313,7 +312,6 @@ const ManageRoom: React.FC = () => {
|
|||
console.log('Error launching quiz (launchStudentMode). No questions found.');
|
||||
return;
|
||||
}
|
||||
setisTeacherMode(false);
|
||||
setQuestions(questions);
|
||||
webSocketService.launchStudentModeQuiz(formattedRoomName, questions);
|
||||
};
|
||||
|
|
@ -410,7 +408,7 @@ const ManageRoom: React.FC = () => {
|
|||
{questions.length > 0 ? (
|
||||
<div style={{ display: 'flex', flexDirection: 'column' }}>
|
||||
<div className="title center-h-align mb-2">{quiz?.title}</div>
|
||||
{index !== null && (
|
||||
{index && (
|
||||
<strong className="number of questions">
|
||||
Question {index +1}/
|
||||
{questions?.length}
|
||||
|
|
@ -430,7 +428,7 @@ const ManageRoom: React.FC = () => {
|
|||
|
||||
<div className="mb-2 flex-column-wrapper">
|
||||
<div className="preview-and-result-container">
|
||||
{index !== null && (
|
||||
{index && (
|
||||
<QuestionDisplay/>
|
||||
)}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue