From 11c653beac60d1f9117682c017d024270349b5fd Mon Sep 17 00:00:00 2001 From: chrqls Date: Wed, 18 Jun 2014 11:32:45 +0200 Subject: [PATCH] [#39] Student detail --- lib/smile/game.js | 4 +- static/js/smileteacher.js | 88 +++++++++++++++++++++++++++++++++++++-- static/smile-teacher.html | 83 ++++++++++++++++++++++++++++++++---- 3 files changed, 162 insertions(+), 13 deletions(-) diff --git a/lib/smile/game.js b/lib/smile/game.js index 7034d51..79816f6 100644 --- a/lib/smile/game.js +++ b/lib/smile/game.js @@ -41,6 +41,8 @@ Game.prototype.setRatingMetadata = function setRatingMetadata(metadata) { } }; +/* OLD METHOD TO RETAKE. + NOT CALLED ANYMORE: TO DELETE SOON *//* Game.prototype.retake_dirty = function retake_dirty() { this.questionRatings = {}; @@ -75,7 +77,7 @@ Game.prototype.retake_dirty = function retake_dirty() { } } this.questions = new Questions(); -}; +};*/ /* When retaking, there is 2 things to manage: diff --git a/static/js/smileteacher.js b/static/js/smileteacher.js index 33cb252..ee0bc28 100644 --- a/static/js/smileteacher.js +++ b/static/js/smileteacher.js @@ -28,10 +28,10 @@ #SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **/ -var VERSION = '0.8.7'; +var VERSION = '0.8.9'; // Interval of time used to update the GlobalViewModel -var DELAY_UPDATE_BOARD = 5000; +var DELAY_UPDATE_BOARD = 3000; var DELAY_ERROR = 60000; var DELAY_SHORT = 9000; var DELAY_NORMAL = 18000;/* @@ -72,6 +72,7 @@ var Student = function(name,ip) { this.name = name; this.ip = ip; + this.questions = []; } var Question = function(sessionID,urlImage,author,question,answer,options,ip,type) { @@ -121,7 +122,10 @@ var GlobalViewModel = { questions: ko.observableArray([]), // Detail of a question - question_detail: ko.observableArray([]) + question_detail: ko.observableArray([]), + + // Detail of a student + student_detail: ko.observableArray([]) }; /* ------------------ @@ -404,6 +408,82 @@ GlobalViewModel.retake = function() { this.redirectView(); } +function detailStudent() { + + var selected = $('table#students tr.selected'); + + if(selected.length == 1) { + + var IP_studentToDetail = selected.find('td[smile=ip_of_student] input[type=hidden]').val(); + + // We remove the previous student detailed + GlobalViewModel.student_detail.removeAll(); + + // We get the /smile/all + var dataAll = JSON.parse(smile_all()); + + var studentToDetail = new Student('Unknown',IP_studentToDetail); + + for (i = 0; i < dataAll.length; i++) { + + if(dataAll[i].TYPE === 'HAIL' && dataAll[i].IP === IP_studentToDetail) { + studentToDetail.name = dataAll[i].NAME; + } + + // If the question is still in session, we load the details + if((dataAll[i].TYPE === 'QUESTION' || dataAll[i].TYPE === 'QUESTION_PIC') && dataAll[i].IP === IP_studentToDetail) { + + var options = []; + options.push( + dataAll[i].O1, + dataAll[i].O2, + dataAll[i].O3, + dataAll[i].O4 + ); + + var question = new Question( + dataAll[i].SessionID, + dataAll[i].PICURL, + dataAll[i].NAME, + dataAll[i].Q, + dataAll[i].A, + options, + dataAll[i].IP, + dataAll[i].TYPE + ); + + studentToDetail.questions.push(question); + } + } + + // console.log('studentToDetail='+JSON.stringify(studentToDetail)); + + GlobalViewModel.student_detail.push(studentToDetail); + + // We highlight the right answers + $('section[smile=student-detail] .question').each(function() { + + var answer = parseInt($(this).find('[type=hidden]').val()); + + var options = $(this).find('#options span'); + + $(this).find('#options span').each(function(index) { + + if(index+1 === answer) { + $(this).addClass('rightAnswer'); + } + }); + }); + + switchSection('student-detail'); + + } else if(selected.length > 1) { + absoluteAlert('Please select only one student', DELAY_SHORT,'red'); + } else { + absoluteAlert('Please select a student', DELAY_SHORT,'red'); + } +} + function detailQuestion(sessionID) { // We remove the previous question detailed to put the new one @@ -509,7 +589,7 @@ GlobalViewModel.removeQuestionFromSession = function() { } /* - TALK TO A STUDENT + TALK TO A STUDENT ? */ function showTalkForm() { $('#talkButton_with_form').removeClass('hidden'); diff --git a/static/smile-teacher.html b/static/smile-teacher.html index caf49c2..80576bd 100644 --- a/static/smile-teacher.html +++ b/static/smile-teacher.html @@ -123,8 +123,8 @@ section[smile=general-board] table#questions .percentSuccess_container { font-size: 20px; color: white; - font-weight:bold; - margin-right:15px; + font-weight: bold; + margin-right: 15px; width: 20px; text-align: right; } @@ -140,10 +140,10 @@ font-weight:bold; } section[smile=general-board] table#questions .percent_success { - text-shadow:0 0 4px #00a830; + text-shadow: 0 0 4px #00a830; } section[smile=general-board] table#questions .percent_fail { - text-shadow:0 0 4px #F00; + text-shadow: 0 0 4px #F00; } /* ------- @@ -154,6 +154,42 @@ min-height: 200px; } + section[smile=student-detail] #title-name { + display: inline-block; + padding: 2px 10px; + font-weight: bold; + border-radius: 10px 0 10px 0; + box-shadow: 0px 0px 0px 2px #333; + background-color: #666; + } + section[smile=student-detail] #title-ip { + display:inline-block; + padding:3px 6px; + font-size:9px; + border:1px solid #331833; + border-radius: 10px 10px 0 0; + background-color: #614f60; + } + + section[smile=student-detail] .question { + border: 1px dashed #999; + background-color: white; + margin: 5px 0; + padding: 10px; + font-family: Comic sans MS; + font-size: 70%; + } + section[smile=student-detail] .rightAnswer { + background-color: rgb(153, 255, 102); + padding: 0 5px 0 2px; + + box-shadow: 0px 0px 1px 1px rgba(153, 255, 102, 1); + /* Try to add those 2 lines if 'box-shadow' does not work on all browsers + -webkit-box-shadow: 0px 0px 1px 1px rgba(153, 255, 102, 1); + -moz-box-shadow: 0px 0px 1px 1px rgba(153, 255, 102, 1); + */ + } + .style_redRight { color: #D22; font-size: 12px; @@ -208,8 +244,8 @@
- - - - + ♦ +
@@ -321,9 +357,13 @@
-
- Talk +
+ Detail +
+
+ Talk
+