diff --git a/cms/templates/ux/reference/unit.html b/cms/templates/ux/reference/unit.html index 45d60ec845..9ad1ee32c0 100644 --- a/cms/templates/ux/reference/unit.html +++ b/cms/templates/ux/reference/unit.html @@ -523,7 +523,7 @@ from django.utils.translation import ugettext as _ -
+
diff --git a/common/lib/xmodule/xmodule/capa_base.py b/common/lib/xmodule/xmodule/capa_base.py index 32290e1889..4e69413133 100644 --- a/common/lib/xmodule/xmodule/capa_base.py +++ b/common/lib/xmodule/xmodule/capa_base.py @@ -131,6 +131,7 @@ class CapaFields(object): {"display_name": _("Attempted"), "value": "attempted"}, {"display_name": _("Closed"), "value": "closed"}, {"display_name": _("Finished"), "value": "finished"}, + {"display_name": _("Correct or Past Due"), "value": "correct_or_past_due"}, {"display_name": _("Past Due"), "value": "past_due"}, {"display_name": _("Never"), "value": "never"}] ) @@ -712,6 +713,8 @@ class CapaMixin(CapaFields): elif self.showanswer == 'finished': return self.closed() or self.is_correct() + elif self.showanswer == 'correct_or_past_due': + return self.is_correct() or self.is_past_due() elif self.showanswer == 'past_due': return self.is_past_due() elif self.showanswer == 'always': diff --git a/common/lib/xmodule/xmodule/tests/test_capa_module.py b/common/lib/xmodule/xmodule/tests/test_capa_module.py index 6f2bd03a4f..1e0cf84b7f 100644 --- a/common/lib/xmodule/xmodule/tests/test_capa_module.py +++ b/common/lib/xmodule/xmodule/tests/test_capa_module.py @@ -258,6 +258,43 @@ class CapaModuleTest(unittest.TestCase): graceperiod=self.two_day_delta_str) self.assertFalse(still_in_grace.answer_available()) + def test_showanswer_correct_or_past_due(self): + """ + With showanswer="correct_or_past_due" should show answer after the answer is correct + or after the problem is closed for everyone--e.g. after due date + grace period. + """ + + # can see because answer is correct, even with due date in the future + answer_correct = CapaFactory.create(showanswer='correct_or_past_due', + max_attempts="1", + attempts="0", + due=self.tomorrow_str, + correct=True) + self.assertTrue(answer_correct.answer_available()) + + # can see after due date, even when answer isn't correct + past_due_date = CapaFactory.create(showanswer='correct_or_past_due', + max_attempts="1", + attempts="0", + due=self.yesterday_str) + self.assertTrue(past_due_date.answer_available()) + + # can also see after due date when answer _is_ correct + past_due_date_correct = CapaFactory.create(showanswer='correct_or_past_due', + max_attempts="1", + attempts="0", + due=self.yesterday_str, + correct=True) + self.assertTrue(past_due_date_correct.answer_available()) + + # Can't see because grace period hasn't expired and answer isn't correct + still_in_grace = CapaFactory.create(showanswer='correct_or_past_due', + max_attempts="1", + attempts="1", + due=self.yesterday_str, + graceperiod=self.two_day_delta_str) + self.assertFalse(still_in_grace.answer_available()) + def test_showanswer_past_due(self): """ With showanswer="past_due" should only show answer after the problem is closed diff --git a/docs/en_us/course_authors/source/creating_content/create_problem.rst b/docs/en_us/course_authors/source/creating_content/create_problem.rst index 055dbe96fd..b04117cbe5 100644 --- a/docs/en_us/course_authors/source/creating_content/create_problem.rst +++ b/docs/en_us/course_authors/source/creating_content/create_problem.rst @@ -360,7 +360,7 @@ Show Answer =============== This setting defines when the problem shows the answer to the student. -This setting has seven options. +This setting has the following options. +-------------------+--------------------------------------+ | **Always** | Always show the answer when the | @@ -385,6 +385,10 @@ This setting has seven options. | | the student has no attempts left, or | | | the problem due date has passed. | +-------------------+--------------------------------------+ +| **Correct or | Show the answer after the student | +| Past Due** | has answered the problem correctly | +| | or the problem due date has passed. | ++-------------------+--------------------------------------+ | **Past Due** | Show the answer after the due date | | | for the problem has passed. | +-------------------+--------------------------------------+ diff --git a/docs/en_us/data/source/course_data_formats/course_xml.rst b/docs/en_us/data/source/course_data_formats/course_xml.rst index 2eac698dd3..2c02c84955 100644 --- a/docs/en_us/data/source/course_data_formats/course_xml.rst +++ b/docs/en_us/data/source/course_data_formats/course_xml.rst @@ -391,13 +391,14 @@ Inherited When this content should be shown to students. Note that anyone with staff access to the course will always see everything. `showanswer` - When to show answer. Values: never, attempted, answered, closed, finished, past_due, always. Default: closed. Optional. + When to show answer. Values: never, attempted, answered, closed, finished, correct_or_past_due, past_due, always. Default: closed. Optional. - `never`: never show answer - `attempted`: show answer after first attempt - `answered` : this is slightly different from `attempted` -- resetting the problems makes "done" False, but leaves attempts unchanged. - `closed` : show answer after problem is closed, ie due date is past, or maximum attempts exceeded. - `finished` : show answer after problem closed, or is correctly answered. - `past_due` : show answer after problem due date is past. + - `correct_or_past_due` : like `past_due`, but also allow solution to be seen immediately if the problem is correctly answered. - `always` : always allow answer to be shown. `graded`