Skip to content

Commit 03c27ef

Browse files
committed
more setup for "Start a shared session" mode
1 parent 7812d85 commit 03c27ef

File tree

9 files changed

+59
-24
lines changed

9 files changed

+59
-24
lines changed

v3/css/opt-frontend.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ table#pyOutputPane {
4242
}
4343

4444
#pyInputPane {
45-
margin-top: 20px;
45+
margin-top: 10px;
4646
margin-bottom: 20px;
4747

4848
max-width: 700px;

v3/js/opt-frontend.js

Lines changed: 46 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ var manualSharedSession = false; // XXX: this is uber-unreliable since
7171
// it's not set on page reload unless
7272
// there's a special url hash
7373

74+
var helpQueueSize = 0;
75+
var tutorAvailable = false;
76+
7477
// TODO: consider deferred initialization later: "TogetherJS starts up
7578
// automatically as soon as it can, especially when continuing a
7679
// session. Sometimes this is problematic, like an application that
@@ -82,7 +85,7 @@ var manualSharedSession = false; // XXX: this is uber-unreliable since
8285
var origDocURL = document.URL; // capture this ASAP before TogetherJS munges the URL
8386

8487
var tutorWaitText = 'Please wait for the next available tutor.';
85-
var informedConsentText = '<p/>During shared sessions, chat logs and code may be recorded and published for<br/>educational purposes. Please do not reveal any private or confidential information.';
88+
var informedConsentText = '<p>During shared sessions, chat logs and code may be recorded and published for<br/>educational purposes. Do not reveal any private or confidential information.</p>';
8689

8790
// nasty globals
8891
var updateOutputSignalFromRemote = false;
@@ -125,26 +128,47 @@ function syncAppState(appState) {
125128
}
126129
}
127130

128-
var TogetherJSConfig_getUserName = function () {
131+
/*
132+
var TogetherJSConfig_getUserName = function() {
129133
if (isTutor) {
130134
return 'Tutor';
131135
}
132136
else {
133137
return 'Learner';
134138
}
135139
}
140+
*/
136141

137142

138143
function getTutor() {
139144
manualSharedSession = false; // icky global!
145+
146+
$("#togetherjsStatus").html('<div style="font-size: 11pt;">Please wait for the next available tutor. <span id="helpQueueText"></span></div>');
147+
140148
TogetherJS();
141149
}
142150

143151
function startSharedSession() {
144152
manualSharedSession = true; // icky global!
153+
154+
$("#togetherjsStatus").html('<div style="font-size: 11pt;">\
155+
Copy and send this URL to let others join your session:\
156+
</div>\
157+
<input type="text" style="font-size:\
158+
12pt; font-weight: bold; padding: 5px;" id="togetherjsURL"\
159+
size="80" readonly="readonly"/>');
145160
TogetherJS();
146161
}
147162

163+
function setHelpQueueSizeLabel() {
164+
if (helpQueueSize == 1) {
165+
$("#helpQueueText").html('There is 1 person in line.');
166+
}
167+
else if (helpQueueSize == 0 || helpQueueSize > 1) {
168+
$("#helpQueueText").html('There are ' + dat.helpQueueUrls + ' people in line.');
169+
}
170+
}
171+
148172

149173
// get this app ready for TogetherJS
150174
function initTogetherJS() {
@@ -400,23 +424,23 @@ function initTogetherJS() {
400424
source.onmessage = function(e) {
401425
var dat = JSON.parse(e.data);
402426

403-
if (dat.helpAvailable && !TogetherJS.running) {
427+
// nasty globals
428+
helpQueueSize = dat.helpQueueUrls;
429+
tutorAvailable = dat.helpAvailable;
430+
431+
setHelpQueueSizeLabel();
432+
433+
if (tutorAvailable && !TogetherJS.running) {
404434
$("#getTutorBtn").fadeIn(750, redrawConnectors);
405435
}
406436
else {
407-
/* janky
408-
if (TogetherJS.running && !manualSharedSession) {
409-
alert("No more live tutors are available now.\nPlease check back later.");
410-
TogetherJS(); // toggle off
411-
}
412-
*/
413437
$("#getTutorBtn").fadeOut(750, redrawConnectors);
414438
}
415439
};
416440
}
417441
catch(err) {
418442
// ugh, SSE doesn't work in Safari when testing on localhost,
419-
// but I think it works when deployed on pythontutor.com
443+
// but I think it works when deployed on pythontutor.com (maybe?)
420444
console.warn("Sad ... EventSource not supported :(");
421445
}
422446

@@ -432,9 +456,7 @@ function initTogetherJS() {
432456
$("#surveyHeader").hide();
433457
$("#stopTogetherJSBtn").show();
434458

435-
$("#togetherjsStatus").html(informedConsentText).fadeIn(500);
436-
437-
//$("#getTutorBtn").fadeIn(750, redrawConnectors); // always show when ready
459+
$("#togetherjsStatus").append(informedConsentText).fadeIn(500);
438460

439461
if (isTutor) {
440462
$("#togetherjsStatus").html(origDocURL);
@@ -443,7 +465,10 @@ function initTogetherJS() {
443465
}
444466
else {
445467
if (manualSharedSession) {
446-
console.log('URL TO SHARE:', TogetherJS.shareUrl() + '&share=manual');
468+
// without anything after the '#' in the hash
469+
var cleanUrl = $.param.fragment(location.href, {}, 2 /* override */);
470+
var urlToShare = cleanUrl + 'togetherjs=' + TogetherJS.shareId();
471+
$("#togetherjsURL").val(urlToShare).attr('size', urlToShare.length + 15);
447472
}
448473
else {
449474
// if you're a learner, request help when TogetherJS is activated
@@ -455,6 +480,8 @@ function initTogetherJS() {
455480
// also log the learner's initial state when they first requested help
456481
TogetherJS.send({type: "initialAppState", myAppState: getAppState()});
457482
}
483+
484+
setHelpQueueSizeLabel();
458485
});
459486

460487
// emitted when TogetherJS is closed. This is not emitted when the
@@ -464,7 +491,11 @@ function initTogetherJS() {
464491
console.log("TogetherJS close");
465492

466493
$("#stopTogetherJSBtn,#togetherjsStatus").hide();
467-
$("#getTutorBtn,#sharedSessionBtn").show();
494+
$("#sharedSessionBtn").show();
495+
496+
if (tutorAvailable) {
497+
$("#getTutorBtn").show();
498+
}
468499

469500
if (appMode == "display") {
470501
$("#surveyHeader").show();

v3/js/togetherjs/togetherjs/interface.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@
176176
</div>
177177
-->
178178
<div id="togetherjs-chat-no-participants" data-toggles="#togetherjs-chat-participants">
179-
{{ gettext('Please wait for the next available tutor ...') }}
179+
{{ gettext('Nobody is here yet. Please wait ...') }}
180180
</div>
181181

182182
</section>

v3/js/togetherjs/togetherjs/templates-en-US.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

v3/js/togetherjs/togetherjs/templates-ru.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

v3/js/togetherjs/togetherjs/togetherjsPackage.js

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

v3/opt_togetherjs/server.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,10 @@ wsServer.on('request', function(request) {
363363
connectionStats[id].lastLeft = Date.now();
364364
}
365365
logger.debug('Peer ' + connection.remoteAddress + ' disconnected, ID: ' + connection.ID);
366+
367+
var logObj = createLogEntry(request, 'websocket-connection-closed');
368+
logObj.id = id;
369+
pgLogWrite(logObj);
366370
});
367371
});
368372

v3/screenshot-renderer/render-opt-screenshots.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ page.open(url, function () {
6060

6161
// hide extraneous components and resize
6262
page.evaluate(function() {
63-
$("#surveyHeader").hide();
63+
$("#experimentalHeader").hide();
6464
$("#footer").hide();
6565
$("#vizLayoutTdFirst").hide();
6666
$('#pyOutputPane').width($('table.visualizer').width());

v3/visualize.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,12 @@
113113

114114
<div>
115115
<button id="stopTogetherJSBtn" type="button" class="togetherjsBtn" style="display: none;">
116-
Stop live chat session
116+
Quit shared session
117117
</button>
118118
</div>
119119

120120
</td>
121-
<td valign="top" style="padding-left: 15px;">
121+
<td valign="top" style="padding-left: 25px;">
122122

123123
<div style="display: none;" id="togetherjsStatus"></div>
124124

0 commit comments

Comments
 (0)