diff --git a/routes/index.js b/routes/index.js index 9d577e8..a01fba8 100644 --- a/routes/index.js +++ b/routes/index.js @@ -844,7 +844,7 @@ exports.handleQuestionJSONDelete = function(req, res) { } } } - res.sendJSON(HTTP_STATUS_OK, {'status': status}); + res.sendJSON(HTTP_STATUS_OK, {'status': status,'IP':question.IP}); }; exports.handleQuestionImageGet = function(req, res) { diff --git a/static/images/smile_grey_student.png b/static/images/smile_grey_student.png new file mode 100644 index 0000000..db37609 Binary files /dev/null and b/static/images/smile_grey_student.png differ diff --git a/static/js/smilestudent.js b/static/js/smilestudent.js index de8d485..02bd2b4 100644 --- a/static/js/smilestudent.js +++ b/static/js/smilestudent.js @@ -363,7 +363,7 @@ GlobalViewModel.doAnswerNextQ = function() { // // Should we do something else? // - absoluteAlert('Submitted Answers for ' + GlobalViewModel.username(), DELAY_SHORT,'blue'); + absoluteAlert('Answers submitted!', DELAY_SHORT,'blue'); }); } /* if (self.validateInquiry()) { @@ -626,7 +626,7 @@ function doPostInquiry(inquirydata, cb) { absoluteAlert('Unable to post inquiry. Reason: ' + xhr.status + ':' + xhr.responseText + '. Please verify your connection or server status.', DELAY_ERROR,'trace'); }, success: function(data) { - absoluteAlert('Sent Inquiry Question', DELAY_NORMAL,'green'); + absoluteAlert('Question sent!', DELAY_NORMAL,'green'); if (cb) { cb(data); } diff --git a/static/js/smileteacher.js b/static/js/smileteacher.js index 19a9bb4..e752389 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.1'; +var VERSION = '0.8.3'; // Interval of time used to update the GlobalViewModel var DELAY_UPDATE_BOARD = 5000; @@ -75,7 +75,6 @@ var Student = function(name,ip) { var Question = function(sessionID,urlImage,author,question,answer,options,ip,type) { - //this.position = position; this.session_id = sessionID; this.urlImage = urlImage; this.author = author; @@ -199,8 +198,12 @@ GlobalViewModel.redirectView = function() { break; case 'QUESTION': - case 'QUESTION_PIC': addQuestion(dataAll[i]); break; - case 'HAIL': addStudent(dataAll[i]); break; + case 'QUESTION_PIC': + addQuestion(dataAll[i]); break; + case 'HAIL': + addStudent(dataAll[i]); break; + case 'ANSWER': + questionsAnsweredByStudent(dataAll[i].IP); break; default: break; } } @@ -368,6 +371,21 @@ GlobalViewModel.startSolvingQuestions = function() { this.redirectView(); } + +function questionsAnsweredByStudent(IP_student, withAbsoluteAlert) { + + $('table#students tr').each(function(index) { + + var td_name = $(this).find('td[smile=name_of_student]'); + var td_IP = $(this).find('td[smile=ip_of_student]'); + + if(td_IP.find('input[type=hidden]').val() === IP_student && !td_name.hasClass('answered')) { + td_name.addClass('answered'); + if(withAbsoluteAlert) absoluteAlert(''+td_name.find('input[type=hidden]').val()+' finished answering!',DELAY_NORMAL); + } + }); +} + GlobalViewModel.seeResults = function() { $('.see_results').addClass('hidden'); @@ -460,11 +478,23 @@ GlobalViewModel.removeQuestionFromSession = function() { absoluteAlert('Unable to remove question from session', DELAY_ERROR, 'trace'); }, success: function(data) { - absoluteAlert('Question deleted', DELAY_NORMAL, 'green'); + absoluteAlert('Question of student deleted!', DELAY_NORMAL, 'green'); switchSection('general-board'); + + // Decrementing number of questions of a student (if the question does not come from an iqset) + if(GlobalViewModel.students().length) { + + $('table#students tr').each(function(index) { + + if($(this).find('td[smile=ip_of_student] input[type=hidden]').val() === data.IP) { + + var amount = $(this).find('td[smile=number_of_questions] span'); + amount.text(parseInt(amount.text())-1); + } + }); + } } }); - } } } @@ -492,12 +522,12 @@ GlobalViewModel.talkToStudent = function() { message['TYPE'] = 'TEACHER'; message.TEXT = GlobalViewModel.message_for_student(); - message.IP = $(this).find('input[type=hidden]').val(); + message.IP = $(this).find('td[smile=ip_of_student] input[type=hidden]').val(); postMessage('talk',JSON.stringify(message)); }); } else { - absoluteAlert('Please select a student', DELAY_SHORT,'red'); + absoluteAlert('Please select a student', DELAY_SHORT,'red'); } } @@ -556,17 +586,6 @@ GlobalViewModel.saveNewIQSet = function() { (encapsulation of code used by the actions) -------------------------------------------------------- */ -/* -GlobalViewModel.seeContent = function() { - - var content = ''; - - $('table#questions tr.checked').each(function( index ) { - content += $(this).find('input[type=hidden]').attr('name')+'|'; - }); - - absoluteAlert('checked:'+content,10000); -}*/ function absoluteAlert(text, lifetime, alerttype, hasCross) { @@ -627,14 +646,29 @@ function addQuestion(question) { question.IP, question.TYPE )); + + // Incrementing number of questions of a student (if the question does not come from an iqset) + if(GlobalViewModel.students().length) { + + $('table#students tr').each(function(index) { + + if($(this).find('td[smile=ip_of_student] input[type=hidden]').val() === question.IP) { + + var amount = $(this).find('td[smile=number_of_questions] span'); + amount.text(parseInt(amount.text())+1); + } + }); + } } + function addStudent(student) { GlobalViewModel.students.push( new Student( student.NAME, student.IP - )); + ) + ); } // To recap, each time this function is called, it updates students, questions, and session values @@ -691,28 +725,29 @@ function updateGVM() { break; case 'SESSION_VALUES': - if(dataAll[i].teacherName !== GlobalViewModel.teacher_name()) { - GlobalViewModel.teacher_name(dataAll[i].teacherName); - GlobalViewModel.session_name(dataAll[i].sessionName); - GlobalViewModel.group_name(dataAll[i].groupName); - } + if(dataAll[i].teacherName !== GlobalViewModel.teacher_name()) { + GlobalViewModel.teacher_name(dataAll[i].teacherName); + GlobalViewModel.session_name(dataAll[i].sessionName); + GlobalViewModel.group_name(dataAll[i].groupName); + } break; case 'HAIL': - if(!GVM_students.contains('"ip":"'+dataAll[i].IP+'"')) { - addStudent(dataAll[i]); - absoluteAlert(''+dataAll[i].NAME+' appears!',DELAY_NORMAL); - - } + if(!GVM_students.contains('"ip":"'+dataAll[i].IP+'"')) { + addStudent(dataAll[i]); + absoluteAlert(''+dataAll[i].NAME+' appears!',DELAY_NORMAL); + } break; case 'QUESTION': case 'QUESTION_PIC': - if(!GVM_questions.contains('"session_id":"'+dataAll[i].SessionID+'"')) { - addQuestion(dataAll[i]); - absoluteAlert('New question from '+dataAll[i].NAME+'!',DELAY_NORMAL); - } + if(!GVM_questions.contains('"session_id":"'+dataAll[i].SessionID+'"')) { + addQuestion(dataAll[i]); + absoluteAlert('New question from '+dataAll[i].NAME+'!',DELAY_NORMAL); + } break; + case 'ANSWER': + questionsAnsweredByStudent(dataAll[i].IP,true); break; } } diff --git a/static/smile-student.html b/static/smile-student.html index d9ed684..37b36f8 100644 --- a/static/smile-student.html +++ b/static/smile-student.html @@ -40,7 +40,7 @@
-