Skip to content
This repository was archived by the owner on Jun 7, 2023. It is now read-only.

Commit 955890c

Browse files
committed
Fix: Allow code blocks in parsons question
1 parent 8ed086a commit 955890c

3 files changed

Lines changed: 26 additions & 4 deletions

File tree

runestone/parsons/js/parsons.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export default class Parsons extends RunestoneBase {
5656
super(opts);
5757
var orig = opts.orig; // entire <pre> element that will be replaced by new HTML
5858
this.containerDiv = orig;
59-
this.origElem = $(orig).find("pre")[0];
59+
this.origElem = $(orig).find("pre.parsonsblocks")[0];
6060
// Find the question text and store it in .question
6161
this.question = $(orig).find(`.parsons_question`)[0];
6262
this.useRunestoneServices = opts.useRunestoneServices;

runestone/parsons/parsons.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ def setup(app):
3333

3434

3535
TEMPLATE_START = """
36-
<div class="%(divclass)s" style="max-width: none;">
36+
<div class="%(divclass)s" style="max-width: none;">
3737
<div data-component="parsons" id="%(divid)s" class="alert alert-warning parsons" >
3838
<div class="parsons_question parsons-text" >
3939
"""
4040

4141
TEMPLATE_END = """
4242
</div>
43-
<pre data-question_label="%(question_label)s" %(adaptive)s %(maxdist)s %(order)s %(noindent)s %(language)s %(numbered)s %(optional)s style="visibility: hidden;">
43+
<pre class="parsonsblocks" data-question_label="%(question_label)s" %(adaptive)s %(maxdist)s %(order)s %(noindent)s %(language)s %(numbered)s %(optional)s style="visibility: hidden;">
4444
%(code)s
4545
</pre>
4646
</div>

runestone/parsons/test/_sources/index.rst

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,26 @@ Section 2: Labeling
9090
=====
9191
return fib(num - 1) + fib(num - 2)
9292
=====
93-
return fib(num - 1) * fib(num - 2) #paired
93+
return fib(num - 1) * fib(num - 2) #paired
94+
95+
96+
.. parsonsprob:: test_parsons_5
97+
98+
Make a program that looks like this:
99+
100+
.. code-block:: python
101+
102+
sum = 0
103+
for i in range(10):
104+
sum = sum + i
105+
106+
print(sum)
107+
108+
-----
109+
sum = 0
110+
=====
111+
for i in range(10):
112+
sum = sum + i
113+
=====
114+
print(sum)
115+

0 commit comments

Comments
 (0)