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

Commit 2a1a16d

Browse files
committed
Merge pull request #25 from RunestoneInteractive/master
getting up to date
2 parents 3a6ebad + 4b9535b commit 2a1a16d

File tree

17 files changed

+1746
-1497
lines changed

17 files changed

+1746
-1497
lines changed

runestone/activecode/textfield.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Copyright (C) 2011 Bradley N. Miller
2+
#
3+
# This program is free software: you can redistribute it and/or modify
4+
# it under the terms of the GNU General Public License as published by
5+
# the Free Software Foundation, either version 3 of the License, or
6+
# (at your option) any later version.
7+
#
8+
# This program is distributed in the hope that it will be useful,
9+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
# GNU General Public License for more details.
12+
#
13+
# You should have received a copy of the GNU General Public License
14+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
15+
#
16+
__author__ = 'bmiller'
17+
18+
from docutils import nodes
19+
from docutils.parsers.rst import directives
20+
from docutils.parsers.rst import Directive
21+
import json
22+
import random
23+
24+
# setup is called in activecode.py
25+
26+
27+
def textfield_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
28+
'''
29+
Usage:
30+
In your document you can write :textfield:`myid:myvalue:width`
31+
This will translate to:
32+
<input type='text' id='myid' class="form-control input-small" style="display:inline; width:width;" value='myvalue'></input>
33+
34+
where width can be specified in pixels or percentage of page width (standard CSS syntax).
35+
Width can also be specified using relative sizes:
36+
mini, small, medium, large, xlarge, and xxlarge
37+
'''
38+
iid, value, width = text.split(':')
39+
40+
if 'mini' in width:
41+
width = '60px'
42+
elif 'small' in width:
43+
width = '90px'
44+
elif 'medium' in width:
45+
width = '150px'
46+
elif 'large' in width:
47+
width = '210px'
48+
elif 'xlarge' in width:
49+
width = '270px'
50+
elif 'xxlarge' in width:
51+
width = '530px'
52+
53+
res = '''<input type='text' id='%s' class="form-control" style="display:inline; width: %s;" value="%s"></input>''' % (iid,width,value)
54+
55+
return [nodes.raw('',res, format='html')],[]

runestone/assess/.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*.woff2
2+
*.woff
3+
*.ttf
4+
*.eot
5+
*.svg
6+
7+
node_modules/
8+
bower_components/

runestone/assess/README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ Each 2 <code>li</code> answer/feedback pair represents a possible answer to the
2828
<li><code>id</code> must be unique in the document</li>
2929
<li><code>data-multipleanswers</code> REQUIRED Attribute. Possible values are true and false. Determines whether the question can take one or more answers on submission (radio vs checkbox).</li>
3030
<li><code>data-random</code> Randomizes the order that the possible answers are displayed on the page</li>
31-
<li><code>data-timed</code> Required if this MC question is inside of a timed assessment, will break things if not.</li>
3231
<br />
3332
<p>Attributes of the question tags</p>
3433
<br />
@@ -58,7 +57,7 @@ Each regex,text <code>span</code> pair represents a point of feedback for incorr
5857

5958
Multiple blanks can also be put into the same FITB question as shown here.
6059

61-
<p data-component="fillintheblank" data-casei="false" data-timed id="fill1412" >
60+
<p data-component="fillintheblank" data-casei="false" id="fill1412" >
6261

6362
<span data-blank>Give me a string that has an 'e' in it. Now.<span data-answer id="blank2_answer">e</span>
6463
<span data-feedback="regex" id="feedback1">f</span>
@@ -91,14 +90,13 @@ Multiple blanks can also be put into the same FITB question as shown here.
9190
<ul>
9291
<li><code>data-casei</code> Determines if the answer is case insensitive</li>
9392
<li><code>id</code> Must be unique in the document</li>
94-
<li><code>timed</code> Required for a FITB component inside of a timed assessment</li>
9593

9694
</ul>
9795

9896
<h2>Timed</h2>
9997

10098
<ul data-component="timedAssessment" data-time id="timed_1">
101-
<ul data-component="multiplechoice" data-multipleanswers="true" data-timed data-random id="question_1">
99+
<ul data-component="multiplechoice" data-multipleanswers="true" data-random id="question_1">
102100
The Question can go right here.
103101
<li data-component="answer" id="123" >Answer One</li>
104102
<li data-component="feedback" for="123">Feedback for One</li>
@@ -110,7 +108,7 @@ Multiple blanks can also be put into the same FITB question as shown here.
110108
<li data-component="feedback" for="789">Feedback for Three</li>
111109
</ul>
112110

113-
<ul data-component="multiplechoice" data-timed id="question_2">
111+
<ul data-component="multiplechoice" id="question_2">
114112
The Question can go right here.
115113
<li data-component="answer" id="123" >Answer One</li>
116114
<li data-component="feedback" for="123">Feedback for One</li>
@@ -122,7 +120,7 @@ Multiple blanks can also be put into the same FITB question as shown here.
122120
<li data-component="feedback" for="789">Feedback for Three</li>
123121
</ul>
124122

125-
<p data-component="fillintheblank" data-casei="false" data-timed id="fill1412" >
123+
<p data-component="fillintheblank" data-casei="false" id="fill1412" >
126124

127125
<span data-blank>Give me a string that has an 'e' in it. Now.<span data-answer id="blank2_answer">e</span>
128126

runestone/assess/assess.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@ def setup(app):
3636
app.add_directive('timed', TimedDirective)
3737

3838
app.add_stylesheet('fitb.css')
39-
app.add_javascript('assess.js')
39+
#app.add_javascript('assess.js')
40+
app.add_javascript('mchoice.js')
41+
app.add_javascript('timedmc.js')
42+
app.add_javascript('fitb.js')
43+
app.add_javascript('timedfitb.js')
44+
app.add_javascript('timed.js')
4045

4146
app.add_node(TimedNode, html=(visit_timed_node, depart_timed_node))
4247
app.add_node(MChoiceNode, html=(visit_mc_node, depart_mc_node))

runestone/assess/css/fitb.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.selectwidthauto {
2+
width:auto !important;
3+
display: inline-block !important;
4+
margin: 5px;
5+
}
6+
7+
input.input-validation-error {
8+
border: 1px solid #e80c4d;
9+
}

runestone/assess/fitb.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@ def visit_fitb_node(self,node):
4444
node.fitb_options['casei'] = 'true'
4545
else:
4646
node.fitb_options['casei'] = 'false'
47-
if 'timed' in node.fitb_options:
48-
node.fitb_options['timed'] = 'data-timed'
49-
else:
50-
node.fitb_options['timed'] = ''
5147
res = node.template_start % node.fitb_options
5248

5349
self.body.append(res)
@@ -66,7 +62,6 @@ class FillInTheBlank(Directive):
6662
final_argument_whitespace = True
6763
has_content = True
6864
option_spec = {'blankid':directives.unchanged,
69-
'timed':directives.flag,
7065
'iscode':directives.flag,
7166
'casei':directives.flag # case insensitive matching
7267
}
@@ -78,13 +73,12 @@ def run(self):
7873
:return:
7974
.. fillintheblank:: qname
8075
:iscode: boolean
81-
:timed: Flag that indicated this is part of a timed block
8276
:casei: Case insensitive boolean
8377
...
8478
"""
8579

8680
TEMPLATE_START = '''
87-
<p data-component="fillintheblank" data-casei="%(casei)s" id="%(divid)s" %(timed)s>
81+
<p data-component="fillintheblank" data-casei="%(casei)s" id="%(divid)s">
8882
'''
8983

9084
TEMPLATE_END = '''

0 commit comments

Comments
 (0)