Skip to content

Commit

Permalink
refs #39 Merge branch 'dev' of github.com:RazortoothRTC/node-smile-se…
Browse files Browse the repository at this point in the history
…rver into dev
  • Loading branch information
truedat101 committed Jun 12, 2014
2 parents 90567ca + d482411 commit 1acbed4
Show file tree
Hide file tree
Showing 6 changed files with 175 additions and 131 deletions.
2 changes: 1 addition & 1 deletion routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Binary file added static/images/smile_grey_student.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions static/js/smilestudent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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);
}
Expand Down
103 changes: 69 additions & 34 deletions static/js/smileteacher.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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('<b>'+td_name.find('input[type=hidden]').val()+'</b> finished answering!',DELAY_NORMAL);
}
});
}

GlobalViewModel.seeResults = function() {

$('.see_results').addClass('hidden');
Expand Down Expand Up @@ -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);
}
});
}
}
});

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

Expand Down Expand Up @@ -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) {

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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('<b>'+dataAll[i].NAME+'</b> appears!',DELAY_NORMAL);

}
if(!GVM_students.contains('"ip":"'+dataAll[i].IP+'"')) {
addStudent(dataAll[i]);
absoluteAlert('<b>'+dataAll[i].NAME+'</b> 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 <b>'+dataAll[i].NAME+'</b>!',DELAY_NORMAL);
}
if(!GVM_questions.contains('"session_id":"'+dataAll[i].SessionID+'"')) {
addQuestion(dataAll[i]);
absoluteAlert('New question from <b>'+dataAll[i].NAME+'</b>!',DELAY_NORMAL);
}
break;
case 'ANSWER':
questionsAnsweredByStudent(dataAll[i].IP,true); break;
}
}

Expand Down
56 changes: 22 additions & 34 deletions static/smile-student.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<body>

<!-- Absolute alert container-->
<div id="absolute_alerts" style="position:fixed;z-index: 10;border:1px dotted #CCC;top:80px;font-size:12px">
<div id="absolute_alerts" style="position:fixed;z-index: 10;border:0 dotted #BBB;top:80px;font-size:12px">
</div>

<div class="row">
Expand Down Expand Up @@ -399,68 +399,56 @@ <H3>Congrats. You got 5/10 correct.</h3>
</div>
</div>

<!-- THIS IS A DUPLICATE BLOCK, I COMMENT IT FOR A WHILE, BUT IT HAS TO BE REMOVED -->
<!--div class="container">
<!-- THIS PART IS USED WHEN THE STUDENT WANTS TO REVIEW THE DETAIL OF EACH QUESTION -->
<div class="container">

<div class="row">

<!--div id="iq-area" style="display: none">
<div id="iq-area" style="display: none">

<H3>Question <span data-bind="text: qidx() + 1"></span></H3>
<H4 class="subheader"><span data-bind="text: question"></span></H4>
<h3>Question <span data-bind="text: qidx() + 1"></span></h3>
<h4 class="subheader"><span data-bind="text: question"></span></h4>

<P><img data-bind="attr: { src: picurl }" /></P>
<p><img data-bind="attr: { src: picurl }" /></p>

<br>
<form>
<ul class="block-grid two-up">

<li>
<label>A)<span data-bind="text: a1">1998</span></label>
</li>
<li>
<li style="list-style-type: none">
<label for="a1">
<input disabled="true" data-bind="checked: answer" name="answer-options" type="radio" value="a1" id="a1">
Correct?
A/ <span data-bind="text: a1">SMILE_ERROR_CONTACT_ADMIN</span>
</label>
</li>
<li>
<label>B)<span data-bind="text: a2">1836</span></label>
</li>
<li>
<li style="list-style-type: none">
<label for="a2">
<input disabled="true" data-bind="checked: answer" name="answer-options" type="radio" value="a2" id="a2">
Correct?
B/ <span data-bind="text: a2">SMILE_ERROR_CONTACT_ADMIN</span>
</label>
</li>
<li>
<label>C)<span data-bind="text: a3">1812</span></label>
</li>
<li>
<li style="list-style-type: none">
<label for="a3">
<input disabled="true" data-bind="checked: answer" name="answer-options" type="radio" value="a3" id="a3">
Correct?
C/ <span data-bind="text: a3">SMILE_ERROR_CONTACT_ADMIN</span>
</label>
</li>
<li>
<label>D)<span data-bind="text: a4">1901</span></label>
</li>
<li>
<li style="list-style-type: none">
<label for="a4">
<input disabled="true" data-bind="checked: answer" name="answer-options" type="radio" value="a4" id="a4">
Correct?
D/ <span data-bind="text: a4">SMILE_ERROR_CONTACT_ADMIN</span>
</label>
</li>
</ul>
<p><em>Rating:</em><span data-bind="text: rating">5</span></p>
<p>
<em>Rating:</em>
<span data-bind="if: rating>4">Yes</span>
<span data-bind="if: rating<3">No</span>
<span data-bind="text: rating">5</span>
</p>
</form>
</div>
</div>
</div-->
</div>
<!-- Included JS Files -->

<!-- Included JS Files -->
Expand Down
Loading

0 comments on commit 1acbed4

Please sign in to comment.