forked from maxdougherty/snap_autograder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathM2_W1_L1_T4_E1_2_3.html
268 lines (231 loc) · 12.7 KB
/
M2_W1_L1_T4_E1_2_3.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Snap! Build Your Own Blocks. Beta</title>
<link rel="shortcut icon" href="favicon.ico">
<script src="jschannel.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script type="text/javascript" src="underscore-min.js"></script>
<!--<script type="text/javascript" src='gradingLog.js'></script>-->
<script type="text/javascript" src='spriteEventLog.js'></script>
<script type="text/javascript" src='scriptAnalysis.js'></script>
<meta charset="utf-8">
<!-- Moved down to the bottom to have var id. -->
<script type="text/javascript" src="morphic.js"></script>
<script type="text/javascript" src="widgets.js"></script>
<script type="text/javascript" src="blocks.js"></script>
<script type="text/javascript" src="threads.js"></script>
<script type="text/javascript" src="objects.js"></script>
<script type="text/javascript" src="gui.js"></script>
<script type="text/javascript" src="paint.js"></script>
<script type="text/javascript" src="lists.js"></script>
<script type="text/javascript" src="byob.js"></script>
<script type="text/javascript" src="xml.js"></script>
<script type="text/javascript" src="store.js"></script>
<script type="text/javascript" src="locale.js"></script>
<script type="text/javascript" src="cloud.js"></script>
<script type="text/javascript" src="sha512.js"></script>
<script type="text/javascript" src="snap-edx-overrides.js"></script>
<link rel="stylesheet" type="text/css" href="AG_status_bar.css" />
<link rel="stylesheet" type="text/css" href="hintstyle.css" />
<script type="text/javascript" src="AGAgent.js"></script>
<script type="text/javascript" src='feedbackLog.js'></script>
<script type='text/javascript'>
var starter_path = null;
// The id is to act as a course identifier.
// NOTE: FOR NOW YOU ALSO HAVE TO ADD THE ID TO THE BOTTOM OF THE PAGE.
var courseID = "BJC.2x"; // e.g. "BJCx"
// Specify a prerequisite task id, should be null if no such requirement.
var preReqTaskID = null;
var preReqID = courseID + preReqTaskID;
// taskID uniquely identifies the task for saving in browser sessionStorage.
var taskID = "_M2_W1_L1_T4_E1_2_3";
var id = courseID + taskID;
var isEDX = isEDXurl();
// if this question is not meant to be graded, change this flag to false
var graded = true;
// to hide feedback for this problem, change this flag to false
var showFeedback = true;
// to allow for the ability to regrade certain tests, change this flag to true
var regradeOn = false;
// Add tests to the outputLog. Function is called by runAGTest(id, outputLog)
// var testLog;
function AGTest(outputLog) {
//NOTES TO YIFAT AND PATRICK:
// No IO tests should be isolated. Which means that you have to check that the block
// is on screen.
// All getter/setter functions inside anonymous Assert functions.
// Thanks for all your work :D
// var scriptExists = function() {
// var scriptSkeleton = '[{"blockSp":"clear","inputs":[]},{"blockSp":"pen down","inputs":[]},{"blockSp":"for each %upvar of %l %cs","inputs":["A",[{"blockSp":"glide %n secs to x: %n y: %n","inputs":["1","B","C"]}]]},{"blockSp":"glide %n secs to x: %n y: %n","inputs":["1","0","0"]},{"blockSp":"pen up","inputs":[]}]';
// var svars = ["A","B","C"];
// return scriptPresentInSprite(scriptSkeleton, 0, svars);
// }
var scriptMatches = function() {
var answer = '[{"blockSp":"clear","inputs":[]},{"blockSp":"pen down","inputs":[]},{"blockSp":"for each %upvar of %l %cs","inputs":["sdhsjdh",[{"blockSp":"glide %n secs to x: %n y: %n","inputs":["1",{"blockSp":"item %idx of %l","inputs":["1","item"]},{"blockSp":"item %idx of %l","inputs":["2","item"]}]}]]},{"blockSp":"glide %n secs to x: %n y: %n","inputs":["1","0","0"]},{"blockSp":"pen up","inputs":[]}]';
return scriptPresentInSprite(answer);
}
var fb = new FeedbackLog(null, id, 'this is a feedback log test', 0);
fb.snapWorld = world;
// Create a first test chunk
var first_chunk = fb.newChunk('Finish the script with the "for each" block by filling in the inputs to the "glide" block.');
// Add a first tip to that first test chunk
var first_tip = first_chunk.newTip('Make sure you fill in the inputs to the "glide" block properly.',
'Great job!');
var ass_test1 = first_tip.newAssertTest(
scriptMatches,
"Testing if the given script has been filled in correctly.",
"The given script has been filled in correctly.",
"Make sure you fill in the 'glide' block's inputs properly using the 'each' variable from the for-loop.",
1);
var drawShapeExists = function() {
if (findBlockInPalette("draw shape %") == null) {
return false;
}
return true;
}
var pointExists = function() {
if (findBlockInPalette("point % %") == null) {
return false;
}
return true;
}
var xcorExists = function() {
if (findBlockInPalette("X coordinate %") == null) {
return false;
}
return true;
}
var ycorExists = function() {
if (findBlockInPalette("Y coordinate %") == null) {
return false;
}
return true;
}
var drawShapeContainsAbstraction = function() {
return customBlockContains("draw shape %", "point % %") &&
customBlockContains("draw shape %", "X coordinate %") &&
customBlockContains("draw shape %", "Y coordinate %");
}
var second_chunk = fb.newChunk('Make the "draw shape %" block using data abstraction.');
var first_tip2 = second_chunk.newTip('Make the "draw shape %" block.',
'Great job!');
var ass_test1_2 = first_tip2.newAssertTest(
drawShapeExists,
"Testing if the 'draw shape %' block exists.",
"The 'draw shape %' block has been made.",
"Make sure you name your block exactly 'draw shape %' and place it in the scripting area.",
1);
var second_tip2 = second_chunk.newTip('Make the three blocks that demonstrate data abstraction.',
'Great job!');
var ass_test2_1 = second_tip2.newAssertTest(
pointExists,
"Testing if the 'point % %' block exists.",
"The 'point % %' block has been made.",
"Make sure you name your block exactly 'point % %' and place it in the scripting area.",
1);
var ass_test2_2 = second_tip2.newAssertTest(
xcorExists,
"Testing if the 'X coordinate %' block exists.",
"The 'X coordinate %' block has been made.",
"Make sure you name your block exactly 'X coordinate %' and place it in the scripting area.",
1);
var ass_test2_3 = second_tip2.newAssertTest(
ycorExists,
"Testing if the 'Y coordinate %' block exists.",
"The 'Y coordinate %' block has been made.",
"Make sure you name your block exactly 'Y coordinate %' and place it in the scripting area.",
1);
var third_tip2 = second_chunk.newTip('Make sure to use the data abstraction blocks in creating your "draw shape %" block.',
'Great job!');
var ass_test3_1 = third_tip2.newAssertTest(
drawShapeContainsAbstraction,
"Testing if the 'draw shape %' block contains data abstraction.",
"The 'draw shape %' block contains data abstraction.",
"Make sure your 'draw shape %' block uses all three data abstraction blocks.",
1);
return fb;
}
</script>
<script type="text/javascript" src='feedbackLog.js'></script>
<script type="text/javascript" src="AGFormatting.js"></script>
<script type="text/javascript">
var world;
window.onload = function () {
//INITIALIZE UP SNAP
world = new WorldMorph(document.getElementById('world'));
new IDE_Morph().openIn(world);
var ide = world.children[0];
//Reduce Stage Size on initialization
ide.toggleStageSize(true);
initializeSnapAdditions(world, id);
//AUTOGRADER ADDITION -
//Forced to use setTimeout() to let the world load before... Maybe not.
//Create a gradingLog and initialize the AG status bar (AGSB).
//Initialize AGSB button.
var grade_button = document.getElementById("autograding_button");
grade_button.addEventListener('click', button_listener);
var world_canvas = document.getElementById('world');
world_canvas.addEventListener("mouseup", update_listener);
// Start Snap Environment Loop
setInterval(loop, 1);
};
function loop() {
world.doOneCycle();
}
</script>
<script type="text/javascript" src='feedbackLog.js'></script>
<script type="text/javascript" src="AG_EDX.js"></script>
</head>
<body style="margin: 0;">
<canvas id="world" tabindex="1" style="position: absolute;" ></canvas>
<!-- Snap Autograding Button -->
<div id="autograding_bar">
<div tabindex="0" class="onclick-menu" id='onclick-menu' style="display:inline-block">
<span title="Menu">☰</span>
<div class='hover_darken'></div>
<nav id="navigation" class="site-navigation" role="navigation">
<ul id="dropdown-closed" class="bubble">
<!--<li class="menu-item-sub-menu" id="enabled-button"><a id="feedback-button">View Feedback</a></li>
<li class="menu-divider-sub-menu" id='menu-divider'></li>-->
<li class="menu-item-sub-menu" id="enabled-button"><a id="undo-button">Revert To Last Attempt</a></li>
<li class="menu-item-sub-menu" id="enabled-button"><a id="revert-button">Revert To Best Attempt</a></li>
<!--<li class="menu-item-sub-menu" id="enabled-button"><a id="last-submit">Revert To Last edX Submission</a></li>-->
<li class="menu-item-sub-menu" id="enabled-button"><a id="reset-button">Reset</a></li>
<li class="menu-divider-sub-menu" id='menu-divider'></li>
<li class="menu-item-sub-menu" id='enabled-button' onclick="openPopup();"><a id="help-button">Help</a></li>
</ul>
</nav>
</div>
<div id="autograding_button" style="display:inline-block;">
<span></span>
<div class='hover_darken'></div>
</div>
<div id="numtips" style="display:inline-block"></div>
</div>
<!-- Snap Autograding Menu -->
<!-- Autograding Menu Help Button -->
<div class="overlay is-hidden" id="overlay">
<p class="help-text" id="full-screen-arrow">↘</p>
<p class="help-text" id="full-screen-help">This full-screen button will pop out the Snap! window.</p>
<p class="help-text" id="menu-item-arrow">↗</p>
<p class="help-text" id="menu-item-help">The first two menu items will revert your current Snap! state to one of your previous attempts, depending on whether you wish to revert to your last graded attempt or to your best attempt.</br></br>The 'Reset' button will revert to a blank Snap! project, or to a provided starter file if one is given for this problem.</p>
<p class="help-text" id="ag-button-arrow">↑</p>
<p class="help-text" id="ag-button-help">Clicking this button will grade your current attempt and send the results to edX.</p>
</div>
<div style="display:inline-block" class="view-results" id="circle" onclick="openResults();">Results
</div>
<div class="overlay is-hidden" id="ag-output">
<div class="popup-content" id="ag-results">
<span class="button-close" onclick="closeResults();" id="popup">X</span>
<!--<p id = "different-feedback"></p>
<p id = "edx-submit-different"></p>-->
<div id="toggle-correct-tests"></div>
<p id="comment"></p>
</div>
</div>
</div>
<script type="text/javascript" src="AG_status_bar.js" />
</body>
</html>