Skip to content

Commit

Permalink
refs #26 Add KO 3.0 and start working on session model.
Browse files Browse the repository at this point in the history
  • Loading branch information
truedat101 committed Nov 11, 2013
1 parent 5ec7831 commit efa63f3
Show file tree
Hide file tree
Showing 5 changed files with 190 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/js.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ if (js.DEBUG) {

registerRoute = function(path, handler, method, rexp) {
var myHandler = function(req, res) {
js.info("Handling: " + req.method + " " + req.url);
// js.info("Handling: " + req.method + " " + req.url);
handler(req, res);
// console.info(req.body); // Dump all the routes
};
Expand Down
9 changes: 9 additions & 0 deletions lib/smile/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ Game.prototype.calcScoreAndRating = function calcScoreAndRating(student) {
currentQuestionCorrectCount = questionCorrectCountMap[i];
}
if (correctAnswer === parseInt(studentAnswer, 10)) {
console.log("Student(" + student.getName() + ") got correct answer");
studentScore++;
currentQuestionCorrectCount++;
}
Expand All @@ -167,6 +168,7 @@ 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;
};

Expand All @@ -181,6 +183,11 @@ Game.prototype.calcQuestionsCorrectPercentage = function calcQuestionsCorrectPer
allows us to keep an archive of activities for each session whether or not the Teacher remembers to do this.
Our approach here is purely to support this demo-ad hoc mode for SMILE Plug, and isn't necessarily what we'd do
for SMILE Global 2.x.
Perhaps the most efficient way to move forward with this routine is to only post updates to this data
if data changes, so we'd have calculate results tied to changes in the data, and the consumers of this
data would access the "cached result". Worry about optimization later, as I've only introduced bugs with
attempts at optimizing the results.
*/
Game.prototype.calculateResults = function calculateResults() {
var listOfQuestions = this.questions.getList();
Expand Down Expand Up @@ -230,6 +237,8 @@ Game.prototype.calculateResults = function calculateResults() {
result.averageRatings = averageRatings;
result.questionsCorrectPercentage = this.calcQuestionsCorrectPercentage();
this.resultsCache = result;
} else {
console.log("Results: Cache is not null");
}

return this.resultsCache;
Expand Down
Loading

0 comments on commit efa63f3

Please sign in to comment.