diff --git a/src/assets/font/Audiowide-Regular.ttf b/src/assets/font/Audiowide-Regular.ttf
new file mode 100644
index 00000000..348817d5
Binary files /dev/null and b/src/assets/font/Audiowide-Regular.ttf differ
diff --git a/src/index.scss b/src/index.scss
index 852bb1fb..f120975a 100644
--- a/src/index.scss
+++ b/src/index.scss
@@ -75,6 +75,14 @@
font-display: auto;
}
+@font-face {
+ font-family: 'Audiowide';
+ src: url('./assets/font/Audiowide-Regular.ttf') format('truetype');
+ font-weight: 400;
+ font-style: normal;
+ font-display: swap;
+}
+
.content {
padding-top: 14px;
margin-left: 110px;
diff --git a/src/pages/public/Companion/components/dataverse/Dashboard.js b/src/pages/public/Companion/components/dataverse/Dashboard.js
index 01cc3eba..c69506f0 100644
--- a/src/pages/public/Companion/components/dataverse/Dashboard.js
+++ b/src/pages/public/Companion/components/dataverse/Dashboard.js
@@ -4,52 +4,12 @@ import React, {
import {
useLocation, useHistory
} from "react-router-dom";
-import {
- Typography
-} from "@material-ui/core";
import Quiz from "./Quiz";
-import Leaderboard from "./Leaderboard";
-const useStyles = {
- root: {
- position: "relative",
- minHeight: "180vh",
- background: "linear-gradient(135deg, #3C1F62, #5A3D89, #2F3C53, #121C2C)",
- color: "white",
- padding: "20px",
- textAlign: "center", // Centering the content
- },
- heading: {
- fontSize: "6rem", // Making the main heading bigger
- fontWeight: "bold", // Making the text bold
- marginTop: "40px", // Adding space above the heading
- },
- subheading: {
- fontSize: "1.5rem", // Increasing the font size for subheadings
- fontWeight: "500", // Optional: make the subheading a bit lighter
- },
- text: {
- fontSize: "1.2rem", // Make other text a bit larger
- },
- infoRow: {
- display: "flex", // Align items in a row
- justifyContent: "center", // Center the row
- gap: "30px", // Space between the items
- marginBottom: "20px", // Space below the row
- },
- label: {
- color: "#B0B0B0", // Gray color for labels
- fontWeight: "500", // Optional: make labels a bit lighter
- },
- value: {
- background: "linear-gradient(to bottom, #FFFFFF, #7B7DFF)", // Gradient from white to light purple
- WebkitBackgroundClip: "text", // Clip the background to the text
- color: "transparent", // Make the text color transparent so the gradient shows through
- fontWeight: "700", // Optional: make values bold
- },
-};
const Dashboard = () => {
+ const startTime = new Date();
+ const endTime = new Date(startTime.getTime() + 5 * 60000);
const location = useLocation();
const history = useHistory();
const {
@@ -64,32 +24,13 @@ const Dashboard = () => {
}, [teamPoints, teamName, history]);
return (
-
- {!teamPoints || !teamName ? (
- Redirecting to Companion...
- ) : (
- <>
- Team Dashboard
- {/* Flex container for the Team Name and Current Points */}
-
-
- Team Name:
-
-
- {teamName}
-
-
- Current Points:
-
-
- {teamPoints}
-
-
;
};
export default QuizDashboard;
diff --git a/src/pages/public/Companion/components/dataverse/QuizRoom.js b/src/pages/public/Companion/components/dataverse/QuizRoom.js
index 4a6e8117..4132fe0d 100644
--- a/src/pages/public/Companion/components/dataverse/QuizRoom.js
+++ b/src/pages/public/Companion/components/dataverse/QuizRoom.js
@@ -2,60 +2,144 @@ import React, {
useState
} from "react";
import {
- Typography, Button, TextField, FormControl
+ Typography,
+ Button,
+ TextField,
+ FormControl,
+ IconButton,
+ Grid,
+ Card,
+ CardContent
} from "@material-ui/core";
+import ArrowBackIcon from "@mui/icons-material/ArrowBack";
import {
fetchBackend
} from "utils";
-const quizData = {
- 1: {
- questions: [
- "What is the capital of France?",
- "What is the largest country by area?",
- "Who painted the Mona Lisa?",
- "What is the smallest prime number?",
- "What is the tallest mountain in the world?",
- ],
- correctAnswers: ["Paris", "Russia", "Leonardo da Vinci", "2", "Mount Everest"],
- },
- 2: {
- questions: [
- "Which planet is known as the Red Planet?",
- "What gas do plants absorb from the atmosphere?",
- "What is the chemical symbol for water?",
- "Who developed the theory of relativity?",
- "What is the speed of light?",
- ],
- correctAnswers: ["Mars", "Carbon dioxide", "H2O", "Albert Einstein", "299,792,458 m/s"],
- },
- 3: {
- questions: [
- "Who wrote 'To Kill a Mockingbird'?",
- "What is the main language spoken in Brazil?",
- "Who is known as the Father of Computers?",
- "What is the hardest natural substance?",
- "What is the boiling point of water in Celsius?",
- ],
- correctAnswers: ["Harper Lee", "Portuguese", "Charles Babbage", "Diamond", "100"],
- },
-};
-
const QuizRoom = ({
roomNumber, goBack, userRegistration
}) => {
- const [answers, setAnswers] = useState(Array(5).fill("")); // Store answers for 5 questions
+ const [answers, setAnswers] = useState(Array(5).fill("")); // Array to hold answers for 5 questions
+ const [selectedOptions, setSelectedOptions] = useState(Array(5).fill(null)); // To track selected options for multiple-choice questions
+ const [answerStatus, setAnswerStatus] = useState(Array(5).fill(null)); // To track the status of each question (null = not checked, 'correct' or 'incorrect')
+
+ const quizData = {
+ 1: {
+ questions: [
+ "Which player had the most rebounds in a single game?",
+ "Which of the following teams scored the most points?",
+ "Based on historical outcomes, if the Boston Celtics and Charlotte Hornets play against each other, who would you predict would win?",
+ "Which of the following attributes is most positively correlated with Total Points Scored?",
+ "What is this SQL query trying to do? \n\nSELECT player \nFROM NBA \nWHERE team = 'NYK' AND total_points >= 20"
+ ],
+ questionType: [
+ "text", // Free text question
+ "multiple-choice", // Free text question
+ "multiple-choice", // Free text question
+ "multiple-choice", // Free text question
+ "multiple-choice" // Free text question
+ ],
+ correctAnswers: [
+ "Victor Wembanyama",
+ "TOR",
+ "BOS",
+ "Field Goal Attempts",
+ "Retrieve all players who play for the New York Knicks and scored at least 20 points in a game"
+ ],
+ options: [
+ [],
+ ["ATL", "TOR", "WAS"],
+ ["BOS", "CHO"],
+ ["Field Goal Attempts", "3 Pointer Attempts", "Free Throw Attempts"],
+ [
+ "Retrieve all players who scored at least 20 points in a game",
+ "Retrieve the total points scored by New York Knicks players who scored more than 20 points in a game",
+ "Retrieve all players who play for the New York Knicks and scored at least 20 points in a game"
+ ]
+ ] // No multiple choice questions for this quiz
+ },
+ 2: {
+ questions: [
+ "Which planet is known as the Red Planet?",
+ "What gas do plants absorb from the atmosphere?",
+ "What is the chemical symbol for water?",
+ "Who developed the theory of relativity?",
+ "What is the speed of light?"
+ ],
+ questionType: [
+ "multiple-choice", // Multiple choice question
+ "multiple-choice", // Multiple choice question
+ "text", // Free text question
+ "text", // Free text question
+ "text" // Free text question
+ ],
+ correctAnswers: [
+ "Mars",
+ "Carbon dioxide",
+ "H2O",
+ "Albert Einstein",
+ "299,792,458 m/s"
+ ],
+ options: [
+ ["Mars", "Earth", "Venus", "Jupiter"],
+ ["Oxygen", "Carbon dioxide", "Nitrogen", "Hydrogen"],
+ [], // No options for this text question
+ [], // No options for this text question
+ [] // No options for this text question
+ ]
+ },
+ 3: {
+ questions: [
+ "Which planet is known as the Red Planet?",
+ "What gas do plants absorb from the atmosphere?",
+ "What is the chemical symbol for water?",
+ "Who developed the theory of relativity?",
+ "What is the speed of light?"
+ ],
+ questionType: [
+ "multiple-choice", // Multiple choice question
+ "multiple-choice", // Multiple choice question
+ "text", // Free text question
+ "text", // Free text question
+ "text" // Free text question
+ ],
+ correctAnswers: [
+ "Mars",
+ "Carbon dioxide",
+ "H2O",
+ "Albert Einstein",
+ "299,792,458 m/s"
+ ],
+ options: [
+ ["Mars", "Earth", "Venus", "Jupiter"],
+ ["Oxygen", "Carbon dioxide", "Nitrogen", "Hydrogen"],
+ [], // No options for this text question
+ [], // No options for this text question
+ [] // No options for this text question
+ ]
+ }
+ };
const handleAnswerChange = (index, value) => {
- const updatedAnswers = [...answers];
- updatedAnswers[index] = value;
- setAnswers(updatedAnswers);
+ const newAnswers = [...answers];
+ newAnswers[index] = value;
+ setAnswers(newAnswers);
+ };
+
+ const handleMultipleChoiceAnswer = (index, option) => {
+ const newSelectedOptions = [...selectedOptions];
+ newSelectedOptions[index] = option;
+ setSelectedOptions(newSelectedOptions);
+ const newAnswers = [...answers];
+ newAnswers[index] = option;
+ setAnswers(newAnswers);
};
const checkAnswers = async () => {
const {
correctAnswers, questions
} = quizData[roomNumber];
+ const newAnswerStatus = [...answerStatus]; // Copy the current answerStatus array
try {
const response = await fetchBackend(
@@ -77,6 +161,9 @@ const QuizRoom = ({
const question = questions[index];
const isCorrect = answer.trim().toLowerCase() === correctAnswers[index].trim().toLowerCase();
+ // Update the status for this question
+ newAnswerStatus[index] = isCorrect ? "correct" : "incorrect";
+
// Award points only if the question hasn't been answered correctly before
if (isCorrect && !completedQuestions.includes(question)) {
score += 1;
@@ -84,6 +171,9 @@ const QuizRoom = ({
}
});
+ // Update the answerStatus state
+ setAnswerStatus(newAnswerStatus);
+
if (score > 0) {
const updateResponse = await fetchBackend(
"/team/points",
@@ -97,7 +187,6 @@ const QuizRoom = ({
false
);
- // NOTE: using the scannedQRs field to store already answered correctly questions
const addQuestions = await fetchBackend(
"/team/addQuestions",
"put",
@@ -109,10 +198,6 @@ const QuizRoom = ({
},
false
);
-
- alert(`Team points updated successfully: ${updateResponse.updatedPoints}`);
- } else {
- alert("No new points awarded :(");
}
} catch (error) {
console.error("Error updating team points:", error);
@@ -121,49 +206,142 @@ const QuizRoom = ({
};
+ // Render the questions based on the room number
+ const renderQuiz = () => {
+ const {
+ questions, questionType, options
+ } = quizData[roomNumber];
+
+ return questions.map((question, index) => {
+ const questionStatus = answerStatus[index];
+ const isCorrect = questionStatus === "correct";
+ const isIncorrect = questionStatus === "incorrect";
+
+ return (
+
+
+
+ {question.split("\n").map((part, i) => (
+
+ {part}
+ {i < question.split("\n").length - 1 && }
+
+ ))}
+
+
+ {questionType[index] === "multiple-choice" ? (
+
+ {options[index].map((option, i) => (
+
+
+
+ ))}
+
+ ) : (
+
+ handleAnswerChange(index, e.target.value)}
+ style={{
+ marginTop: "10px",
+ width: "100%"
+ }}
+ />
+
+ )}
+
+
+ );
+ });
+ };
+
return (
-