Merge pull request #1001 from MITx/feature/victor/inputtypes-refactor
Feature/victor/inputtypes refactor
This commit is contained in:
@@ -68,7 +68,7 @@ class CorrectMap(object):
|
||||
|
||||
correct_map is saved by LMS as a plaintext JSON dump of the correctmap dict. This
|
||||
means that when the definition of CorrectMap (e.g. its properties) are altered,
|
||||
an existing correct_map dict not coincide with the newest CorrectMap format as
|
||||
an existing correct_map dict will not coincide with the newest CorrectMap format as
|
||||
defined by self.set.
|
||||
|
||||
For graceful migration, feed the contents of each correct map to self.set, rather than
|
||||
|
||||
@@ -396,7 +396,7 @@ class FileSubmission(InputTypeBase):
|
||||
self.required_files = saxutils.escape(self.required_files, escapedict)
|
||||
|
||||
# Check if problem has been queued
|
||||
queue_len = 0
|
||||
self.queue_len = 0
|
||||
# Flag indicating that the problem has been queued, 'msg' is length of queue
|
||||
if self.status == 'incomplete':
|
||||
self.status = 'queued'
|
||||
|
||||
@@ -81,7 +81,7 @@ class LoncapaResponse(object):
|
||||
by __init__
|
||||
|
||||
- check_hint_condition : check to see if the student's answers satisfy a particular
|
||||
condition for a hint to be displayed
|
||||
condition for a hint to be displayed
|
||||
|
||||
- render_html : render this Response as HTML (must return XHTML-compliant string)
|
||||
- __unicode__ : unicode representation of this Response
|
||||
@@ -149,6 +149,7 @@ class LoncapaResponse(object):
|
||||
# for convenience
|
||||
self.answer_id = self.answer_ids[0]
|
||||
|
||||
# map input_id -> maxpoints
|
||||
self.maxpoints = dict()
|
||||
for inputfield in self.inputfields:
|
||||
# By default, each answerfield is worth 1 point
|
||||
@@ -280,17 +281,14 @@ class LoncapaResponse(object):
|
||||
(correctness, npoints, msg) for each answer_id.
|
||||
|
||||
Arguments:
|
||||
- student_answers : dict of (answer_id,answer) where answer = student input (string)
|
||||
|
||||
- old_cmap : previous CorrectMap (may be empty); useful for analyzing or
|
||||
recording history of responses
|
||||
- student_answers : dict of (answer_id, answer) where answer = student input (string)
|
||||
'''
|
||||
pass
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_answers(self):
|
||||
'''
|
||||
Return a dict of (answer_id,answer_text) for each answer for this question.
|
||||
Return a dict of (answer_id, answer_text) for each answer for this question.
|
||||
'''
|
||||
pass
|
||||
|
||||
|
||||
@@ -538,15 +538,9 @@ class CapaModule(XModule):
|
||||
lcp_id = self.lcp.problem_id
|
||||
correct_map = self.lcp.grade_answers(answers)
|
||||
except StudentInputError as inst:
|
||||
# TODO (vshnayder): why is this line here?
|
||||
#self.lcp = LoncapaProblem(self.definition['data'],
|
||||
# id=lcp_id, state=old_state, system=self.system)
|
||||
log.exception("StudentInputError in capa_module:problem_check")
|
||||
return {'success': inst.message}
|
||||
except Exception, err:
|
||||
# TODO: why is this line here?
|
||||
#self.lcp = LoncapaProblem(self.definition['data'],
|
||||
# id=lcp_id, state=old_state, system=self.system)
|
||||
if self.system.DEBUG:
|
||||
msg = "Error checking problem: " + str(err)
|
||||
msg += '\nTraceback:\n' + traceback.format_exc()
|
||||
|
||||
@@ -337,7 +337,7 @@ def xqueue_callback(request, course_id, userid, id, dispatch):
|
||||
'''
|
||||
# Test xqueue package, which we expect to be:
|
||||
# xpackage = {'xqueue_header': json.dumps({'lms_key':'secretkey',...}),
|
||||
# 'xqueue_body' : 'Message from grader}
|
||||
# 'xqueue_body' : 'Message from grader'}
|
||||
get = request.POST.copy()
|
||||
for key in ['xqueue_header', 'xqueue_body']:
|
||||
if not get.has_key(key):
|
||||
@@ -372,7 +372,8 @@ def xqueue_callback(request, course_id, userid, id, dispatch):
|
||||
# We go through the "AJAX" path
|
||||
# So far, the only dispatch from xqueue will be 'score_update'
|
||||
try:
|
||||
ajax_return = instance.handle_ajax(dispatch, get) # Can ignore the "ajax" return in 'xqueue_callback'
|
||||
# Can ignore the return value--not used for xqueue_callback
|
||||
instance.handle_ajax(dispatch, get)
|
||||
except:
|
||||
log.exception("error processing ajax call")
|
||||
raise
|
||||
@@ -386,12 +387,12 @@ def xqueue_callback(request, course_id, userid, id, dispatch):
|
||||
|
||||
#Bin score into range and increment stats
|
||||
score_bucket=get_score_bucket(instance_module.grade, instance_module.max_grade)
|
||||
org, course_num, run=course_id.split("/")
|
||||
org, course_num, run=course_id.split("/")
|
||||
statsd.increment("lms.courseware.question_answered",
|
||||
tags=["org:{0}".format(org),
|
||||
"course:{0}".format(course_num),
|
||||
"run:{0}".format(run),
|
||||
"score_bucket:{0}".format(score_bucket),
|
||||
"run:{0}".format(run),
|
||||
"score_bucket:{0}".format(score_bucket),
|
||||
"type:xqueue"])
|
||||
return HttpResponse("")
|
||||
|
||||
@@ -479,12 +480,12 @@ def modx_dispatch(request, dispatch, location, course_id):
|
||||
|
||||
#Bin score into range and increment stats
|
||||
score_bucket=get_score_bucket(instance_module.grade, instance_module.max_grade)
|
||||
org, course_num, run=course_id.split("/")
|
||||
org, course_num, run=course_id.split("/")
|
||||
statsd.increment("lms.courseware.question_answered",
|
||||
tags=["org:{0}".format(org),
|
||||
"course:{0}".format(course_num),
|
||||
"run:{0}".format(run),
|
||||
"score_bucket:{0}".format(score_bucket),
|
||||
"run:{0}".format(run),
|
||||
"score_bucket:{0}".format(score_bucket),
|
||||
"type:ajax"])
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user