You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 7, 2023. It is now read-only.
@@ -75,11 +88,6 @@ class LP extends RunestoneBase {
75
88
// Keep track of it.
76
89
that.textAreas.push(editor);
77
90
});
78
-
// Handle clicks to the "Save and run" button.
79
-
$(this.element).click((eventObject)=>
80
-
that.onSaveAndRun(eventObject).then(null)
81
-
);
82
-
this.checkServer("lp_build",true);
83
91
}
84
92
85
93
// Data structures:
@@ -137,7 +145,7 @@ class LP extends RunestoneBase {
137
145
// Store the answer as a string, since this is what goes in to / comes out from the database. We have to translate this back to a data structure when restoring from the db or local storage.
@@ -213,17 +219,29 @@ class LP extends RunestoneBase {
213
219
214
220
// Store an array of strings in ``data.code_snippets`` into each textarea.
215
221
dataToTextareas(data){
216
-
// Find all code snippet textareas.
222
+
// For places where textareas aren't provided (instructor grading interface, assignment page), create them. However, these aren't runnable, so disable the "Save and run" button. Assume this is the case when there are no textareas. Reasoning: the page containing the problem contains code intended to be intermingled with the student's answer. If that's not present, we can't build.
223
+
if(!this.textAreas.length){
224
+
// The unusual case -- a problem not on its original page. Create textareas to display the code, then initialize them. Note that we can't simply create these in the constructor (which would be convenient) since we don't yet know how many code snippets are associated with the problem.
// Corner case TODO: if a problem is edited after students already submit code so that there are now fewer textareas, display these but don't save them when "Save and run" is pressed. This allows students to (hopefully) re-use code from now-discarded textareas.
221
239
}
222
240
223
241
// Restore answers from storage retrieval done in RunestoneBase.
224
242
restoreAnswers(data){
225
-
// We store the answer as a JSON-encoded string in the db / local storage. Restore the actual data structure from it.
226
-
data.answer=JSON.parse(data.answer);
243
+
// We store the answer as a JSON-encoded string in the db / local storage. Restore the actual data structure from it. Avoid exceptions if no data is available.
244
+
data.answer=JSON.parse(data.answer||"{}");
227
245
this.dataToTextareas(data);
228
246
this.displayAnswer(data);
229
247
}
@@ -249,7 +267,10 @@ class LP extends RunestoneBase {
Copy file name to clipboardExpand all lines: runestone/lp/lp.py
+1-5Lines changed: 1 addition & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -195,7 +195,7 @@ class _LpBuildButtonDirective(RunestoneIdDirective):
195
195
# No optional arguments.
196
196
optional_arguments=0
197
197
# Per http://docutils.sourceforge.net/docs/howto/rst-directives.html, True if content is allowed. However, this isn't checked or enforced.
198
-
has_content=True
198
+
has_content=False
199
199
# Options. Everything but language is currently ignored. This is based on activecode, so in the future similar support would be provided for these options.
0 commit comments