diff --git a/lib/smile/game.js b/lib/smile/game.js index 8d8732f..83372db 100644 --- a/lib/smile/game.js +++ b/lib/smile/game.js @@ -168,7 +168,6 @@ Game.prototype.calcQuestionsCorrectPercentage = function calcQuestionsCorrectPer var count = this.questionCorrectCountMap[key]; percentages[key] = parseInt((count / numberOfStudents) * 100, 10); } - console.log("Results: perecentages : " + percentages + " for " + numberOfStudents); return percentages; }; @@ -194,53 +193,49 @@ Game.prototype.calculateResults = function calculateResults() { var scoresMap = {}; var winnerScore = 0; - if (this.resultsCache === null) { - for (var key in this.students.getAll()) { - var student = this.students.getStudent(key); - var studentScore = student.getScore(); - if (winnerScore <= studentScore) { - winnerScore = studentScore; - if (winnerScore !== 0) { - if (scoresMap.hasOwnProperty(studentScore)) { - scoresMap[studentScore].push(student.getName()); - } else { - scoresMap[studentScore] = [ student.getName() ]; - } + for (var key in this.students.getAll()) { + var student = this.students.getStudent(key); + var studentScore = student.getScore(); + if (winnerScore <= studentScore) { + winnerScore = studentScore; + if (winnerScore !== 0) { + if (scoresMap.hasOwnProperty(studentScore)) { + scoresMap[studentScore].push(student.getName()); + } else { + scoresMap[studentScore] = [ student.getName() ]; } } } + } - var winnerRating = 0; - var ratingsMap = {}; - var averageRatings = []; - for (key in this.questionRatings) { - var question = listOfQuestions[key]; - var averageRating = this.getQuestionAverageRating(key); - averageRatings.push(averageRating); - if (winnerRating <= averageRating) { - winnerRating = averageRating; - if (ratingsMap.hasOwnProperty(averageRating)) { - ratingsMap[averageRating].push(question.NAME); - } else { - ratingsMap[averageRating] = [ question.NAME ]; - } + var winnerRating = 0; + var ratingsMap = {}; + var averageRatings = []; + for (key in this.questionRatings) { + var question = listOfQuestions[key]; + var averageRating = this.getQuestionAverageRating(key); + averageRatings.push(averageRating); + if (winnerRating <= averageRating) { + winnerRating = averageRating; + if (ratingsMap.hasOwnProperty(averageRating)) { + ratingsMap[averageRating].push(question.NAME); + } else { + ratingsMap[averageRating] = [ question.NAME ]; } } - - var result = new Result(); - result.winnerScore = winnerScore; - result.bestScoredStudentNames = scoresMap[winnerScore]; - result.winnerRating = winnerRating; - result.bestRatedQuestionStudentNames = ratingsMap[winnerRating]; - result.numberOfQuestions = this.questions.getNumberOfQuestions(); - result.rightAnswers = this.questions.getRightAnswers(); - result.averageRatings = averageRatings; - result.questionsCorrectPercentage = this.calcQuestionsCorrectPercentage(); - this.resultsCache = result; - } else { - console.log("Results: Cache is not null"); } + var result = new Result(); + result.winnerScore = winnerScore; + result.bestScoredStudentNames = scoresMap[winnerScore]; + result.winnerRating = winnerRating; + result.bestRatedQuestionStudentNames = ratingsMap[winnerRating]; + result.numberOfQuestions = this.questions.getNumberOfQuestions(); + result.rightAnswers = this.questions.getRightAnswers(); + result.averageRatings = averageRatings; + result.questionsCorrectPercentage = this.calcQuestionsCorrectPercentage(); + this.resultsCache = result; + return this.resultsCache; }; diff --git a/static/smile-student.html b/static/smile-student.html index d2d0467..ba77090 100644 --- a/static/smile-student.html +++ b/static/smile-student.html @@ -17,7 +17,7 @@ -