diff --git a/routes/index.js b/routes/index.js
index a01fba8..298de21 100644
--- a/routes/index.js
+++ b/routes/index.js
@@ -473,7 +473,9 @@ exports.handleSendShowResultsPut = function(req, res) {
});
}
game.setCurrentMessage(message);
- return res.sendText(HTTP_STATUS_OK, OK);
+
+ // We return all the messages to calculate the results
+ return res.sendJSON(HTTP_STATUS_OK, game.messages.past);
};
exports.handleCurrentSessionDataGet = function(req, res) {
diff --git a/static/js/smileteacher.js b/static/js/smileteacher.js
index e752389..b620586 100644
--- a/static/js/smileteacher.js
+++ b/static/js/smileteacher.js
@@ -28,7 +28,7 @@
#SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**/
-var VERSION = '0.8.3';
+var VERSION = '0.8.4';
// Interval of time used to update the GlobalViewModel
var DELAY_UPDATE_BOARD = 5000;
@@ -195,6 +195,7 @@ GlobalViewModel.redirectView = function() {
case 'START_SHOW':
$('.see_results').addClass('hidden');
$('.retake').removeClass('hidden');
+ calculateAndShowResults(dataAll);
break;
case 'QUESTION':
@@ -204,7 +205,6 @@ GlobalViewModel.redirectView = function() {
addStudent(dataAll[i]); break;
case 'ANSWER':
questionsAnsweredByStudent(dataAll[i].IP); break;
- default: break;
}
}
switchSection(section);
@@ -490,6 +490,10 @@ GlobalViewModel.removeQuestionFromSession = function() {
var amount = $(this).find('td[smile=number_of_questions] span');
amount.text(parseInt(amount.text())-1);
+ if(amount.text() === '0') {
+ amount.removeClass('sticker_positive');
+ amount.addClass('sticker_null');
+ }
}
});
}
@@ -562,7 +566,7 @@ GlobalViewModel.saveNewIQSet = function() {
"NAME":GlobalViewModel.questions()[i].author,
"Q":GlobalViewModel.questions()[i].question,
"A":GlobalViewModel.questions()[i].answer,
- "IP":GlobalViewModel.questions()[i].ip,
+ "IP":"No IP address",
"O4":GlobalViewModel.questions()[i].options[3],
"O3":GlobalViewModel.questions()[i].options[2],
"O2":GlobalViewModel.questions()[i].options[1],
@@ -656,6 +660,10 @@ function addQuestion(question) {
var amount = $(this).find('td[smile=number_of_questions] span');
amount.text(parseInt(amount.text())+1);
+ if(parseInt(amount.text()) > 0) {
+ amount.removeClass('sticker_null');
+ amount.addClass('sticker_positive');
+ }
}
});
}
@@ -746,8 +754,9 @@ function updateGVM() {
absoluteAlert('New question from '+dataAll[i].NAME+'!',DELAY_NORMAL);
}
break;
- case 'ANSWER':
- questionsAnsweredByStudent(dataAll[i].IP,true); break;
+ case 'ANSWER':
+ questionsAnsweredByStudent(dataAll[i].IP,true);
+ break;
}
}
@@ -784,6 +793,76 @@ function updateGVM() {
});
}
+function calculateAndShowResults(dataAll) {
+
+ // Getting /smile/all
+ //var dataAll = JSON.parse(smile_all());
+
+ // Variables to fill
+ var students_results = [];
+ var answers;
+ var size_Q;
+ var scores = [];
+ var best_score = 0;
+
+ // Extracting results
+ for(var i=0; i best_score) best_score = score.SCORE;
+ scores.push(score);
+ }
+
+ // Injecting scores into students table
+ $('table#students tr').each(function(index) {
+ for(var i=0; i%'
+
+ $(this).find('.score_container').html(html);
+ }
+ }
+ });
+}
+
+// Very useful to redirect views if a message already exists
function typeExist(type) {
var answer = false;
@@ -837,7 +916,7 @@ function postMessage(type,values) {
async: false,
error: function(xhr, text, err) {
- absoluteAlert('Unable to send START_MAKE phase', DELAY_NORMAL, 'trace');
+ absoluteAlert('Unable to send START_MAKE phase', DELAY_ERROR, 'trace', true);
},
success: function(data) {}
});
@@ -855,10 +934,10 @@ function postMessage(type,values) {
//async: false,
error: function(xhr, text, err) {
- absoluteAlert('Unable to send START_SOLVE phase', DELAY_NORMAL, 'trace');
+ absoluteAlert('Unable to send START_SOLVE phase', DELAY_ERROR, 'trace', true);
},
success: function(data) {
- absoluteAlert('START_SOLVE sent!', DELAY_NORMAL, 'green');
+ absoluteAlert('Your students can start answering questions.', DELAY_NORMAL, 'green');
}
});
break;
@@ -874,10 +953,11 @@ function postMessage(type,values) {
//async: false,
error: function(xhr, text, err) {
- absoluteAlert('Unable to send START_SHOW phase', DELAY_NORMAL, 'trace');
+ absoluteAlert('Unable to send START_SHOW phase', DELAY_ERROR, 'trace', true);
},
- success: function(data) {
- absoluteAlert('START_SHOW sent!', DELAY_NORMAL, 'green');
+ success: function(dataAll) {
+ absoluteAlert('Your students can see the results now!', DELAY_NORMAL, 'green');
+ calculateAndShowResults(dataAll);
}
});
break;
@@ -929,7 +1009,7 @@ function postMessage(type,values) {
},
success: function(data) {
absoluteAlert('New iqset "'+data.title+'" saved!',DELAY_NORMAL,'green');
- switchVisibilitySaveButton();
+ hideSaveForm();
}
});
break;
diff --git a/static/smile-student.html b/static/smile-student.html
index 37b36f8..f0ff3c2 100644
--- a/static/smile-student.html
+++ b/static/smile-student.html
@@ -296,11 +296,10 @@
-
- Rating:
-
+