Commit 0efa75d6 by Sarina Canelake

i18n of common/lib/capa/capa files

Also pep8, pylint, and style fixes
Covers:
{capa_problem, correctmap, customerender,
inputtypes, responsetypes, util, xqueue_interface}.py
LMS-1744
parent 3584b246
......@@ -63,13 +63,13 @@ class CorrectMap(object):
return repr(self.cmap)
def get_dict(self):
'''
"""
return dict version of self
'''
"""
return self.cmap
def set_dict(self, correct_map):
'''
"""
Set internal dict of CorrectMap to provided correct_map dict
correct_map is saved by LMS as a plaintext JSON dump of the correctmap dict. This
......@@ -85,7 +85,7 @@ class CorrectMap(object):
Special migration case:
If correct_map is a one-level dict, then convert it to the new dict of dicts format.
'''
"""
# empty current dict
self.__init__()
......@@ -149,17 +149,17 @@ class CorrectMap(object):
return self.get_property(answer_id, 'hintmode', None)
def set_hint_and_mode(self, answer_id, hint, hintmode):
'''
"""
- hint : (string) HTML text for hint
- hintmode : (string) mode for hint display ('always' or 'on_request')
'''
"""
self.set_property(answer_id, 'hint', hint)
self.set_property(answer_id, 'hintmode', hintmode)
def update(self, other_cmap):
'''
"""
Update this CorrectMap with the contents of another CorrectMap
'''
"""
if not isinstance(other_cmap, CorrectMap):
raise Exception('CorrectMap.update called with invalid argument %s' % other_cmap)
self.cmap.update(other_cmap.get_dict())
......
......@@ -26,7 +26,7 @@ class MathRenderer(object):
tags = ['math']
def __init__(self, system, xml):
r'''
r"""
Render math using latex-like formatting.
Examples:
......@@ -37,7 +37,7 @@ class MathRenderer(object):
We convert these to [mathjax]...[/mathjax] and [mathjaxinline]...[/mathjaxinline]
TODO: use shorter tags (but this will require converting problem XML files!)
'''
"""
self.system = system
self.xml = xml
......@@ -79,13 +79,13 @@ registry.register(MathRenderer)
class SolutionRenderer(object):
'''
"""
A solution is just a <span>...</span> which is given an ID, that is used for displaying an
extended answer (a problem "solution") after "show answers" is pressed.
Note that the solution content is NOT rendered and returned in the HTML. It is obtained by an
ajax call.
'''
"""
tags = ['solution']
def __init__(self, system, xml):
......
......@@ -313,7 +313,7 @@ class FileSubmissionTest(unittest.TestCase):
'STATIC_URL': '/dummy-static/',
'id': 'prob_1_2',
'status': 'queued',
'msg': input_class.submitted_msg,
'msg': the_input.submitted_msg,
'value': 'BumbleBee.py',
'queue_len': '3',
'allowed_files': '["runme.py", "nooooo.rb", "ohai.java"]',
......@@ -362,7 +362,7 @@ class CodeInputTest(unittest.TestCase):
'id': 'prob_1_2',
'value': 'print "good evening"',
'status': 'queued',
'msg': input_class.submitted_msg,
'msg': the_input.submitted_msg,
'mode': mode,
'linenumbers': linenumbers,
'rows': rows,
......@@ -415,7 +415,7 @@ class MatlabTest(unittest.TestCase):
'id': 'prob_1_2',
'value': 'print "good evening"',
'status': 'queued',
'msg': self.input_class.submitted_msg,
'msg': self.the_input.submitted_msg,
'mode': self.mode,
'rows': self.rows,
'cols': self.cols,
......@@ -444,7 +444,7 @@ class MatlabTest(unittest.TestCase):
'id': 'prob_1_2',
'value': 'print "good evening"',
'status': 'queued',
'msg': self.input_class.submitted_msg,
'msg': the_input.submitted_msg,
'mode': self.mode,
'rows': self.rows,
'cols': self.cols,
......@@ -501,7 +501,7 @@ class MatlabTest(unittest.TestCase):
'id': 'prob_1_2',
'value': 'print "good evening"',
'status': 'queued',
'msg': self.input_class.plot_submitted_msg,
'msg': the_input.submitted_msg,
'mode': self.mode,
'rows': self.rows,
'cols': self.cols,
......
......@@ -1150,7 +1150,7 @@ class NumericalResponseTest(ResponseTest):
"""A fake gettext.Translations object."""
def ugettext(self, text):
"""Return the 'translation' of `text`."""
if text == "There was a problem with the staff answer to this problem":
if text == "There was a problem with the staff answer to this problem.":
text = "TRANSLATED!"
return text
problem.capa_system.i18n = FakeTranslations()
......
......@@ -8,10 +8,10 @@ default_tolerance = '0.001%'
def compare_with_tolerance(v1, v2, tol=default_tolerance):
'''
"""
Compare v1 to v2 with maximum tolerance tol.
tol is relative if it ends in %; otherwise, it is absolute
tol is relative if it ends in %; otherwise, it is absolute.
- v1 : student result (float complex number)
- v2 : instructor result (float complex number)
......@@ -26,7 +26,7 @@ def compare_with_tolerance(v1, v2, tol=default_tolerance):
Out[183]: -3.3881317890172014e-21
In [212]: 1.9e24 - 1.9*10**24
Out[212]: 268435456.0
'''
"""
relative = tol.endswith('%')
if relative:
tolerance_rel = evaluator(dict(), dict(), tol[:-1]) * 0.01
......@@ -46,8 +46,10 @@ def compare_with_tolerance(v1, v2, tol=default_tolerance):
def contextualize_text(text, context): # private
''' Takes a string with variables. E.g. $a+$b.
Does a substitution of those variables from the context '''
"""
Takes a string with variables. E.g. $a+$b.
Does a substitution of those variables from the context
"""
if not text:
return text
for key in sorted(context, lambda x, y: cmp(len(y), len(x))):
......@@ -66,10 +68,10 @@ def contextualize_text(text, context): # private
def convert_files_to_filenames(answers):
'''
"""
Check for File objects in the dict of submitted answers,
convert File objects to their filename (string)
'''
"""
new_answers = dict()
for answer_id in answers.keys():
answer = answers[answer_id]
......@@ -86,9 +88,9 @@ def is_list_of_files(files):
def is_file(file_to_test):
'''
"""
Duck typing to check if 'file_to_test' is a File object
'''
"""
return all(hasattr(file_to_test, method) for method in ['read', 'name'])
......
......@@ -12,9 +12,9 @@ dateformat = '%Y%m%d%H%M%S'
def make_hashkey(seed):
'''
"""
Generate a string key by hashing
'''
"""
h = hashlib.md5()
h.update(str(seed))
return h.hexdigest()
......@@ -57,9 +57,9 @@ def parse_xreply(xreply):
class XQueueInterface(object):
'''
"""
Interface to the external grading system
'''
"""
def __init__(self, url, django_auth, requests_auth=None):
self.url = url
......@@ -106,8 +106,10 @@ class XQueueInterface(object):
return self._http_post(self.url + '/xqueue/login/', payload)
def _send_to_queue(self, header, body, files_to_upload):
payload = {'xqueue_header': header,
'xqueue_body': body}
payload = {
'xqueue_header': header,
'xqueue_body': body
}
files = {}
if files_to_upload is not None:
for f in files_to_upload:
......
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