@@ -47,17 +47,16 @@ def setup(app):
4747
4848
4949TEMPLATE_START = """
50- <div class="%(divclass)s" >
50+ <div>
5151<div data-component="activecode" id=%(divid)s data-question_label="%(question_label)s">
5252<div id=%(divid)s_question class="ac_question col-md-12">
5353"""
5454
5555TEMPLATE_END = """
5656</div>
57- <textarea data-lang="%(language)s" id="%(divid)s_editor" %(autorun)s
58- %(hidecode)s %(include)s %(timelimit)s %(coach)s %(codelens)s %(enabledownload)s %(chatcodes)s %(optional)s
59- data-audio='%(ctext)s' %(sourcefile)s %(datafile)s %(stdin)s %(tie)s %(dburl)s %(nopair)s
60- %(cargs)s %(largs)s %(rargs)s %(iargs)s %(gradebutton)s %(caption)s %(hidehistory)s %(wasmuri)s
57+ <textarea data-lang="%(language)s" id="%(divid)s_editor"
58+ %(optional)s
59+ %(dburl)s
6160 %(showlastsql)s style="visibility: hidden;">
6261%(initialcode)s
6362</textarea>
@@ -79,8 +78,6 @@ def visit_ac_node(self, node):
7978 # print self.settings.env.activecodecounter
8079
8180 # todo: handle above in node.runestone_options
82- # todo handle 'hidecode' not in node.runestone_options:
83- # todo: handle if 'gradebutton' in node.runestone_options: res += GRADES
8481
8582 node .delimiter = "_start__{}_" .format (node .runestone_options ["divid" ])
8683
@@ -116,31 +113,11 @@ def purge_activecodes(app, env, docname):
116113
117114
118115class HParsonsDirective (RunestoneIdDirective ):
116+ # only keep: language, autograde, dburl
119117 """
120118 .. activecode:: uniqueid
121- :nocanvas: -- do not create a canvas
122119 :autograde: unittest
123- :nopre: -- do not create an output component
124- :above: -- put the canvas above the code
125- :autorun: -- run this activecode as soon as the page is loaded
126- :caption: this is the caption
127- :include: div1,div2 -- invisibly include code from another activecode
128- :hidecode: -- Don't show the editor initially
129- :nocodelens: -- Do not show the codelens button
130- :timelimit: -- set the time limit for this program in seconds
131120 :language: python, html, javascript, java, python2, python3
132- :chatcodes: -- Enable users to talk about this code snippet with others
133- :tour_1: audio tour track
134- :tour_2: audio tour track
135- :tour_3: audio tour track
136- :tour_4: audio tour track
137- :tour_5: audio tour track
138- :stdin: : A file to simulate stdin (java, python2, python3)
139- :datafile: : A datafile for the program to read (java, python2, python3)
140- :sourcefile: : source files (java, python2, python3)
141- :available_files: : other additional files (java, python2, python3)
142- :enabledownload: -- allow textfield contents to be downloaded as *.py file
143- :nopair: -- disable pair programming features
144121 :dburl: url to load database for sql mode
145122 :showlastsql: -- Only show the last sql result in output
146123
@@ -158,7 +135,6 @@ class HParsonsDirective(RunestoneIdDirective):
158135
159136 - activecode_div_class - custom CSS class of the component's outermost div
160137 - activecode_hide_load_history - if True, hide the load history button
161- - wasm_uri - Path or Full URL to folder containing WASM files for SQL. /_static is default
162138 """
163139
164140 required_arguments = 1
@@ -167,35 +143,7 @@ class HParsonsDirective(RunestoneIdDirective):
167143 option_spec = RunestoneIdDirective .option_spec .copy ()
168144 option_spec .update (
169145 {
170- "nocanvas" : directives .flag ,
171- "nopre" : directives .flag ,
172- "above" : directives .flag , # put the canvas above the code
173- "autorun" : directives .flag ,
174- "caption" : directives .unchanged ,
175- "include" : directives .unchanged ,
176- "hidecode" : directives .flag ,
177146 "language" : directives .unchanged ,
178- "chatcodes" : directives .flag ,
179- "tour_1" : directives .unchanged ,
180- "tour_2" : directives .unchanged ,
181- "tour_3" : directives .unchanged ,
182- "tour_4" : directives .unchanged ,
183- "tour_5" : directives .unchanged ,
184- "nocodelens" : directives .flag ,
185- "coach" : directives .flag ,
186- "gradebutton" : directives .flag ,
187- "timelimit" : directives .unchanged ,
188- "stdin" : directives .unchanged ,
189- "datafile" : directives .unchanged ,
190- "sourcefile" : directives .unchanged ,
191- "available_files" : directives .unchanged ,
192- "enabledownload" : directives .flag ,
193- "compileargs" : directives .unchanged ,
194- "linkargs" : directives .unchanged ,
195- "interpreterargs" : directives .unchanged ,
196- "runargs" : directives .unchanged ,
197- "tie" : directives .unchanged ,
198- "nopair" : directives .flag ,
199147 "dburl" : directives .unchanged ,
200148 "showlastsql" : directives .flag ,
201149 }
@@ -233,118 +181,9 @@ def run(self):
233181 str3 = str2 .replace ("'" , "*singleq*" )
234182 self .options ["argu" ] = str3
235183
236- # TODO: This is BAD -- using '_' as a key for audio tour stuff is wrong.
237- complete = ""
238- no_of_buttons = 0
239- okeys = list (self .options .keys ())
240- for k in okeys :
241- if "tour_" in k :
242- x , label = k .split ("_" )
243- no_of_buttons = no_of_buttons + 1
244- complete = complete + self .options [k ] + "*atype*"
245-
246- newcomplete = complete .replace ('"' , "*doubleq*" )
247- self .options ["ctext" ] = newcomplete
248- self .options ["no_of_buttons" ] = no_of_buttons
249-
250- if "caption" not in self .options :
251- self .options ["caption" ] = ""
252- else :
253- self .options ["caption" ] = "data-caption='%s'" % self .options ["caption" ]
254-
255- if "include" not in self .options :
256- self .options ["include" ] = ""
257- else :
258- lst = self .options ["include" ].split ("," )
259- lst = [x .strip () for x in lst ]
260- self .options ["include" ] = 'data-include="' + " " .join (lst ) + '"'
261-
262- if "hidecode" in self .options :
263- self .options ["hidecode" ] = 'data-hidecode="true"'
264- else :
265- self .options ["hidecode" ] = ""
266-
267- if "enabledownload" in self .options :
268- self .options ["enabledownload" ] = 'data-enabledownload="true"'
269- else :
270- self .options ["enabledownload" ] = ""
271-
272- if "chatcodes" in self .options :
273- self .options ["chatcodes" ] = 'data-chatcodes="true"'
274- else :
275- self .options ["chatcodes" ] = ""
276-
277184 if "language" not in self .options :
278185 self .options ["language" ] = "python"
279186
280- if self .options ["language" ] == "html" :
281- self .options ["language" ] = "htmlmixed"
282- self .options ["initialcode" ] = escape (self .options ["initialcode" ])
283-
284- if "nocodelens" in self .options or self .options ["language" ] not in [
285- "python" ,
286- "java" ,
287- "c" ,
288- "cpp" ,
289- ]:
290- self .options ["codelens" ] = ""
291- else :
292- self .options ["codelens" ] = 'data-codelens="true"'
293-
294- if "nopair" in self .options :
295- self .options ["nopair" ] = 'data-nopair="true"'
296- else :
297- self .options ["nopair" ] = ""
298-
299- if "timelimit" not in self .options :
300- self .options ["timelimit" ] = "data-timelimit=25000"
301- else :
302- self .options ["timelimit" ] = "data-timelimit=%s" % self .options ["timelimit" ]
303-
304- if "autorun" not in self .options :
305- self .options ["autorun" ] = ""
306- else :
307- self .options ["autorun" ] = 'data-autorun="true"'
308-
309- if "coach" in self .options :
310- self .options ["coach" ] = 'data-coach="true"'
311- else :
312- self .options ["coach" ] = ""
313-
314- # livecode options
315- if "stdin" in self .options :
316- self .options ["stdin" ] = "data-stdin='%s'" % self .options ["stdin" ]
317- else :
318- self .options ["stdin" ] = ""
319-
320- if "datafile" not in self .options :
321- self .options ["datafile" ] = ""
322- else :
323- self .options ["datafile" ] = "data-datafile='%s'" % self .options ["datafile" ]
324-
325- if "sourcefile" not in self .options :
326- self .options ["sourcefile" ] = ""
327- else :
328- self .options ["sourcefile" ] = (
329- "data-sourcefile='%s'" % self .options ["sourcefile" ]
330- )
331-
332- if "tie" in self .options :
333- self .options ["tie" ] = "data-tie='{}'" .format (self .options ["tie" ])
334- else :
335- self .options ["tie" ] = ""
336-
337- for opt , tp in [
338- ("compileargs" , "cargs" ),
339- ("linkargs" , "largs" ),
340- ("runargs" , "rargs" ),
341- ("interpreterargs" , "iargs" ),
342- ]:
343- if opt in self .options :
344- self .options [tp ] = 'data-{}="{}"' .format (opt , escape (self .options [opt ]))
345- else :
346- self .options [tp ] = ""
347-
348187 # SQL Options
349188 if "dburl" in self .options :
350189 self .options ["dburl" ] = "data-dburl='{}'" .format (self .options ["dburl" ])
@@ -356,39 +195,6 @@ def run(self):
356195 else :
357196 self .options ["showlastsql" ] = ""
358197
359- # other options
360-
361- if "gradebutton" not in self .options :
362- self .options ["gradebutton" ] = ""
363- else :
364- self .options ["gradebutton" ] = "data-gradebutton=true"
365-
366- self .options ["divclass" ] = env .config .activecode_div_class
367- if env .config .activecode_hide_load_history :
368- self .options ["hidehistory" ] = "data-hidehistory=true"
369- else :
370- self .options ["hidehistory" ] = ""
371-
372- if env .config .wasm_uri :
373- self .options ["wasmuri" ] = f"data-wasm={ env .config .wasm_uri } "
374- else :
375- self .options ["wasmuri" ] = ""
376-
377- if self .content :
378- if "^^^^" in self .content :
379- idx = self .content .index ("^^^^" )
380- prefix = "\n " .join (self .content [:idx ])
381- if "====" in self .content :
382- idx = self .content .index ("====" )
383- source = "\n " .join (self .content [:idx ])
384- suffix = "\n " .join (self .content [idx + 1 :])
385- else :
386- source = "\n " .join (self .content )
387- suffix = "\n "
388- else :
389- source = "\n "
390- suffix = "\n "
391-
392198 course_name = env .config .html_context ["course_id" ]
393199 divid = self .options ["divid" ]
394200
@@ -409,8 +215,6 @@ def run(self):
409215 course_id = course_name ,
410216 main_code = source ,
411217 suffix_code = suffix ,
412- includes = self .options ["include" ],
413- available_files = self .options .get ("available_files" , "" ),
414218 )
415219 )
416220 else :
0 commit comments