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

sync fork #46

Merged
merged 46 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
4c864c1
Bump micromatch and lint-staged
dependabot[bot] Sep 16, 2024
aa6dc08
Merge pull request #120 from eduardconstantin/dependabot/npm_and_yarn…
eduardconstantin Sep 16, 2024
0dea06b
Bump express from 4.19.2 to 4.21.0
dependabot[bot] Sep 16, 2024
1ba5705
Merge pull request #121 from eduardconstantin/dependabot/npm_and_yarn…
eduardconstantin Sep 16, 2024
418df5d
Bump next from 14.1.1 to 14.2.13
dependabot[bot] Sep 23, 2024
6d007d1
Merge pull request #122 from eduardconstantin/dependabot/npm_and_yarn…
eduardconstantin Sep 23, 2024
5097808
Fix option selection
eduardconstantin Sep 23, 2024
5d9daa3
Merge pull request #123 from eduardconstantin/fix/option-selection
eduardconstantin Sep 23, 2024
c34f187
fix/invalid exam score
chaitanya-bhargava Oct 7, 2024
dbd10d7
Merge pull request #126 from chaitanya-bhargava/fix/invalid-exam-score
eduardconstantin Oct 7, 2024
dbc8bd0
selection icon changed
Dhruvnotfound Oct 7, 2024
ecdb561
solved Change input selection icon #127 , and removed the x icon fr…
maxwithbug Oct 7, 2024
79f020a
icon svg changed
Dhruvnotfound Oct 8, 2024
0e52ac0
Merge pull request #128 from Dhruvnotfound/feat/Selection-input-icon-…
eduardconstantin Oct 8, 2024
a4e423c
solved Checkbox selection not visible #130
maxwithbug Oct 9, 2024
d2956b7
Merge branch 'dev' into feat/pullreqbranch
maxwithbug Oct 9, 2024
84bff50
Merge branch 'dev' into feat/pullreqbranch
eduardconstantin Oct 9, 2024
d3f6739
Update components/SelectionInput.tsx
eduardconstantin Oct 9, 2024
714a921
Update components/SelectionInput.tsx
maxwithbug Oct 9, 2024
e3e1864
Update QuizExamForm.tsx
eduardconstantin Oct 9, 2024
6815423
Merge pull request #131 from maxwithbug/feat/pullreqbranch
eduardconstantin Oct 9, 2024
be59c3b
add types to useResults
Oct 16, 2024
2e703b7
Merge pull request #135 from sushant0709/feat/types
eduardconstantin Oct 16, 2024
11c912b
Bump cookie and express
dependabot[bot] Oct 18, 2024
0fc230f
Merge branch 'dev' into dependabot/npm_and_yarn/multi-9f37c16f8f
eduardconstantin Oct 18, 2024
8a3db16
Merge pull request #136 from eduardconstantin/dependabot/npm_and_yarn…
eduardconstantin Oct 18, 2024
9add503
Update package-lock
eduardconstantin Oct 27, 2024
bad135d
Fix multiple answers selection
eduardconstantin Oct 28, 2024
4ea070d
Move type
eduardconstantin Oct 28, 2024
4ca5b18
Merge pull request #138 from eduardconstantin/fix/multiple-option-sel…
eduardconstantin Oct 28, 2024
8db5dd2
Fix imports
eduardconstantin Nov 2, 2024
17109ce
Fix hook
eduardconstantin Nov 3, 2024
ca3797b
Create new form for use form
eduardconstantin Nov 3, 2024
6d0bd8b
Fix form
eduardconstantin Nov 3, 2024
87d9b4a
Fix types
eduardconstantin Nov 3, 2024
63d608a
Fix input type error
eduardconstantin Nov 4, 2024
2de91a6
Replace form
eduardconstantin Nov 4, 2024
e2c46b3
Fix types
eduardconstantin Nov 4, 2024
4beaf56
Refactor function
eduardconstantin Nov 4, 2024
ca85ddf
Merge pull request #139 from eduardconstantin/feat/replace-formik
eduardconstantin Nov 4, 2024
1c140ab
Fix type error
eduardconstantin Nov 5, 2024
bce052e
Remove unused type
eduardconstantin Nov 5, 2024
5c0beeb
Merge pull request #140 from eduardconstantin/fix/build-error
eduardconstantin Nov 5, 2024
a2b6020
Fix error
eduardconstantin Nov 5, 2024
ffce5e3
Bump cross-spawn from 7.0.3 to 7.0.6
dependabot[bot] Nov 26, 2024
47fb4be
Merge pull request #141 from eduardconstantin/dependabot/npm_and_yarn…
eduardconstantin Nov 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/exam/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { NextPage } from "next";
import { gql, useQuery } from "@apollo/client";
import useTimer from "@azure-fundamentals/hooks/useTimer";
import { Button } from "@azure-fundamentals/components/Button";
import QuizExamForm from "@azure-fundamentals/components/QuizExamForm";
import QuizExamForm from "@azure-fundamentals/components/QuizExamFormUF";
import { Question } from "@azure-fundamentals/components/types";
import ExamResult from "@azure-fundamentals/components/ExamResult";

Expand Down Expand Up @@ -128,7 +128,7 @@ const Exam: NextPage<{ searchParams: { url: string; name: string } }> = ({
totalQuestions={data.randomQuestions?.length}
currentQuestionIndex={currentQuestionIndex}
question={currentQuestion?.question ?? ""}
options={currentQuestion?.options}
options={currentQuestion?.options ?? []}
images={currentQuestion?.images}
stopTimer={stopTimer}
revealExam={revealExam}
Expand Down
37 changes: 18 additions & 19 deletions components/QuizExamForm.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { useEffect, useState } from "react";
import { useEffect, useState, type FC } from "react";
import Image from "next/image";
import { Question } from "./types";
import { FieldArray, FormikProvider, Field, useFormik } from "formik";
import { useForm } from "react-hook-form";
import { Button } from "./Button";
import useResults from "@azure-fundamentals/hooks/useResults";

Expand All @@ -24,7 +25,7 @@ type Props = {
images?: { url: string; alt: string }[];
};

const QuizExamForm: React.FC<Props> = ({
const QuizExamForm: FC<Props> = ({
isLoading,
handleNextQuestion,
handleSkipQuestion,
Expand All @@ -44,7 +45,7 @@ const QuizExamForm: React.FC<Props> = ({
}) => {
const [showCorrectAnswer, setShowCorrectAnswer] = useState<boolean>(false);
const [savedAnswers, setSavedAnswers] = useState<any>([]);
const { points, reCount } = useResults(savedAnswers);
const { points, reCount } = useResults();
const [selectedImage, setSelectedImage] = useState<{
url: string;
alt: string;
Expand All @@ -64,11 +65,9 @@ const QuizExamForm: React.FC<Props> = ({
],
},
onSubmit: () => {
saveAnswers(false).then(() => {
reCount({
questions: questions,
answers: savedAnswers,
});
reCount({
questions: questions,
answers: savedAnswers,
});
stopTimer();
},
Expand All @@ -90,25 +89,23 @@ const QuizExamForm: React.FC<Props> = ({
}
}, [remainingTime]);

const nextQuestion = (skip: boolean) => {
if (skip === false) {
useEffect(() => {
if (savedAnswers.length > 0) {
let done = true;
for (let x = 0; x < savedAnswers.length; x++) {
if (savedAnswers[x] === null && x !== currentQuestionIndex) {
if (savedAnswers[x] === null) {
done = false;
break;
}
}
if (done === true) {
handleCountAnswered();
formik.submitForm();
return;
} else {
saveAnswers(skip);
}
} else {
saveAnswers(skip);
}
}, [savedAnswers]);

const nextQuestion = (skip: boolean) => {
saveAnswers(skip);
let areAllQuestionsAnswered = false;
let i = currentQuestionIndex + 1;
while (savedAnswers[i] !== null && i < totalQuestions) {
Expand Down Expand Up @@ -305,7 +302,9 @@ const QuizExamForm: React.FC<Props> = ({
}`}
>
<svg
className={`border rounded-full absolute h-5 w-5 p-0.5 ${
className={`border ${
noOfAnswers > 1 ? "rounded" : "rounded-full"
} absolute h-5 w-5 p-0.5 ${
showCorrectAnswer &&
formik.values.options[index]?.isAnswer
? "text-emerald-500 border-emerald-600"
Expand All @@ -322,7 +321,7 @@ const QuizExamForm: React.FC<Props> = ({
: "hidden"
}`}
fillRule="evenodd"
d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM5.354 4.646a.5.5 0 1 0-.708.708L7.293 8l-2.647 2.646a.5.5 0 0 0 .708.708L8 8.707l2.646 2.647a.5.5 0 0 0 .708-.708L8.707 8l2.647-2.646a.5.5 0 0 0-.708-.708L8 7.293 5.354 4.646z"
d="M 2 0 a 2 2 0 0 0 -2 2 v 12 a 2 2 0 0 0 2 2 h 12 a 2 2 0 0 0 2 -2 V 2 a 2 2 0 0 0 -2 -2 H 2 z z"
clipRule="evenodd"
/>
</svg>
Expand Down
Loading
Loading