Skip to content

Commit 240bd2a

Browse files
committed
added another set of survey stuff
1 parent 7e5927f commit 240bd2a

3 files changed

Lines changed: 48 additions & 4 deletions

File tree

‎v3/css/opt-frontend.css‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ button.bigBtn {
6868
margin-top: 6px;
6969
}
7070

71+
button.surveyBtn {
72+
font-size: 8pt;
73+
margin-top: 8px;
74+
}
75+
7176
#footer {
7277
color: #666666;
7378
font-size: 9pt;

‎v3/js/opt-frontend.js‎

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ $(document).ready(function() {
6666
setSurveyHTML();
6767

6868
$("#embedLinkDiv").hide();
69+
$("#surveyHeader").hide();
6970

7071
pyInputCodeMirror = CodeMirror(document.getElementById('codeInputPane'), {
7172
mode: 'python',
@@ -87,7 +88,7 @@ $(document).ready(function() {
8788

8889
if (appMode === undefined || appMode == 'edit') {
8990
$("#pyInputPane").show();
90-
$("#pyOutputPane").hide();
91+
$("#pyOutputPane,#surveyHeader").hide();
9192
$("#embedLinkDiv").hide();
9293

9394
$(".surveyQ").val(''); // clear all survey results when user hits forward/back
@@ -99,8 +100,7 @@ $(document).ready(function() {
99100
}
100101
else if (appMode == 'display' || appMode == 'visualize' /* 'visualize' is deprecated */) {
101102
$("#pyInputPane").hide();
102-
$("#pyOutputPane").show();
103-
103+
$("#pyOutputPane,#surveyHeader").show();
104104
$("#embedLinkDiv").show();
105105

106106
$('#executeBtn').html("Visualize Execution");
@@ -119,7 +119,7 @@ $(document).ready(function() {
119119
}
120120
else if (appMode == 'display_no_frills') {
121121
$("#pyInputPane").hide();
122-
$("#pyOutputPane").show();
122+
$("#pyOutputPane,#surveyHeader").show();
123123
$("#embedLinkDiv").show();
124124
}
125125
else {
@@ -619,5 +619,32 @@ $(document).ready(function() {
619619
var iframeStr = '<iframe width="800" height="500" frameborder="0" src="' + embedUrlStr + '"> </iframe>';
620620
$('#embedCodeOutput').val(iframeStr);
621621
});
622+
623+
624+
// for survey-related stuff
625+
$('.surveyBtn').click(function(e) {
626+
// wow, massive copy-and-paste action from above!
627+
var myArgs = {code: pyInputCodeMirror.getValue(),
628+
mode: appMode,
629+
cumulative: $('#cumulativeModeSelector').val(),
630+
heapPrimitives: $('#heapPrimitivesSelector').val(),
631+
drawParentPointers: $('#drawParentPointerSelector').val(),
632+
textReferences: $('#textualMemoryLabelsSelector').val(),
633+
showOnlyOutputs: $('#showOnlyOutputsSelector').val(),
634+
py: $('#pythonVersionSelector').val()};
635+
636+
if (appMode == 'display' || appMode == 'visualize' /* 'visualize' is deprecated */) {
637+
myArgs.curInstr = myVisualizer.curInstr;
638+
}
639+
640+
var buttonPrompt = $(this).html();
641+
var res = prompt('"' + buttonPrompt + '"' + ' Please elaborate:');
642+
// don't submit EMPTY results with no feedback or when Cancel button is pressed
643+
if (res) {
644+
myArgs.surveyQuestion = buttonPrompt;
645+
myArgs.surveyResponse = res;
646+
$.get('survey.py', myArgs, function(dat) {});
647+
}
648+
});
622649
});
623650

‎v3/visualize.html‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,18 @@
6868

6969
<body>
7070

71+
<div id="surveyHeader" style="margin-bottom: 10pt;">
72+
<div id="vizSurveyLabel" style="font-size: 8pt; color: #666;">
73+
Support our research by clicking a button when you see something interesting in the visualization.<br/>
74+
</div>
75+
<button class="surveyBtn" type="button">Eureka! Now I understand.</button>
76+
<button class="surveyBtn" type="button">I learned something new!</button>
77+
<button class="surveyBtn" type="button">I found the bug in my code!</button>
78+
<button class="surveyBtn" type="button">This looks confusing.</button>
79+
<button class="surveyBtn" type="button">I have another comment.</button>
80+
</div>
81+
82+
7183
<div id="pyInputPane">
7284

7385
Write your Python code here:

0 commit comments

Comments
 (0)