Skip to content

Commit

Permalink
Added Play as a Guest Functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
uo289267 committed Apr 24, 2024
1 parent 4625dd6 commit 59a2b4a
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 8 deletions.
Binary file added webapp/public/game.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion webapp/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function App() {
<Route path="/instructions" element={<Instructions />} />
<Route path="/addUser" element={isLoggedIn ? <GameMenu /> : <AddUser />} />
<Route path="/menu" element={isLoggedIn ? <GameMenu /> : <Login /> } />
<Route path="/questions" element={isLoggedIn ? <QuestionView /> : <Login />} />
<Route path="/questions" element={ <QuestionView />} />
<Route path="/historical" element={isLoggedIn ? <HistoricalView /> : <Login />} />
<Route path="/configurator" element={isLoggedIn ? <GameConfigurator /> : <Login />}/>
<Route path="/ranking" element={isLoggedIn ? <RankingView /> : <Login />} />
Expand Down
4 changes: 2 additions & 2 deletions webapp/src/components/Home/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ function Home() {
<label htmlFor="toggleClose" title={t("home.clickClose")}></label>
<b>
W
<Link to="/instructions" title={t("home.how_to_play")}>
<img src="/instrucciones.png" alt="Instructions" style={{ width: "100%", height: "100%" }} />
<Link to="/questions" title={t("home.game")}>
<img src="/game.png" alt="Game" style={{ width: "100%", height: "100%" }} />
</Link>
</b>
<b>
Expand Down
11 changes: 8 additions & 3 deletions webapp/src/components/questionView/QuestionView.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ function QuestionView({type= "COMPETITIVE", amount=5}){
const generateQuestions = async (numQuestion) => {
if (numQuestion < 0) {
try {

var generatedQuestions = await questionGenerator.generateQuestions(i18n.language, type, amount, cookie.token);
var generatedQuestions;
if(cookie){
generatedQuestions = await questionGenerator.generateQuestions(i18n.language, type, amount, cookie.token);
}else{
generateQuestions = await questionGenerator.generateQuestions(i18n.language, type, amount, null);//playing as guest
}
setQuestions(generatedQuestions);
setnumQuestion(0);
} catch (error) {
Expand Down Expand Up @@ -110,7 +114,8 @@ function QuestionView({type= "COMPETITIVE", amount=5}){
creationHistoricalRecord.setCompetitive(type === 'COMPETITIVE');
creationHistoricalRecord.setDate(Date.now());
creationHistoricalRecord.setPoints(points);
creationHistoricalRecord.sendRecord(cookie.username, cookie.token);
if(cookie)
creationHistoricalRecord.sendRecord(cookie.username, cookie.token);
}
}, 1000);

Expand Down
3 changes: 2 additions & 1 deletion webapp/src/translations/en/global.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"msg1": "Welcome to the knowledge challenge! Get ready to test your mind and demonstrate your skills. In this exciting game, you will face a series of questions that will test your knowledge on a variety of topics.",
"msg2": "So go ahead, prove that you are the master of questions! Are you ready to accept the challenge?",
"clickOpen": "Click to continue",
"clickClose": "Click to close"
"clickClose": "Click to close",
"game":"Play as a guest"
},

"navBar": {
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/translations/es/global.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"msg1": "Bienvenido al desafío de conocimientos! Prepárate para poner a prueba tu mente y demostrar tus habilidades. En este emocionante juego, te enfrentarás a una serie de preguntas que pondrán a prueba tu conocimiento en una variedad de temas.",
"msg2": "¡Así que adelante, demuestra que eres el maestro de las preguntas! ¿Estás listo para aceptar el desafío?",
"clickOpen": "Haz click para continuar",
"clickClose": "Haz click para cerrar"
"clickClose": "Haz click para cerrar",
"game":"Juega como invitado"

},

Expand Down

0 comments on commit 59a2b4a

Please sign in to comment.