added logic to display answer preview
This commit is contained in:
parent
99af47d017
commit
b8527e870c
|
@ -213,6 +213,11 @@ socket.on("WRITE", function(data){
|
|||
|
||||
page += "<p>Question "+data.questionNr+" of "+data.questionsTotal+"</p>";
|
||||
page += "<h4>"+data.question+"</h4>";
|
||||
|
||||
if(data.answerPreview !== null){
|
||||
page += "<p>One of the existing answers is:<br><b>"+data.answerPreview+"</b></p>";
|
||||
}
|
||||
|
||||
page += "<p>Enter a <b>false</b> answer.</p>";
|
||||
page += "<input type='text' placeholder='Wrong answer' id='input_write' /><br/>";
|
||||
page += "<p id='text_write_error' style='display: none; color: #BB2266; '></p>";
|
||||
|
|
15
main.js
15
main.js
|
@ -349,8 +349,21 @@ function next(){
|
|||
// Save data
|
||||
questionData = json.results[0];
|
||||
|
||||
questionAnswers = [questionData.correct_answer];
|
||||
for(var i=0; i<questionData.incorrect_answers.length; i++){
|
||||
questionAnswers.push(questionData.incorrect_answers[i]);
|
||||
}
|
||||
answerPreview = (config.answerPreview ? questionAnswers[rand(0, questionAnswers.length)] : null);
|
||||
|
||||
// Send question to players
|
||||
userSockets.forEach(function(s){s.emit("WRITE", {questionNr:questionNr, questionsTotal:questionsTotal, question:questionData.question});});
|
||||
userSockets.forEach(function(s){
|
||||
s.emit("WRITE", {
|
||||
questionNr: questionNr,
|
||||
questionsTotal: questionsTotal,
|
||||
question: questionData.question,
|
||||
answerPreview: answerPreview,
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue