@@ -192,24 +192,14 @@ def _score_one_khanex(row, points, autograde):
192192
193193
194194def _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
195+ if autograde == "pct_correct" and "percent" in row and row .percent is not None :
196+ pct_correct = int (round (row .percent * 100 ))
208197 else :
209- if percent >= 99.99 :
198+ if row . correct :
210199 pct_correct = 100
211200 else :
212201 pct_correct = 0
202+
213203 return _score_from_pct_correct (pct_correct , points , autograde )
214204
215205
@@ -291,6 +281,30 @@ def _scorable_useinfos(
291281 )
292282
293283
284+ def _scorable_webwork_answers (
285+ course_name ,
286+ sid ,
287+ question_name ,
288+ points ,
289+ deadline ,
290+ practice_start_time = None ,
291+ db = None ,
292+ now = None ,
293+ ):
294+ query = (
295+ (db .webwork_answers .course_name == course_name )
296+ & (db .webwork_answers .sid == sid )
297+ & (db .webwork_answers .div_id == question_name )
298+ )
299+ if deadline :
300+ query = query & (db .webwork_answers .timestamp < deadline )
301+ if practice_start_time :
302+ query = query & (db .webwork_answers .timestamp >= practice_start_time )
303+ if now :
304+ query = query & (db .webwork_answers .timestamp <= now )
305+ return db (query ).select (orderby = db .webwork_answers .timestamp )
306+
307+
294308def _scorable_parsons_answers (
295309 course_name ,
296310 sid ,
@@ -681,7 +695,7 @@ def _autograde_one_q(
681695 logger .debug ("AGDB - done with khanex" )
682696 elif question_type == "webwork" :
683697 logger .debug ("grading a WebWork!!" )
684- results = _scorable_useinfos (
698+ results = _scorable_webwork_answers (
685699 course_name ,
686700 sid ,
687701 question_name ,
0 commit comments