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

Commit 9b4c6b9

Browse files
authored
Merge pull request #1336 from amy21206/master
🐛 Fixing writing to database error in horizontal parsons.
2 parents e575c17 + c843348 commit 9b4c6b9

File tree

1 file changed

+1
-37
lines changed

1 file changed

+1
-37
lines changed

runestone/hparsons/hparsons.py

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
from runestone.server.componentdb import (
2525
addQuestionToDB,
2626
addHTMLToDB,
27-
get_engine_meta,
2827
maybeAddToAssignment,
2928
)
3029
from 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

Comments
 (0)