2424from runestone .server .componentdb import (
2525 addQuestionToDB ,
2626 addHTMLToDB ,
27- get_engine_meta ,
2827 maybeAddToAssignment ,
2928)
3029from runestone .common .runestonedirective import (
@@ -129,6 +128,7 @@ class HParsonsDirective(RunestoneIdDirective):
129128
130129 def run (self ):
131130 super (HParsonsDirective , self ).run ()
131+ addQuestionToDB (self )
132132
133133 env = self .state .document .settings .env
134134
@@ -163,7 +163,6 @@ def run(self):
163163 source = "\n "
164164
165165 self .explain_text = explain_text or ["Not an Exercise" ]
166- addQuestionToDB (self )
167166
168167 self .options ["initialsetting" ] = source
169168
@@ -176,41 +175,6 @@ def run(self):
176175 course_name = env .config .html_context ["course_id" ]
177176 divid = self .options ["divid" ]
178177
179- engine , meta , sess = get_engine_meta ()
180-
181- if engine :
182- Source_code = Table (
183- "source_code" , meta , autoload = True , autoload_with = engine
184- )
185- engine .execute (
186- Source_code .delete ()
187- .where (Source_code .c .acid == divid )
188- .where (Source_code .c .course_id == course_name )
189- )
190- engine .execute (
191- Source_code .insert ().values (
192- acid = divid ,
193- course_id = course_name ,
194- main_code = source ,
195- suffix_code = suffix ,
196- )
197- )
198- else :
199- if (
200- not hasattr (env , "dberr_activecode_reported" )
201- or not env .dberr_activecode_reported
202- ):
203- env .dberr_activecode_reported = True
204- print (
205- "Unable to save to source_code table in activecode.py. Possible problems:"
206- )
207- print (" 1. dburl or course_id are not set in conf.py for your book" )
208- print (" 2. unable to connect to the database using dburl" )
209- print ("" )
210- print (
211- "This should only affect the grading interface. Everything else should be fine."
212- )
213-
214178 hpnode = HParsonsNode ()
215179 hpnode ["runestone_options" ] = self .options
216180 hpnode ["source" ], hpnode ["line" ] = self .state_machine .get_source_and_line (self .lineno )
0 commit comments