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

Commit b6a468d

Browse files
committed
Add webwork support for assignments and autograder
1 parent 6aa6cfe commit b6a468d

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

controllers/admin.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
shortanswer=ALL_AUTOGRADE_OPTIONS,
5858
showeval=["interact"],
5959
video=["interact"],
60+
webwork=ALL_AUTOGRADE_OPTIONS,
6061
youtube=["interact"],
6162
)
6263

@@ -70,6 +71,7 @@
7071
"parsonsprob",
7172
"quizly",
7273
"selectquestion",
74+
"webwork",
7375
]
7476
)
7577

@@ -95,6 +97,7 @@
9597
shortanswer=ALL_WHICH_OPTIONS,
9698
showeval=ALL_WHICH_OPTIONS,
9799
video=[],
100+
webwork=ALL_WHICH_OPTIONS,
98101
youtube=[],
99102
)
100103

@@ -1890,6 +1893,7 @@ def _add_q_meta_info(qrow):
18901893
"fillintheblank": "FillB ✓",
18911894
"quizly": "Quizly ✓",
18921895
"khanex": "KhanAcademy ✓",
1896+
"webwork": "WebWork ✓",
18931897
}
18941898
qt = qt.get(qrow.questions.question_type, "")
18951899

@@ -1919,6 +1923,9 @@ def _add_q_meta_info(qrow):
19191923
requires_login=True,
19201924
)
19211925
def get_assignment():
1926+
"""
1927+
Called when ann assignment is chosed on the assignmentn builder page
1928+
"""
19221929
try:
19231930
assignment_id = int(request.vars.assignmentid)
19241931
except (TypeError, ValueError):

modules/rs_grading.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,28 @@ def _score_one_khanex(row, points, autograde):
191191
return _score_from_pct_correct(pct_correct, points, autograde)
192192

193193

194+
def _score_one_webwork(row, points, autograde):
195+
# row is from useinfo for now -- we may want to make a webwork_answers table later
196+
# the act field can be very convoluted but it willl end with: :correct:0:count:4:pct:0
197+
if "act" in row:
198+
parts = row.act.split(":")
199+
if parts[-2] == "pct":
200+
percent = float(parts[-1]) * 100
201+
else:
202+
logger.error("ACT field has no pct for a webwork problem")
203+
percent = None
204+
else:
205+
return 0.0
206+
if autograde == "pct_correct":
207+
pct_correct = percent
208+
else:
209+
if percent >= 99.99:
210+
pct_correct = 100
211+
else:
212+
pct_correct = 0
213+
return _score_from_pct_correct(pct_correct, points, autograde)
214+
215+
194216
def _scorable_mchoice_answers(
195217
course_name,
196218
sid,
@@ -657,6 +679,20 @@ def _autograde_one_q(
657679
)
658680
scoring_fn = _score_one_khanex
659681
logger.debug("AGDB - done with khanex")
682+
elif question_type == "webwork":
683+
logger.debug("grading a WebWork!!")
684+
results = _scorable_useinfos(
685+
course_name,
686+
sid,
687+
question_name,
688+
points,
689+
deadline,
690+
practice_start_time,
691+
db=db,
692+
now=now,
693+
)
694+
scoring_fn = _score_one_webwork
695+
logger.debug("AGDB - done with webwork")
660696

661697
elif question_type == "codelens":
662698
if (

views/_sphinx_static_files.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
<link rel="stylesheet" type="text/css" href="{{=URL('static', 'css/accessibility.css')}}" />
1111
<script src="{{=URL('static', 'js/jquery.js')}}"></script>
1212
<script src="{{=URL('static', 'js/jquery-fix.js')}}"></script>
13-
13+
<link href="https://webwork-ptx.aimath.org/webwork2_files/js/apps/MathView/mathview.css" rel="stylesheet">
14+
<script src="https://pretextbook.org/js/0.13/pretext-webwork/2.16/pretext-webwork.js"></script>
15+
<script src="https://webwork-ptx.aimath.org/webwork2_files/node_modules/iframe-resizer/js/iframeResizer.min.js"></script>
1416

1517
{{ import json
1618
from pathlib import Path

0 commit comments

Comments
 (0)