From 0a3ac9612d50f6a8031e6c6f753d4f5dc1299692 Mon Sep 17 00:00:00 2001 From: xerxesFOSoftware Date: Fri, 15 Mar 2024 20:11:17 +0800 Subject: [PATCH 1/3] Hide question details during buffer time --- WebApp/.env | 2 +- .../room/quiz/components/mulitpleChoice.js | 58 ++--- .../app/room/quiz/components/question.js | 22 +- .../app/room/quiz/components/trueOrFalse.js | 199 +++++++++--------- .../app/room/quiz/components/typeAnswer.js | 136 ++++++------ package-lock.json | 6 + 6 files changed, 228 insertions(+), 195 deletions(-) create mode 100644 package-lock.json diff --git a/WebApp/.env b/WebApp/.env index 694bb0dd..28050308 100644 --- a/WebApp/.env +++ b/WebApp/.env @@ -8,7 +8,7 @@ BACKEND_QUIZ_CONN_STR=Server=mssql;Database=QuizMasterQuiz;Trusted_Connection=Fa BACKEND_SESSION_CONN_STR=Server=mssql;Database=QuizMasterSession;Trusted_Connection=False;TrustServerCertificate=True;User Id=sa;Password=MsSql123 # GATEWAY -GATEWAY_CORS=http://localhost:3000;http://localhost:3001;http://localhost:5173;https://localhost:7081; +GATEWAY_CORS=http://localhost:3000;http://localhost:3001;http://localhost:5173;https://localhost:7081;https://polliwog-measured-bulldog.ngrok-free.app # SESSION SETTINGS SHOW_ANSWER_AFTER_QUESTION_DELAY=10 diff --git a/WebApp/frontend/quiz_session/app/room/quiz/components/mulitpleChoice.js b/WebApp/frontend/quiz_session/app/room/quiz/components/mulitpleChoice.js index 41a8d549..58f8f13e 100644 --- a/WebApp/frontend/quiz_session/app/room/quiz/components/mulitpleChoice.js +++ b/WebApp/frontend/quiz_session/app/room/quiz/components/mulitpleChoice.js @@ -8,7 +8,7 @@ import QuestionImage from "./questionImage"; import Participants from "../../components/participants"; import useUserTokenData from "@/app/util/useUserTokenData"; import { useScreenshot } from "use-react-screenshot"; -import { useAnswer } from "@/app/util/store"; +import { useAnswer, useMetaData } from "@/app/util/store"; import { notifications } from "@mantine/notifications"; export default React.forwardRef(MulitpleChoice); @@ -24,6 +24,9 @@ function MulitpleChoice({ question, connectionId }, ref) { const [previousStatement, setPreviousStatement] = useState(null); const { answer } = useAnswer(); + /* Shows/hides question details during buffer time */ + const showDetails = question?.remainingTime <= question?.question?.qTime; + const [image, takeScreenShot] = useScreenshot({ type: "image/jpeg", quality: 1.0, @@ -124,31 +127,34 @@ function MulitpleChoice({ question, connectionId }, ref) { )} -
- {question?.details.map((choices, index) => ( -
{ - if (isAdmin) return; - if (isSubmitted) return; - handlePick(choices.qDetailDesc); - }} - > - {choices.qDetailDesc} -
- ))} -
+ + {showDetails && ( +
+ {question?.details.map((choices, index) => ( +
{ + if (isAdmin) return; + if (isSubmitted) return; + handlePick(choices.qDetailDesc); + }} + > + {choices.qDetailDesc} +
+ ))} +
+ )} {!isAdmin && (
{ setResetLeader(); setIsShowLeader(false); - } + }; useEffect(() => { if (leader.length > 0) { @@ -63,7 +63,12 @@ export default function Question() { }, [question, leader, isStop]); if (isShowLeader && !isFinished) { - return ; + return ( + + ); } else if (isFinished) { return ( <> @@ -73,12 +78,19 @@ export default function Question() {
{/* Add an empty div to push the button to the right */}
diff --git a/WebApp/frontend/quiz_session/app/room/quiz/components/trueOrFalse.js b/WebApp/frontend/quiz_session/app/room/quiz/components/trueOrFalse.js index 08a2811d..3390ba80 100644 --- a/WebApp/frontend/quiz_session/app/room/quiz/components/trueOrFalse.js +++ b/WebApp/frontend/quiz_session/app/room/quiz/components/trueOrFalse.js @@ -28,6 +28,8 @@ function TrueOrFalse({ question, connectionId }, ref) { type: "image/jpeg", quality: 1.0, }); + /* Shows/hides question details during buffer time */ + const showDetails = question?.remainingTime <= question?.question?.qTime; const submitScreenshot = (id, connectionId) => takeScreenShot(ref.current).then((image) => @@ -95,109 +97,112 @@ function TrueOrFalse({ question, connectionId }, ref) { {hasImage && } - {isAdmin ? ( -
- {ANSWER && ( -
-

Correct answer is:

-
-

{ANSWER}

- + + {isAdmin + ? showDetails && ( +
+ {ANSWER && ( +
+

Correct answer is:

+
+

{ANSWER}

+ +
+
+ )} +
+
{ + if (isAdmin) return; + if (isSubmitted) return; + handlePick("true"); + }} + > + True +
+
{ + if (isAdmin) return; + if (isSubmitted) return; + handlePick("false"); + }} + > + False +
- )} -
-
{ - if (isAdmin) return; - if (isSubmitted) return; - handlePick("true"); - }} - > - True -
-
{ - if (isAdmin) return; - if (isSubmitted) return; - handlePick("false"); - }} - > - False -
-
-
- ) : ( -
- {ANSWER && ( -
-

Correct answer is:

-
-

{ANSWER}

- + ) + : showDetails && ( +
+ {ANSWER && ( +
+

Correct answer is:

+
+

{ANSWER}

+ +
+
+ )} +
+
{ + if (isAdmin) return; + if (isSubmitted) return; + handlePick("true"); + }} + > + True +
+
{ + if (isAdmin) return; + if (isSubmitted) return; + handlePick("false"); + }} + > + False +
)} -
-
{ - if (isAdmin) return; - if (isSubmitted) return; - handlePick("true"); - }} - > - True -
-
{ - if (isAdmin) return; - if (isSubmitted) return; - handlePick("false"); - }} - > - False -
-
-
- )} - {!isAdmin && ( + {!isAdmin && showDetails && (
takeScreenShot(ref.current).then((image) => @@ -95,75 +97,77 @@ function TypeAnswer({ question, connectionId, answer: ANSWER }, ref) {
{hasImage && }
- {isAdmin ? ( -
- {ANSWER ? ( -
-

Correct answer is:

-
-

{ANSWER}

- -
-
- ) : ( -
-
-
- | -
-

- Type your answers on the text area -

-
-
- )} - -
- ) : ( - <> - {ANSWER && ( + {isAdmin + ? showDetails && (
-

Correct answer is:

-
-

{ANSWER}

- -
-
- )} - {!isAdmin && ( -
-
- { - setAnswer(e.target.value); - }} - disabled={isSubmitted || ANSWER} - value={answer ?? (ANSWER ? "" : "")} - /> -
-
- -
+ {ANSWER ? ( +
+

Correct answer is:

+
+

{ANSWER}

+ +
+
+ ) : ( +
+
+
+ | +
+

+ Type your answers on the text area +

+
+
+ )} +
+ ) + : showDetails && ( + <> + {ANSWER && ( +
+

Correct answer is:

+
+

{ANSWER}

+ +
+
+ )} + {!isAdmin && ( +
+
+ { + setAnswer(e.target.value); + }} + disabled={isSubmitted || ANSWER} + value={answer ?? (ANSWER ? "" : "")} + /> +
+
+ +
+
+ )} + )} - - )}
diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 00000000..aa919b87 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "QuizMaster", + "lockfileVersion": 3, + "requires": true, + "packages": {} +} From ea0f26bdfa2450c60e9d8fda0adbbb30cf097b72 Mon Sep 17 00:00:00 2001 From: xerxesFOSoftware Date: Fri, 15 Mar 2024 20:19:10 +0800 Subject: [PATCH 2/3] Hide timer during buffer time --- .../quiz_session/app/room/quiz/components/header.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/WebApp/frontend/quiz_session/app/room/quiz/components/header.js b/WebApp/frontend/quiz_session/app/room/quiz/components/header.js index 513c4dba..d98822eb 100644 --- a/WebApp/frontend/quiz_session/app/room/quiz/components/header.js +++ b/WebApp/frontend/quiz_session/app/room/quiz/components/header.js @@ -16,6 +16,8 @@ export default function Header() { const [isMute, setIsMute] = useState(); const [collapsedVolume, setCollapsedVolumne] = useState(true); const [volume, setVolume] = useState(100); + /* Shows/hides question details during buffer time */ + const showDetails = question?.remainingTime <= question?.question?.qTime; const [play, { stop }] = useSound( "/audio/quiz_master-ten-seconds-count-down.mp3", @@ -64,7 +66,9 @@ export default function Header() {
10 ? " bg-green-700/50" : "bg-red-500" }`} > From 9b4e2ce1377f068a9c604d63dfefa89f1d480d98 Mon Sep 17 00:00:00 2001 From: Jayharron Mar Abejar <72720429+jaymar921@users.noreply.github.com> Date: Fri, 15 Mar 2024 20:21:32 +0800 Subject: [PATCH 3/3] Update .env --- WebApp/.env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WebApp/.env b/WebApp/.env index 28050308..694bb0dd 100644 --- a/WebApp/.env +++ b/WebApp/.env @@ -8,7 +8,7 @@ BACKEND_QUIZ_CONN_STR=Server=mssql;Database=QuizMasterQuiz;Trusted_Connection=Fa BACKEND_SESSION_CONN_STR=Server=mssql;Database=QuizMasterSession;Trusted_Connection=False;TrustServerCertificate=True;User Id=sa;Password=MsSql123 # GATEWAY -GATEWAY_CORS=http://localhost:3000;http://localhost:3001;http://localhost:5173;https://localhost:7081;https://polliwog-measured-bulldog.ngrok-free.app +GATEWAY_CORS=http://localhost:3000;http://localhost:3001;http://localhost:5173;https://localhost:7081; # SESSION SETTINGS SHOW_ANSWER_AFTER_QUESTION_DELAY=10