From 4a46dabe28de01c93e45c86d51b8f5d4a374a44f Mon Sep 17 00:00:00 2001 From: "David J. Kordsmeier" Date: Thu, 30 Jan 2014 06:22:11 -0800 Subject: [PATCH] refs #74, #101 Fix IQ PIC data save on session save. Also fix missing submit buttons on new session (after a session has completed) --- routes/index.js | 19 +++++++++++++++++-- static/js/smilestudent.js | 2 +- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/routes/index.js b/routes/index.js index da7ef77..ef1ff2e 100644 --- a/routes/index.js +++ b/routes/index.js @@ -170,7 +170,7 @@ exports.handlePostNewIQSet = function(req, res) { // console.log(game.questions.getList()); iqset.iqdata[i].PIC = game.questions.getQuestionPicture(tmpidx); iqset.iqdata[i].PICURL = '/smile/questionview/' + tmpidx + '.jpg'; - console.log("New PICURL = " + iqset.iqdata[i].PICURL); + // console.log("New PICURL = " + iqset.iqdata[i].PICURL); // console.log(iqset.iqdata[i].PIC); } } @@ -432,7 +432,22 @@ exports.handleSendShowResultsPut = function(req, res) { message.RPERCENT = result.questionsCorrectPercentage; if (!game.resultsSaved) { console.log("About to store session"); - pdb.putSession(game.getAllSessionData(), function(err, result) { + + // + // Save out the image data too + // We ought to have a way to serve up images directly out of the DB keyed by the IQSet KEY and the question # + // but we don't have that yet, so just keep it silly + // + var sessiondata = game.getAllSessionData(); + var iqset = sessiondata.iqset; + for (var i = 0; i < iqset.length; i++) { + if (iqset[i].TYPE == "QUESTION_PIC") { + // iqset[i].PIC = (new Buffer(game.questions.getQuestionPicture(i), 'base64')).toJSON(); + iqset[i].PIC = game.questions.getQuestionPicture(i); + } + } + sessiondata.iqset = iqset; + pdb.putSession(sessiondata, function(err, result) { if (err) { // XXX TODO: Add in logger instead of console logging console.err(err); } else { diff --git a/static/js/smilestudent.js b/static/js/smilestudent.js index 68a5657..ead6309 100644 --- a/static/js/smilestudent.js +++ b/static/js/smilestudent.js @@ -969,7 +969,7 @@ function restoreLoginState() { // XXX This needs to clean up the sidebar area too // GlobalViewModel.doInquiryReset(); - + $('#submit-inquiry-area').show(); $('div#inquiry-form-area').unblock(); $('div#answer-form-area').unblock();