Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 44 create quiz frontend #80

Open
wants to merge 35 commits into
base: main
Choose a base branch
from

Conversation

morepresent
Copy link
Contributor

@morepresent morepresent commented Jan 22, 2025

Change Summary

[Briefly summarise the changes that you made. Just high-level stuff]

Change Form

Fill this up (NA if not available). If a certain criteria is not met, can you please give a reason.

  • The pull request title has an issue number
  • The change works by "Smoke testing" or quick testing
  • The change has tests
  • The change has documentation

Other Information

[Is there anything in particular in the review that I should be aware of?]

Related issue

@AarifLamat AarifLamat requested a review from loklokyx January 24, 2025 04:14
@yunho7687
Copy link
Member

hi, could you please add some screenshots about what you have done for the frontend? thank you

@morepresent
Copy link
Contributor Author

hi, could you please add some screenshots about what you have done for the frontend? thank you

Screenshot 2025-01-25 at 10 33 41 AM
Screenshot 2025-01-25 at 10 33 54 AM

@AarifLamat AarifLamat requested a review from yunho7687 January 27, 2025 05:12
Copy link
Contributor

@loklokyx loklokyx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ve added some cleanup suggestions.

client/src/components/ui/Competition/competition.tsx Outdated Show resolved Hide resolved
client/src/pages/quiz/index.tsx Outdated Show resolved Hide resolved
client/src/pages/quiz/index.tsx Outdated Show resolved Hide resolved
Comment on lines 13 to 47
const {
data: quizData,
isLoading: isQuizDataLoading,
isError: isQuizDataError,
error: QuizDataError,
} = useFetchData<Quiz[]>({
queryKey: ["quiz.list"],
endpoint: "/quiz/list",
});

// console.log("Quiz Data: ", quizData);
// console.log("2024 Quiz Data: ", quizData ? quizData[0] : "No data available");

/**
* Handles page change logic.
* @param {number} page - The new page number.
*/

const [displayQuiz, setDisplayQuiz] = useState(false);
const [isSubmitted, setIsSubmitted] = useState(false);
const [currentPage, setCurrentPage] = useState(1);

let quizTitle = "Math Competition";
let quizStartTime = "2021-09-01T00:00:00.000Z";
let quizDuration = 100;
let numberOfQuestions = 16;

const id = 0;

if (quizData) {
quizTitle = quizData[id]?.name;
quizStartTime = quizData[id]?.startTime.toString();
quizDuration = quizData[id]?.duration;
numberOfQuestions = quizData[id]?.questions?.length;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this part should retrieve the quiz data by ID rather than fetching the entire list. Please correct me if I’m mistaken.

Comment on lines +75 to +85
const handleSubmit = () => {
setIsSubmitted(true); // Show the popup
};

const closePopup = () => {
setIsSubmitted(false); // Hide the popup
};

const tryAgain = () => {
console.log("Try again");
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These functions are defined but not currently used. Consider removing them if they’re unnecessary or implementing them if needed.

Comment on lines +86 to +88
const [answer, setAnswer] = useState(
() => localStorage.getItem("answer") || "",
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, only one answer is saved for all questions, causing all answers to change when one is updated. Consider adding an unique identifier to update the answer for only the specific question.

client/src/components/ui/generic-quiz.tsx Outdated Show resolved Hide resolved
Comment on lines +19 to +20
let generalInstructions =
'<span class="font-bold">General instructions:</span> There are 16 questions. Each question has an answer that is a positive integer less than 1000. Calculators are <span class="font-bold">not</span> permitted. Diagrams are provided to clarify wording only, and should <span class="font-bold">not</span> be expected to be to scale.';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider removing the unused variable.

client/src/components/ui/quiz-start-page.tsx Show resolved Hide resolved
client/src/types/quiz.ts Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create Quiz Frontend
4 participants