Skip to content

Commit

Permalink
Merge branch 'fix_GameBreakers' into 'staging'
Browse files Browse the repository at this point in the history
Fix game breakers

Adds:
* Leaderboard for FreeText questions

Fixes:
* Title of the live results still present when routing back to the lobby
* Removed correct answer in the question dialog as long as the countdown is still running
* Prevents the attendee's client from reconnecting to sessions (which resulted in an exception and a console.log error)

Modifies:
* The splashscreen dialog is now 2/3 of the timers length open when starting a quiz round

See merge request !522
  • Loading branch information
Christopher Mark Fullarton committed Oct 23, 2016
2 parents 10f72d8 + 418d689 commit 021e9bc
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 17 deletions.
4 changes: 2 additions & 2 deletions arsnova.click/client/layout/region_header/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Template.header.helpers({
case "memberlist":
return Router.current().params.quizName;
case "results":
return TAPi18n.__("region.footer.footer_bar.reading-confirmation");
return TAPi18n.__("view.liveResults.title");
case "onpolling":
return TAPi18n.__("view.voting.title");
case "statistics":
Expand Down Expand Up @@ -145,7 +145,7 @@ Template.header.onRendered(function () {
Session.set("theme", configDoc.theme);
}
});
if (!Session.get("questionGroup") && Router.current().params.quizName) {
if (!Session.get("questionGroup") && Router.current().params.quizName && localData.containsHashtag(Router.current().params.quizName)) {
Session.set("questionGroup", localData.reenterSession(Router.current().params.quizName));
}
$(window).resize(function () {
Expand Down
45 changes: 44 additions & 1 deletion arsnova.click/client/layout/view_leaderboard/scripts/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ function getLeaderBoardItemsByIndex(index) {
// only put member in leaderboard when he clicked the right amount, then check whether he clicked all the right ones
var totalResponseTime = 0;
const questionItem = QuestionGroupCollection.findOne().questionList[index];
if ((userResponses.length === rightAnswerOptions.count() || questionItem.type === "RangedQuestion") && (userResponses.length > 0) && userHasRightAnswers) {
if ((userResponses.length === rightAnswerOptions.count() || questionItem.type === "RangedQuestion") &&
(userResponses.length > 0) && userHasRightAnswers && questionItem.type !== "FreeTextQuestion") {
userResponses.forEach(function (userResponse) {
param.isCorrect = true;
param.answerOptionNumber = userResponse.answerOptionNumber;
Expand All @@ -110,6 +111,48 @@ function getLeaderBoardItemsByIndex(index) {
responseTime: totalResponseTime / responseTime
});
}
} else if (questionItem.type === "FreeTextQuestion") {
let answerOption = AnswerOptionCollection.findOne({questionIndex: index});
if (!answerOption.configCaseSensitive) {
answerOption.answerText = answerOption.answerText.toLowerCase();
}
if (!answerOption.configTrimWhitespaces) {
answerOption.answerText = answerOption.answerText.replace(/ /g, "");
}
if (!answerOption.configUsePunctuation) {
answerOption.answerText = answerOption.answerText.replace(/(\.)*(,)*(!)*(")*(;)*(\?)*/g, "");
}
const responseValue = ResponsesCollection.findOne({
questionIndex: index,
answerOptionNumber: 0,
userNick: member.nick
});
if (!answerOption.configCaseSensitive) {
responseValue.freeTextInputValue = responseValue.freeTextInputValue.toLowerCase();
}
if (!answerOption.configTrimWhitespaces) {
responseValue.freeTextInputValue = responseValue.freeTextInputValue.replace(/ /g, "");
}
if (!answerOption.configUsePunctuation) {
responseValue.freeTextInputValue = responseValue.freeTextInputValue.replace(/(\.)*(,)*(!)*(")*(;)*(\?)*/g, "");
}
if (answerOption.configUseKeywords) {
userHasRightAnswers = answerOption.answerText === responseValue.freeTextInputValue;
} else {
let hasCorrectKeywords = true;
answerOption.answerText.split(" ").forEach(function (keyword) {
if (responseValue.freeTextInputValue.indexOf(keyword) === -1) {
hasCorrectKeywords = false;
}
});
userHasRightAnswers = hasCorrectKeywords;
}
if (userHasRightAnswers) {
allGoodMembers.push({
nick: member.nick,
responseTime: responseValue.responseTime
});
}
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ Template.liveResults.events({

if (questionElement.type !== "FreeTextQuestion") {
answerContent += String.fromCharCode((answerOption.answerOptionNumber + 65)) + "<br/>";
} else {
answerContent += TAPi18n.__("view.liveResults.correct_answer") + ":<br/>";
}
answerContent += mathjaxMarkdown.getContent(answerOption.answerText) + "<br/>";
});
Expand Down Expand Up @@ -133,7 +135,7 @@ Template.liveResults.events({
return;
}

$('.header-title').text(TAPi18n.__("view.liveResults.title"));
//$('.header-title').text(TAPi18n.__("view.liveResults.title"));
calculateHeaderSize();

Meteor.call('Question.startTimer', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ Template.liveResults.helpers({
}
return !Session.get("countdownInitialized") && (
questionDoc.questionList[index].type === "RangedQuestion" ||
questionDoc.questionList[index].type === "FreeTextQuestion" ||
AnswerOptionCollection.find({
questionIndex: index,
isCorrect: true
Expand Down Expand Up @@ -350,7 +351,7 @@ Template.liveResults.helpers({
return;
}
$.each(questionDoc.questionList, function (index, element) {
if (element.type === "RangedQuestion") {
if (element.type === "RangedQuestion" || element.type === "FreeTextQuestion") {
hasRangedQuestion = true;
return false;
}
Expand All @@ -367,7 +368,7 @@ Template.liveResults.helpers({
return;
}
$.each(questionDoc.questionList, function (index, element) {
if (element.type === "RangedQuestion") {
if (element.type === "RangedQuestion" || element.type === "FreeTextQuestion") {
hasRangedQuestion = true;
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {MemberListCollection} from '/lib/member_list/collection.js';
import {SessionConfigurationCollection} from '/lib/session_configuration/collection.js';
import {QuestionGroupCollection} from '/lib/questions/collection.js';
import {showReadingConfirmationSplashscreen, ErrorSplashscreen} from '/client/plugins/splashscreen/scripts/lib.js';
import {TAPi18n} from 'meteor/tap:i18n';
import * as localData from '/lib/local_storage.js';
import {calculateHeaderSize} from '/client/layout/region_header/lib.js';
import * as footerElements from "/client/layout/region_footer/scripts/lib.js";
Expand All @@ -35,9 +34,6 @@ Template.liveResults.onRendered(()=> {
EventManagerCollection.findOne().questionIndex < 0 &&
SessionConfigurationCollection.findOne({hashtag: Router.current().params.quizName}).readingConfirmationEnabled !== false) {
showReadingConfirmationSplashscreen(0);
$('.header-title').text(TAPi18n.__("view.liveResults.reading_confirmation"));
} else {
$('.header-title').text(TAPi18n.__("view.liveResults.title"));
}
if (SessionConfigurationCollection.findOne({hashtag: Router.current().params.quizName}).readingConfirmationEnabled === false) {
if (EventManagerCollection.findOne().readingConfirmationIndex < 1 &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,15 @@ function addLiveresultsChangeEvents() {
onRendered: function (instance) {
var answerContent = "";
var questionContent = "";
const questionElement = QuestionGroupCollection.findOne().questionList[value.questionIndex];
mathjaxMarkdown.initializeMarkdownAndLatex();
if (SessionConfigurationCollection.findOne({hashtag: Router.current().params.quizName}).readingConfirmationEnabled === false) {
var questionDoc = QuestionGroupCollection.findOne({hashtag: Router.current().params.quizName});
if (questionDoc) {
questionContent = mathjaxMarkdown.getContent(questionDoc.questionList[value.questionIndex].questionText);
}
}
if (QuestionGroupCollection.findOne().questionList[value.questionIndex].type !== "RangedQuestion") {
if (questionElement.type !== "RangedQuestion" && questionElement.type !== "FreeTextQuestion") {
AnswerOptionCollection.find({questionIndex: value.questionIndex}, {sort: {answerOptionNumber: 1}}).forEach(function (answerOption) {
if (!answerOption.answerText) {
answerOption.answerText = "";
Expand All @@ -123,7 +124,7 @@ function addLiveresultsChangeEvents() {
mathjaxMarkdown.addSyntaxHighlightLineNumbers(instance.templateSelector.find('#answerContent'));
setTimeout(function () {
instance.close();
}, 10000);
}, questionElement.timer * 0.75 * 1000);
}
});
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@
position: absolute;
right: 10px;
margin-top: 10px;
opacity: 0.2;

&:hover {
-webkit-transition: opacity 0.5s ease-in;
-moz-transition: opacity 0.5s ease-in;
-o-transition: opacity 0.5s ease-in;
opacity: 1;
}

.glyphicon-remove {
border-radius: $corner-radius;
Expand All @@ -113,5 +121,6 @@
}

.noSplashscreenPadding {
padding: 0px 0px 15px 0px;
padding: 0 0 15px 0;
}

3 changes: 2 additions & 1 deletion arsnova.click/i18n/de.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,8 @@
"countdown": "Countdown",
"answer_option": "Antwort",
"guessed_correct": "Richtig geschätzt",
"guessed_wrong": "Falsch geschätzt"
"guessed_wrong": "Falsch geschätzt",
"correct_answer": "Richtige Antwort"
},
"lobby": {
"title": "Quiz Lobby",
Expand Down
3 changes: 2 additions & 1 deletion arsnova.click/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@
"countdown": "Countdown",
"answer_option": "Answer",
"guessed_correct": "Correctly estimated",
"guessed_wrong": "Wrong estimated"
"guessed_wrong": "Wrong estimated",
"correct_answer": "Correct answer"
},
"lobby": {
"title": "Quiz Lobby",
Expand Down
3 changes: 2 additions & 1 deletion arsnova.click/i18n/es.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@
"countdown": "Cuenta atrás",
"answer_option": "Respuesta",
"guessed_correct": "Has adivinado",
"guessed_wrong": "No has adivinado"
"guessed_wrong": "No has adivinado",
"correct_answer": "Respuesta correcta"
},
"lobby": {
"title": "Lobby del cuestionario",
Expand Down
3 changes: 2 additions & 1 deletion arsnova.click/i18n/fr.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@
"countdown": "Compte à rebours",
"answer_option": "Réponse",
"guessed_correct": "Bien estimé",
"guessed_wrong": "Mal estimé"
"guessed_wrong": "Mal estimé",
"correct_answer": "Bonne réponse"
},
"lobby": {
"title": "Lobby du quiz",
Expand Down

0 comments on commit 021e9bc

Please sign in to comment.