Skip to content

Commit c96daaf

Browse files
committed
let's go for it, v1 :)
1 parent 115da97 commit c96daaf

2 files changed

Lines changed: 61 additions & 12 deletions

File tree

‎v3/js/opt-frontend-common.js‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,10 @@ function genericOptFrontendReady() {
887887
return; // get out early
888888
}
889889

890+
if (settings.url.indexOf('syntax_err_survey.py') > -1) {
891+
return; // get out early
892+
}
893+
890894
/*
891895
This jqxhr.responseText might be indicative of the URL being too
892896
long, since the error message returned by the server is something

‎v3/js/opt-frontend.js‎

Lines changed: 57 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ var helpQueueSize = 0;
5454
var tutorAvailable = false;
5555
var tutorWaitText = 'Please wait for the next available tutor.';
5656

57-
var activateSyntaxErrorSurvey = false; // true;
57+
var activateSyntaxErrorSurvey = true; // true;
5858

5959
function setHelpQueueSizeLabel() {
6060
if (helpQueueSize == 1) {
@@ -273,16 +273,26 @@ function experimentalPopUpSyntaxErrorSurvey() {
273273
// need to set both max-width and width() ...
274274
$(bub.qTipID()).css('max-width', '350px').width('350px');
275275

276-
$(bub.qTipContentID()).html('<div id="syntaxErrBubbleContents"><div id="syntaxErrHeader">You just fixed the following error:</div>\
277-
<div id="syntaxErrCodeDisplay"></div>\
278-
<div id="syntaxErrMsg"></div>\
279-
<div id="syntaxErrQuestion">\
280-
If you think this message wasn\'t helpful, what would have been the ideal error message for you here?<br/>\
281-
<input type="text" id="syntaxErrTxtInput" size=60 maxlength=150/><br/>\
282-
<button id="syntaxErrSubmitBtn" type="button">Submit</button>\
283-
<button id="syntaxErrCloseBtn" type="button">Close</button>\
284-
</div></div>\
285-
');
276+
var myUuid = supports_html5_storage() ? localStorage.getItem('opt_uuid') : '';
277+
278+
// Wording of the survey bubble:
279+
var version = 'v1'; // v1 - deployed on 2015-04-20
280+
281+
var surveyBubbleHTML = '<div id="syntaxErrBubbleContents">\
282+
<div id="syntaxErrHeader">You just fixed the following error:</div>\
283+
<div id="syntaxErrCodeDisplay"></div>\
284+
<div id="syntaxErrMsg"></div>\
285+
<div id="syntaxErrQuestion">\
286+
If you think this message wasn\'t helpful, what would have been the best error message for you here?<br/>\
287+
<input type="text" id="syntaxErrTxtInput" size=60 maxlength=150/><br/>\
288+
<button id="syntaxErrSubmitBtn" type="button">Submit</button>\
289+
<button id="syntaxErrCloseBtn" type="button">Close</button>\
290+
</div>\
291+
</div>'
292+
293+
294+
$(bub.qTipContentID()).html(surveyBubbleHTML);
295+
286296
// unbind first, then bind a new one
287297
myVisualizer.domRoot.find('#pyCodeOutputDiv')
288298
.unbind('scroll')
@@ -291,13 +301,37 @@ function experimentalPopUpSyntaxErrorSurvey() {
291301
});
292302

293303
$(bub.qTipContentID() + ' #syntaxErrSubmitBtn').click(function() {
294-
console.log("SUBMIT!");
304+
var res = $(bub.qTipContentID() + ' #syntaxErrTxtInput').val();
305+
var resObj = {appState: getAppState(),
306+
exc: prevExecutionExceptionObj, // note that prevExecutionExceptionObjLst is BLOWN AWAY by now
307+
opt_uuid: myUuid,
308+
reply: res,
309+
type: 'submit',
310+
v: version};
311+
312+
//console.log(resObj);
313+
$.get('syntax_err_survey.py', {arg: JSON.stringify(resObj)}, function(dat) {});
314+
315+
bub.destroyQTip();
295316
});
296317

297318
$(bub.qTipContentID() + ' #syntaxErrCloseBtn').click(function() {
319+
// grab the value anyways in case the learner wrote something decent ...
320+
var res = $(bub.qTipContentID() + ' #syntaxErrTxtInput').val();
321+
var resObj = {appState: getAppState(),
322+
exc: prevExecutionExceptionObj, // note that prevExecutionExceptionObjLst is BLOWN AWAY by now
323+
opt_uuid: myUuid,
324+
reply: res,
325+
type: 'close',
326+
v: version};
327+
328+
//console.log(resObj);
329+
$.get('syntax_err_survey.py', {arg: JSON.stringify(resObj)}, function(dat) {});
330+
298331
bub.destroyQTip();
299332
});
300333

334+
301335
var bubbleAceEditor = ace.edit('syntaxErrCodeDisplay');
302336
// set the size and value ASAP to get alignment working well ...
303337
bubbleAceEditor.setOptions({minLines: 1, maxLines: 5}); // keep this SMALL
@@ -354,6 +388,17 @@ function experimentalPopUpSyntaxErrorSurvey() {
354388
bub.redrawCodelineBubble(); // do an initial redraw to align everything
355389

356390
//globalBub = bub; // for debugging
391+
392+
// log an event whenever this bubble is show (i.e., an 'impression')
393+
// NB: it might actually be hidden if it appears on a line that
394+
// isn't initially visible to the user, but whatevers ...
395+
var impressionObj = {appState: getAppState(),
396+
exceptionLst: prevExecutionExceptionObjLst,
397+
opt_uuid: myUuid,
398+
type: 'show',
399+
v: version};
400+
//console.log(impressionObj);
401+
$.get('syntax_err_survey.py', {arg: JSON.stringify(impressionObj)}, function(dat) {});
357402
}
358403
}
359404
}

0 commit comments

Comments
 (0)