Skip to content

Commit

Permalink
[RazortoothRTC#39] Student detail
Browse files Browse the repository at this point in the history
  • Loading branch information
chrqls committed Jun 18, 2014
1 parent 5e66f6c commit 11c653b
Show file tree
Hide file tree
Showing 3 changed files with 162 additions and 13 deletions.
4 changes: 3 additions & 1 deletion lib/smile/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
Expand Down Expand Up @@ -75,7 +77,7 @@ Game.prototype.retake_dirty = function retake_dirty() {
}
}
this.questions = new Questions();
};
};*/

/*
When retaking, there is 2 things to manage:
Expand Down
88 changes: 84 additions & 4 deletions static/js/smileteacher.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;/*
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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([])
};

/* ------------------
Expand Down Expand Up @@ -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 <b>only</b> one student', DELAY_SHORT,'red');
} else {
absoluteAlert('Please <b>select</b> a student', DELAY_SHORT,'red');
}
}

function detailQuestion(sessionID) {

// We remove the previous question detailed to put the new one
Expand Down Expand Up @@ -509,7 +589,7 @@ GlobalViewModel.removeQuestionFromSession = function() {
}

/*
TALK TO A STUDENT
TALK TO A STUDENT ?
*/
function showTalkForm() {
$('#talkButton_with_form').removeClass('hidden');
Expand Down
83 changes: 75 additions & 8 deletions static/smile-teacher.html
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}

/* -------
Expand All @@ -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;
Expand Down Expand Up @@ -208,8 +244,8 @@

<div class="row" id="session_values" data-bind="if: teacher_name">
<span class="round label">
<span style="color:#fcf4ce" data-bind="text: teacher_name"></span> -
<span style="color:#fde6eb" data-bind="text: session_name"></span> -
<span style="color:#fcf4ce" data-bind="text: teacher_name"></span> &diams;
<span style="color:#fde6eb" data-bind="text: session_name"></span> &diams;
<span style="color:#e6f6fd" data-bind="text: group_name"></span>
</span>
</div>
Expand Down Expand Up @@ -321,9 +357,13 @@
<div class="large-12 columns" smile="talk-to-student">

<div id="talkButton_without_form" class="row">
<div class="small-2 columns" onclick="showTalkForm()">
<span class="zurb_labelAlone">Talk</span>
<div class="small-2 columns" onclick="detailStudent()" style="padding-right:0">
<span class="zurb_labelAlone">Detail</span>
</div>
<div class="small-2 end columns" onclick="showTalkForm()" style="padding-left:0">
<span class="postfix">Talk</span>
</div>

</div>

<div id="talkButton_with_form" class="row collapse hidden">
Expand Down Expand Up @@ -443,6 +483,33 @@ <h4><span data-bind="text: sessionName"></span></h4>
<a href="#" data-bind='click: usePreparedQuestions' class="expand secondary button">Back</a>
</section>

<section smile="student-detail" class="hidden">

<div data-bind="foreach: student_detail" >

<div style="margin-bottom:15px">
<div style="text-align:center;color:white;font-weight:bold">
<span id="title-ip" data-bind="text: ip"></span><br>
<span id="title-name" data-bind="text: name"></span>
</div>

<div data-bind="foreach: questions" >
<div class="question">
<div><span style="color:grey" data-bind="text: $data.question"></span></div>

<div id="options" data-bind="foreach: $data.options" >
<div style="margin:5px 0"><span style="margin:0" data-bind="text: $data"></span></div>
</div>
<input type="hidden" data-bind="attr: {value: $data.answer}" />
<div><img data-bind="attr:{src: urlImage}"></div>
</div>
</div>
</div>
</div>

<a href="#" data-bind='click: redirectView' class="secondary expand button">Back</a>
</section>

<section smile="question-detail" class="hidden">

<div data-bind="foreach: question_detail" >
Expand Down

0 comments on commit 11c653b

Please sign in to comment.