Skip to content

Commit

Permalink
Merge pull request #193 from FS-FAST-TRACK/production/v_1
Browse files Browse the repository at this point in the history
Production/v 1
  • Loading branch information
jaymar921 authored Mar 13, 2024
2 parents 78474da + 4998721 commit a58b52c
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ public async Task StartQuiz(SessionHub hub, SessionHandler handler, QuizRoomServ
await Task.Delay(1000);
// Notify the admin while the game is paused
await hub.Clients.Client(hostConnectionId).SendAsync("paused", $"Game is paused, click proceed to start or the game will resume automatically on '{limit--} second/s'");
await hub.Clients.GroupExcept(roomPin, hostConnectionId).SendAsync("paused", $"Game is Paused");
}

// Reset to true
Expand Down
5 changes: 3 additions & 2 deletions WebApp/frontend/quiz-master/app/questions/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import ErrorContainer from "@/components/pages/ErrorContainer";
import { useErrorRedirection } from "@/utils/errorRedirection";
import { fetchLoginUser } from "@/lib/quizData";
import { useRouter } from "next/navigation";
import { useQuestionnaire } from "@/store/QuestionStore";
import { QUESTION_DEFAULT, useQuestionnaire } from "@/store/QuestionStore";
import { GetAllQuestion } from "@/lib/hooks/question";

export default function Layout({ children }: { children: React.ReactNode }) {
Expand Down Expand Up @@ -48,7 +48,8 @@ export default function Layout({ children }: { children: React.ReactNode }) {
setQuestionTypes(typesRes.data);

const questionsRes = await GetAllQuestion();
if (questionsRes) setQuestionnaire(questionsRes.pop());
if (questionsRes)
setQuestionnaire(questionsRes.pop() ?? QUESTION_DEFAULT);
} catch (error) {
redirectToError();
}
Expand Down
24 changes: 13 additions & 11 deletions WebApp/frontend/quiz-master/store/QuestionStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,20 @@ interface IQuestionStore {
getLatestQuestionnaire: () => Question | undefined;
}

export const QUESTION_DEFAULT = {
id: -1,
qAudio: "",
qCategoryId: 1,
qDifficultyId: 1,
qTypeId: 1,
qImage: "",
qStatement: "",
qTime: 30,
details: [],
} as Question;

export const useQuestionnaire = create<IQuestionStore>((set, get) => ({
questionnaire: {
id: -1,
qAudio: "",
qCategoryId: 1,
qDifficultyId: 1,
qTypeId: 1,
qImage: "",
qStatement: "",
qTime: 30,
details: [],
} as Question,
questionnaire: QUESTION_DEFAULT,
setQuestionnaire(fetchedQuestionnaire) {
set({ questionnaire: fetchedQuestionnaire });
},
Expand Down
15 changes: 13 additions & 2 deletions WebApp/frontend/quiz_session/app/components/welcome.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { useSearchParams } from "next/navigation";
import { useRouter } from "next/navigation";
import { Progress } from "@mantine/core";
import CryptoJS from "crypto-js";
import { BASE_URL } from "../util/api";

export default function Welcome() {
const searchParams = useSearchParams();
Expand Down Expand Up @@ -104,7 +105,6 @@ export default function Welcome() {
const username = params.get("name");

let loggedIn = false;

if (token && username && connection.state === "Connected") {
//TODO: SECRET KEY SHOULD BE REPLACED
const decrypToken = CryptoJS.AES.decrypt(
Expand All @@ -127,7 +127,18 @@ export default function Welcome() {
if (prevProgress >= 100) {
clearInterval(id);
if (loggedIn) {
push("/auth/code");
// Verify Auth Token
const token = localStorage.getItem("token");
fetch(BASE_URL+"/gateway/api/auth/info", {method:'GET', headers: {"Authorization": `Bearer ${token}`}})
.then(r => r.json().then(d => ({status: r.status, body: d})))
.then(d =>{
if(d.status === 200){
push("/auth/code");
}else{
push("/auth");
}
})

} else {
push("/auth");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ function TypeAnswer({ question, connectionId, answer: ANSWER }, ref) {
// clear input field if answer is shown
if (isAdmin) return; // Prevent the admin side from auto-submitting an answer
if (ANSWER && !isSubmitted) {
if (!answer) {
notifications.show({ title: "No answer inputted" });
}
// if (!answer) {
// notifications.show({ title: "No answer inputted" });
// }
setTimeout(() => {
setAnswer();
}, 10_000);
Expand Down

0 comments on commit a58b52c

Please sign in to comment.