Skip to content

Commit

Permalink
refs #74, #101 Fix IQ PIC data save on session save. Also fix missing
Browse files Browse the repository at this point in the history
submit buttons on new session (after a session has completed)
  • Loading branch information
truedat101 committed Jan 30, 2014
1 parent f25281f commit 4a46dab
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
19 changes: 17 additions & 2 deletions routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion static/js/smilestudent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit 4a46dab

Please sign in to comment.