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

Commit eed9d3b

Browse files
committed
support webwork_answers table
1 parent fff50bb commit eed9d3b

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

bookserver/crud.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
"shortanswer": "shortanswer_answers",
9191
"unittest": "unittest_answers",
9292
"timedExam": "timed_exam",
93+
"webwork": "webwork_answers",
9394
}
9495

9596

bookserver/models.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
String,
4242
Date,
4343
DateTime,
44+
JSON,
4445
Text,
4546
types,
4647
Float,
@@ -286,6 +287,14 @@ class UnittestAnswers(Base, CorrectAnswerMixin):
286287

287288
UnittestAnswersValidation = sqlalchemy_to_pydantic(UnittestAnswers)
288289

290+
# An answer to a fill-in-the-blank question.
291+
@register_answer_table
292+
class WebWorkAnswers(Base, CorrectAnswerMixin):
293+
__tablename__ = "webwork_answers"
294+
# See answer_. TODO: what is the format?
295+
answer = Column(JSON, nullable=False)
296+
__table_args__ = (Index("idx_div_sid_course_ww", "sid", "div_id", "course_name"),)
297+
289298

290299
@register_answer_table
291300
class LpAnswers(Base, AnswerMixin):

bookserver/routers/rslogging.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ async def log_book_event(
149149
entry.incorrect = 0
150150
entry.skipped = 0
151151
entry.time_taken = 0
152+
elif entry.event == "webwork":
153+
entry.answer = json.loads(useinfo_dict["answer"])
152154

153155
valid_table = rcd.validator.from_orm(entry) # type: ignore
154156
# Do server-side grading if needed.

0 commit comments

Comments
 (0)