From 516b720f1e393a04443e37fea844d53134a8697c Mon Sep 17 00:00:00 2001 From: Victor Shnayder Date: Mon, 29 Oct 2012 08:05:07 -0400 Subject: [PATCH] Rename: use 'status' in templates as well as in the code. --- common/lib/capa/capa/inputtypes.py | 22 ++++++++----------- .../lib/capa/capa/templates/choicegroup.html | 8 +++---- common/lib/capa/capa/templates/codeinput.html | 10 ++++----- .../capa/capa/templates/crystallography.html | 18 +++++++-------- .../capa/capa/templates/filesubmission.html | 10 ++++----- .../lib/capa/capa/templates/imageinput.html | 8 +++---- .../lib/capa/capa/templates/jstextline.html | 8 +++---- .../lib/capa/capa/templates/optioninput.html | 8 +++---- .../capa/capa/templates/schematicinput.html | 8 +++---- common/lib/capa/capa/templates/textline.html | 18 +++++++-------- .../lib/capa/capa/templates/vsepr_input.html | 18 +++++++-------- common/lib/capa/capa/tests/test_inputtypes.py | 19 ++++++++-------- 12 files changed, 75 insertions(+), 80 deletions(-) diff --git a/common/lib/capa/capa/inputtypes.py b/common/lib/capa/capa/inputtypes.py index 26e2de8fa4..e2d7708ee3 100644 --- a/common/lib/capa/capa/inputtypes.py +++ b/common/lib/capa/capa/inputtypes.py @@ -21,10 +21,6 @@ Each input type takes the xml tree as 'element', the previous answer as 'value', graded status as'status' """ -# TODO: rename "state" to "status" for all below. status is currently the answer for the -# problem ID for the input element, but it will turn into a dict containing both the -# answer and any associated message for the problem ID for the input element. - # TODO: there is a lot of repetitive "grab these elements from xml attributes, with these defaults, # put them in the context" code. Refactor so class just specifies required and optional attrs (with # defaults for latter), and InputTypeBase does the right thing. @@ -177,7 +173,7 @@ class OptionInput(InputTypeBase): context = { 'id': self.id, 'value': self.value, - 'state': self.status, + 'status': self.status, 'msg': self.msg, 'options': self.osetdict, 'inline': self.xml.get('inline',''), @@ -236,7 +232,7 @@ class ChoiceGroup(InputTypeBase): def _get_render_context(self): context = {'id': self.id, 'value': self.value, - 'state': self.status, + 'status': self.status, 'input_type': self.element_type, 'choices': self.choices, 'name_array_suffix': self.suffix} @@ -362,7 +358,7 @@ class TextLine(InputTypeBase): context = {'id': self.id, 'value': value, - 'state': self.status, + 'status': self.status, 'size': self.size, 'msg': self.msg, 'hidden': self.hidden, @@ -403,7 +399,7 @@ class FileSubmission(InputTypeBase): def _get_render_context(self): context = {'id': self.id, - 'state': self.status, + 'status': self.status, 'msg': self.msg, 'value': self.value, 'queue_len': self.queue_len, @@ -455,7 +451,7 @@ class CodeInput(InputTypeBase): context = {'id': self.id, 'value': self.value, - 'state': self.status, + 'status': self.status, 'msg': self.msg, 'mode': self.mode, 'linenumbers': self.linenumbers, @@ -492,7 +488,7 @@ class Schematic(InputTypeBase): context = {'id': self.id, 'value': self.value, 'initial_value': self.initial_value, - 'state': self.status, + 'status': self.status, 'width': self.width, 'height': self.height, 'parts': self.parts, @@ -542,7 +538,7 @@ class ImageInput(InputTypeBase): 'src': self.src, 'gx': self.gx, 'gy': self.gy, - 'state': self.status, # to change (VS: to what??) + 'status': self.status, # to change (VS: to what??) 'msg': self.msg, # to change } return context @@ -577,7 +573,7 @@ class Crystallography(InputTypeBase): def _get_render_context(self): context = {'id': self.id, 'value': self.value, - 'state': self.status, + 'status': self.status, 'size': self.size, 'msg': self.msg, 'hidden': self.hidden, @@ -614,7 +610,7 @@ class VseprInput(InputTypeBase): context = {'id': self.id, 'value': self.value, - 'state': self.status, + 'status': self.status, 'msg': self.msg, 'width': self.width, 'height': self.height, diff --git a/common/lib/capa/capa/templates/choicegroup.html b/common/lib/capa/capa/templates/choicegroup.html index ce1b6d9476..457d9e7817 100644 --- a/common/lib/capa/capa/templates/choicegroup.html +++ b/common/lib/capa/capa/templates/choicegroup.html @@ -1,12 +1,12 @@
- % if state == 'unsubmitted': + % if status == 'unsubmitted': - % elif state == 'correct': + % elif status == 'correct': - % elif state == 'incorrect': + % elif status == 'incorrect': - % elif state == 'incomplete': + % elif status == 'incomplete': % endif
diff --git a/common/lib/capa/capa/templates/codeinput.html b/common/lib/capa/capa/templates/codeinput.html index 6e44712d9f..5c2ff2aca5 100644 --- a/common/lib/capa/capa/templates/codeinput.html +++ b/common/lib/capa/capa/templates/codeinput.html @@ -6,13 +6,13 @@ >${value|h}
- % if state == 'unsubmitted': + % if status == 'unsubmitted': Unanswered - % elif state == 'correct': + % elif status == 'correct': Correct - % elif state == 'incorrect': + % elif status == 'incorrect': Incorrect - % elif state == 'queued': + % elif status == 'queued': Queued % endif @@ -21,7 +21,7 @@
% endif -

${state}

+

${status}

diff --git a/common/lib/capa/capa/templates/crystallography.html b/common/lib/capa/capa/templates/crystallography.html index ee9b249d3d..f46e2f753a 100644 --- a/common/lib/capa/capa/templates/crystallography.html +++ b/common/lib/capa/capa/templates/crystallography.html @@ -6,13 +6,13 @@
- % if state == 'unsubmitted': + % if status == 'unsubmitted':
- % elif state == 'correct': + % elif status == 'correct':
- % elif state == 'incorrect': + % elif status == 'incorrect':
- % elif state == 'incomplete': + % elif status == 'incomplete':
% endif % if hidden: @@ -29,13 +29,13 @@ />

- % if state == 'unsubmitted': + % if status == 'unsubmitted': unanswered - % elif state == 'correct': + % elif status == 'correct': correct - % elif state == 'incorrect': + % elif status == 'incorrect': incorrect - % elif state == 'incomplete': + % elif status == 'incomplete': incomplete % endif

@@ -45,7 +45,7 @@ % if msg: ${msg|n} % endif -% if state in ['unsubmitted', 'correct', 'incorrect', 'incomplete']: +% if status in ['unsubmitted', 'correct', 'incorrect', 'incomplete']:
% endif diff --git a/common/lib/capa/capa/templates/filesubmission.html b/common/lib/capa/capa/templates/filesubmission.html index 630a3222dc..2572b25f8a 100644 --- a/common/lib/capa/capa/templates/filesubmission.html +++ b/common/lib/capa/capa/templates/filesubmission.html @@ -1,16 +1,16 @@
- % if state == 'unsubmitted': + % if status == 'unsubmitted': Unanswered - % elif state == 'correct': + % elif status == 'correct': Correct - % elif state == 'incorrect': + % elif status == 'incorrect': Incorrect - % elif state == 'queued': + % elif status == 'queued': Queued % endif -

${state}

+

${status}

diff --git a/common/lib/capa/capa/templates/imageinput.html b/common/lib/capa/capa/templates/imageinput.html index ceda98ee8f..97279c1b8c 100644 --- a/common/lib/capa/capa/templates/imageinput.html +++ b/common/lib/capa/capa/templates/imageinput.html @@ -4,13 +4,13 @@
- % if state == 'unsubmitted': + % if status == 'unsubmitted': - % elif state == 'correct': + % elif status == 'correct': - % elif state == 'incorrect': + % elif status == 'incorrect': - % elif state == 'incomplete': + % elif status == 'incomplete': % endif diff --git a/common/lib/capa/capa/templates/jstextline.html b/common/lib/capa/capa/templates/jstextline.html index 045f329ad4..7e5fd94a4b 100644 --- a/common/lib/capa/capa/templates/jstextline.html +++ b/common/lib/capa/capa/templates/jstextline.html @@ -18,13 +18,13 @@ % endif - % if state == 'unsubmitted': + % if status == 'unsubmitted': - % elif state == 'correct': + % elif status == 'correct': - % elif state == 'incorrect': + % elif status == 'incorrect': - % elif state == 'incomplete': + % elif status == 'incomplete': % endif % if msg: diff --git a/common/lib/capa/capa/templates/optioninput.html b/common/lib/capa/capa/templates/optioninput.html index 06c7ed1257..ac62c0c9cb 100644 --- a/common/lib/capa/capa/templates/optioninput.html +++ b/common/lib/capa/capa/templates/optioninput.html @@ -12,13 +12,13 @@ - % if state == 'unsubmitted': + % if status == 'unsubmitted': - % elif state == 'correct': + % elif status == 'correct': - % elif state == 'incorrect': + % elif status == 'incorrect': - % elif state == 'incomplete': + % elif status == 'incomplete': % endif diff --git a/common/lib/capa/capa/templates/schematicinput.html b/common/lib/capa/capa/templates/schematicinput.html index f79dc66d24..ff8cc64073 100644 --- a/common/lib/capa/capa/templates/schematicinput.html +++ b/common/lib/capa/capa/templates/schematicinput.html @@ -12,13 +12,13 @@ - % if state == 'unsubmitted': + % if status == 'unsubmitted': - % elif state == 'correct': + % elif status == 'correct': - % elif state == 'incorrect': + % elif status == 'incorrect': - % elif state == 'incomplete': + % elif status == 'incomplete': % endif diff --git a/common/lib/capa/capa/templates/textline.html b/common/lib/capa/capa/templates/textline.html index 3685742a3c..97c512fc00 100644 --- a/common/lib/capa/capa/templates/textline.html +++ b/common/lib/capa/capa/templates/textline.html @@ -7,13 +7,13 @@
% endif - % if state == 'unsubmitted': + % if status == 'unsubmitted':
- % elif state == 'correct': + % elif status == 'correct':
- % elif state == 'incorrect': + % elif status == 'incorrect':
- % elif state == 'incomplete': + % elif status == 'incomplete':
% endif % if hidden: @@ -33,13 +33,13 @@ />

- % if state == 'unsubmitted': + % if status == 'unsubmitted': unanswered - % elif state == 'correct': + % elif status == 'correct': correct - % elif state == 'incorrect': + % elif status == 'incorrect': incorrect - % elif state == 'incomplete': + % elif status == 'incomplete': incomplete % endif

@@ -53,7 +53,7 @@ % endif -% if state in ['unsubmitted', 'correct', 'incorrect', 'incomplete']: +% if status in ['unsubmitted', 'correct', 'incorrect', 'incomplete']:
% endif diff --git a/common/lib/capa/capa/templates/vsepr_input.html b/common/lib/capa/capa/templates/vsepr_input.html index a6bd465554..eaa6ac2174 100644 --- a/common/lib/capa/capa/templates/vsepr_input.html +++ b/common/lib/capa/capa/templates/vsepr_input.html @@ -11,13 +11,13 @@
- % if state == 'unsubmitted': + % if status == 'unsubmitted':
- % elif state == 'correct': + % elif status == 'correct':
- % elif state == 'incorrect': + % elif status == 'incorrect':
- % elif state == 'incomplete': + % elif status == 'incomplete':
% endif @@ -26,13 +26,13 @@ />

- % if state == 'unsubmitted': + % if status == 'unsubmitted': unanswered - % elif state == 'correct': + % elif status == 'correct': correct - % elif state == 'incorrect': + % elif status == 'incorrect': incorrect - % elif state == 'incomplete': + % elif status == 'incomplete': incomplete % endif

@@ -42,7 +42,7 @@ % if msg: ${msg|n} % endif -% if state in ['unsubmitted', 'correct', 'incorrect', 'incomplete']: +% if status in ['unsubmitted', 'correct', 'incorrect', 'incomplete']:
% endif diff --git a/common/lib/capa/capa/tests/test_inputtypes.py b/common/lib/capa/capa/tests/test_inputtypes.py index 6c5b1cca15..65a22a876e 100644 --- a/common/lib/capa/capa/tests/test_inputtypes.py +++ b/common/lib/capa/capa/tests/test_inputtypes.py @@ -39,7 +39,7 @@ class OptionInputTest(unittest.TestCase): expected = {'value': 'Down', 'options': [('Up', 'Up'), ('Down', 'Down')], - 'state': 'answered', + 'status': 'answered', 'msg': '', 'inline': '', 'id': 'sky_input'} @@ -72,7 +72,7 @@ class ChoiceGroupTest(unittest.TestCase): expected = {'id': 'sky_input', 'value': 'foil3', - 'state': 'answered', + 'status': 'answered', 'input_type': expected_input_type, 'choices': [('foil1', 'This is foil One.'), ('foil2', 'This is foil Two.'), @@ -147,7 +147,7 @@ class TextLineTest(unittest.TestCase): expected = {'id': 'prob_1_2', 'value': 'BumbleBee', - 'state': 'unanswered', + 'status': 'unanswered', 'size': size, 'msg': '', 'hidden': False, @@ -175,7 +175,7 @@ class TextLineTest(unittest.TestCase): expected = {'id': 'prob_1_2', 'value': 'BumbleBee', - 'state': 'unanswered', + 'status': 'unanswered', 'size': size, 'msg': '', 'hidden': False, @@ -215,7 +215,7 @@ class FileSubmissionTest(unittest.TestCase): context = the_input._get_render_context() expected = {'id': 'prob_1_2', - 'state': 'queued', + 'status': 'queued', 'msg': 'Submitted to grader.', 'value': 'BumbleBee.py', 'queue_len': '3', @@ -260,7 +260,7 @@ class CodeInputTest(unittest.TestCase): expected = {'id': 'prob_1_2', 'value': 'print "good evening"', - 'state': 'queued', + 'status': 'queued', 'msg': 'Submitted to grader.', 'mode': mode, 'linenumbers': linenumbers, @@ -311,7 +311,7 @@ class SchematicTest(unittest.TestCase): expected = {'id': 'prob_1_2', 'value': value, 'initial_value': initial_value, - 'state': 'unsubmitted', + 'status': 'unsubmitted', 'width': width, 'height': height, 'parts': parts, @@ -349,13 +349,12 @@ class ImageInputTest(unittest.TestCase): expected = {'id': 'prob_1_2', 'value': value, - 'state': 'unsubmitted', + 'status': 'unsubmitted', 'width': width, 'height': height, 'src': src, 'gx': egx, 'gy': egy, - 'state': 'unsubmitted', 'msg': ''} self.assertEqual(context, expected) @@ -404,7 +403,7 @@ class CrystallographyTest(unittest.TestCase): expected = {'id': 'prob_1_2', 'value': value, - 'state': 'unsubmitted', + 'status': 'unsubmitted', 'size': size, 'msg': '', 'hidden': '',