Commit 32d8a6e9 by Victor Shnayder

Pass through course_id, location to openendedresponse

- set default queue in response type--don't use the default per-course one
parent 052807d7
...@@ -1730,9 +1730,9 @@ class ImageResponse(LoncapaResponse): ...@@ -1730,9 +1730,9 @@ class ImageResponse(LoncapaResponse):
Regions is list of lists [region1, region2, region3, ...] where regionN Regions is list of lists [region1, region2, region3, ...] where regionN
is disordered list of points: [[1,1], [100,100], [50,50], [20, 70]]. is disordered list of points: [[1,1], [100,100], [50,50], [20, 70]].
If there is only one region in the list, simpler notation can be used: If there is only one region in the list, simpler notation can be used:
regions="[[10,10], [30,30], [10, 30], [30, 10]]" (without explicitly regions="[[10,10], [30,30], [10, 30], [30, 10]]" (without explicitly
setting outer list) setting outer list)
Returns: Returns:
...@@ -1817,19 +1817,24 @@ class ImageResponse(LoncapaResponse): ...@@ -1817,19 +1817,24 @@ class ImageResponse(LoncapaResponse):
class OpenEndedResponse(LoncapaResponse): class OpenEndedResponse(LoncapaResponse):
""" """
Grade student open ended responses using an external queueing server, called 'xqueue' Grade student open ended responses using an external grading system,
accessed through the xqueue system.
Expects 'xqueue' dict in ModuleSystem with the following keys that are
needed by OpenEndedResponse:
Expects 'xqueue' dict in ModuleSystem with the following keys that are needed by OpenEndedResponse:
system.xqueue = { 'interface': XqueueInterface object, system.xqueue = { 'interface': XqueueInterface object,
'callback_url': Per-StudentModule callback URL 'callback_url': Per-StudentModule callback URL
where results are posted (string), where results are posted (string),
'default_queuename': Default queuename to submit request (string)
} }
External requests are only submitted for student submission grading External requests are only submitted for student submission grading
(i.e. and not for getting reference answers) (i.e. and not for getting reference answers)
By default, uses the OpenEndedResponse.DEFAULT_QUEUE queue.
""" """
DEFAULT_QUEUE = 'open-ended'
response_tag = 'openendedresponse' response_tag = 'openendedresponse'
allowed_inputfields = ['openendedinput'] allowed_inputfields = ['openendedinput']
max_inputfields = 1 max_inputfields = 1
...@@ -1841,7 +1846,7 @@ class OpenEndedResponse(LoncapaResponse): ...@@ -1841,7 +1846,7 @@ class OpenEndedResponse(LoncapaResponse):
xml = self.xml xml = self.xml
# TODO: XML can override external resource (grader/queue) URL # TODO: XML can override external resource (grader/queue) URL
self.url = xml.get('url', None) self.url = xml.get('url', None)
self.queue_name = xml.get('queuename', self.system.xqueue['default_queuename']) self.queue_name = xml.get('queuename', self.DEFAULT_QUEUE)
#Look for tag named openendedparam that encapsulates all grader settings #Look for tag named openendedparam that encapsulates all grader settings
oeparam = self.xml.find('openendedparam') oeparam = self.xml.find('openendedparam')
...@@ -1883,11 +1888,12 @@ class OpenEndedResponse(LoncapaResponse): ...@@ -1883,11 +1888,12 @@ class OpenEndedResponse(LoncapaResponse):
#Update grader payload with student id. If grader payload not json, error. #Update grader payload with student id. If grader payload not json, error.
try: try:
grader_payload=json.loads(grader_payload) grader_payload=json.loads(grader_payload)
location=self.system.ajax_url.split("://")[1] # NOTE: self.system.location is valid because the capa_module
org,course,type,name=location.split("/") # __init__ adds it (easiest way to get problem location into
# response types)
grader_payload.update({ grader_payload.update({
'location' : location, 'location' : self.system.location,
'course_id' : "{0}/{1}".format(org,course), 'course_id' : self.system.course_id,
'prompt' : prompt_string, 'prompt' : prompt_string,
'rubric' : rubric_string, 'rubric' : rubric_string,
}) })
...@@ -1997,7 +2003,6 @@ class OpenEndedResponse(LoncapaResponse): ...@@ -1997,7 +2003,6 @@ class OpenEndedResponse(LoncapaResponse):
msg='Invalid grader reply. Please contact the course staff.') msg='Invalid grader reply. Please contact the course staff.')
return oldcmap return oldcmap
correctness = 'correct' if correct else 'incorrect' correctness = 'correct' if correct else 'incorrect'
# TODO: Find out how this is used elsewhere, if any # TODO: Find out how this is used elsewhere, if any
......
...@@ -146,6 +146,11 @@ class CapaModule(XModule): ...@@ -146,6 +146,11 @@ class CapaModule(XModule):
else: else:
self.seed = None self.seed = None
# Need the problem location in openendedresponse to send out. Adding
# it to the system here seems like the least clunky way to get it
# there.
self.system.set('location', self.location)
try: try:
# TODO (vshnayder): move as much as possible of this work and error # TODO (vshnayder): move as much as possible of this work and error
# checking to descriptor load time # checking to descriptor load time
......
...@@ -809,7 +809,8 @@ class ModuleSystem(object): ...@@ -809,7 +809,8 @@ class ModuleSystem(object):
debug=False, debug=False,
xqueue=None, xqueue=None,
node_path="", node_path="",
anonymous_student_id=''): anonymous_student_id='',
course_id=None):
''' '''
Create a closure around the system environment. Create a closure around the system environment.
...@@ -844,6 +845,8 @@ class ModuleSystem(object): ...@@ -844,6 +845,8 @@ class ModuleSystem(object):
ajax results. ajax results.
anonymous_student_id - Used for tracking modules with student id anonymous_student_id - Used for tracking modules with student id
course_id - the course_id containing this module
''' '''
self.ajax_url = ajax_url self.ajax_url = ajax_url
self.xqueue = xqueue self.xqueue = xqueue
...@@ -856,6 +859,7 @@ class ModuleSystem(object): ...@@ -856,6 +859,7 @@ class ModuleSystem(object):
self.replace_urls = replace_urls self.replace_urls = replace_urls
self.node_path = node_path self.node_path = node_path
self.anonymous_student_id = anonymous_student_id self.anonymous_student_id = anonymous_student_id
self.course_id = course_id
self.user_is_staff = user is not None and user.is_staff self.user_is_staff = user is not None and user.is_staff
def get(self, attr): def get(self, attr):
......
...@@ -225,6 +225,7 @@ def _get_module(user, request, location, student_module_cache, course_id, positi ...@@ -225,6 +225,7 @@ def _get_module(user, request, location, student_module_cache, course_id, positi
replace_urls=replace_urls, replace_urls=replace_urls,
node_path=settings.NODE_PATH, node_path=settings.NODE_PATH,
anonymous_student_id=unique_id_for_user(user), anonymous_student_id=unique_id_for_user(user),
course_id=course_id,
) )
# pass position specified in URL to module through ModuleSystem # pass position specified in URL to module through ModuleSystem
system.set('position', position) system.set('position', position)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment