Add correct_or_past_due option for showanswer and update relevant documentation
This commit is contained in:
@@ -523,7 +523,7 @@ from django.utils.translation import ugettext as _
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div class="wrapper-comp-settings metadata_edit" id="settings-tab" data-metadata="{"showanswer": {"default_value": "finished", "explicitly_set": false, "display_name": "Show Answer", "help": "Defines when to show the answer to the problem. A default value can be set in Advanced Settings.", "type": "Select", "value": "finished", "field_name": "showanswer", "options": [{"display_name": "Always", "value": "always"}, {"display_name": "Answered", "value": "answered"}, {"display_name": "Attempted", "value": "attempted"}, {"display_name": "Closed", "value": "closed"}, {"display_name": "Finished", "value": "finished"}, {"display_name": "Past Due", "value": "past_due"}, {"display_name": "Never", "value": "never"}]}, "display_name": {"default_value": "Blank Advanced Problem", "explicitly_set": true, "display_name": "Display Name", "help": "This name appears in the horizontal navigation at the top of the page.", "type": "Generic", "value": "Blank Common Problem", "field_name": "display_name", "options": []}, "weight": {"default_value": null, "explicitly_set": false, "display_name": "Problem Weight", "help": "Defines the number of points each problem is worth. If the value is not set, each response field in the problem is worth one point.", "type": "Float", "value": null, "field_name": "weight", "options": {"step": 0.1, "min": 0}}, "rerandomize": {"default_value": "never", "explicitly_set": false, "display_name": "Randomization", "help": "Defines how often inputs are randomized when a student loads the problem. This setting only applies to problems that can have randomly generated numeric values. A default value can be set in Advanced Settings.", "type": "Select", "value": "never", "field_name": "rerandomize", "options": [{"display_name": "Always", "value": "always"}, {"display_name": "On Reset", "value": "onreset"}, {"display_name": "Never", "value": "never"}, {"display_name": "Per Student", "value": "per_student"}]}, "max_attempts": {"default_value": null, "explicitly_set": false, "display_name": "Maximum Attempts", "help": "Defines the number of times a student can try to answer this problem. If the value is not set, infinite attempts are allowed.", "type": "Integer", "value": null, "field_name": "max_attempts", "options": {"min": 0}}}"></div>
|
<div class="wrapper-comp-settings metadata_edit" id="settings-tab" data-metadata="{"showanswer": {"default_value": "finished", "explicitly_set": false, "display_name": "Show Answer", "help": "Defines when to show the answer to the problem. A default value can be set in Advanced Settings.", "type": "Select", "value": "finished", "field_name": "showanswer", "options": [{"display_name": "Always", "value": "always"}, {"display_name": "Answered", "value": "answered"}, {"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"}]}, "display_name": {"default_value": "Blank Advanced Problem", "explicitly_set": true, "display_name": "Display Name", "help": "This name appears in the horizontal navigation at the top of the page.", "type": "Generic", "value": "Blank Common Problem", "field_name": "display_name", "options": []}, "weight": {"default_value": null, "explicitly_set": false, "display_name": "Problem Weight", "help": "Defines the number of points each problem is worth. If the value is not set, each response field in the problem is worth one point.", "type": "Float", "value": null, "field_name": "weight", "options": {"step": 0.1, "min": 0}}, "rerandomize": {"default_value": "never", "explicitly_set": false, "display_name": "Randomization", "help": "Defines how often inputs are randomized when a student loads the problem. This setting only applies to problems that can have randomly generated numeric values. A default value can be set in Advanced Settings.", "type": "Select", "value": "never", "field_name": "rerandomize", "options": [{"display_name": "Always", "value": "always"}, {"display_name": "On Reset", "value": "onreset"}, {"display_name": "Never", "value": "never"}, {"display_name": "Per Student", "value": "per_student"}]}, "max_attempts": {"default_value": null, "explicitly_set": false, "display_name": "Maximum Attempts", "help": "Defines the number of times a student can try to answer this problem. If the value is not set, infinite attempts are allowed.", "type": "Integer", "value": null, "field_name": "max_attempts", "options": {"min": 0}}}"></div>
|
||||||
|
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -131,6 +131,7 @@ class CapaFields(object):
|
|||||||
{"display_name": _("Attempted"), "value": "attempted"},
|
{"display_name": _("Attempted"), "value": "attempted"},
|
||||||
{"display_name": _("Closed"), "value": "closed"},
|
{"display_name": _("Closed"), "value": "closed"},
|
||||||
{"display_name": _("Finished"), "value": "finished"},
|
{"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": _("Past Due"), "value": "past_due"},
|
||||||
{"display_name": _("Never"), "value": "never"}]
|
{"display_name": _("Never"), "value": "never"}]
|
||||||
)
|
)
|
||||||
@@ -712,6 +713,8 @@ class CapaMixin(CapaFields):
|
|||||||
elif self.showanswer == 'finished':
|
elif self.showanswer == 'finished':
|
||||||
return self.closed() or self.is_correct()
|
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':
|
elif self.showanswer == 'past_due':
|
||||||
return self.is_past_due()
|
return self.is_past_due()
|
||||||
elif self.showanswer == 'always':
|
elif self.showanswer == 'always':
|
||||||
|
|||||||
@@ -258,6 +258,43 @@ class CapaModuleTest(unittest.TestCase):
|
|||||||
graceperiod=self.two_day_delta_str)
|
graceperiod=self.two_day_delta_str)
|
||||||
self.assertFalse(still_in_grace.answer_available())
|
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):
|
def test_showanswer_past_due(self):
|
||||||
"""
|
"""
|
||||||
With showanswer="past_due" should only show answer after the problem is closed
|
With showanswer="past_due" should only show answer after the problem is closed
|
||||||
|
|||||||
@@ -360,7 +360,7 @@ Show Answer
|
|||||||
===============
|
===============
|
||||||
|
|
||||||
This setting defines when the problem shows the answer to the student.
|
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 |
|
| **Always** | Always show the answer when the |
|
||||||
@@ -385,6 +385,10 @@ This setting has seven options.
|
|||||||
| | the student has no attempts left, or |
|
| | the student has no attempts left, or |
|
||||||
| | the problem due date has passed. |
|
| | 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 |
|
| **Past Due** | Show the answer after the due date |
|
||||||
| | for the problem has passed. |
|
| | for the problem has passed. |
|
||||||
+-------------------+--------------------------------------+
|
+-------------------+--------------------------------------+
|
||||||
|
|||||||
@@ -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.
|
When this content should be shown to students. Note that anyone with staff access to the course will always see everything.
|
||||||
|
|
||||||
`showanswer`
|
`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
|
- `never`: never show answer
|
||||||
- `attempted`: show answer after first attempt
|
- `attempted`: show answer after first attempt
|
||||||
- `answered` : this is slightly different from `attempted` -- resetting the problems makes "done" False, but leaves attempts unchanged.
|
- `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.
|
- `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.
|
- `finished` : show answer after problem closed, or is correctly answered.
|
||||||
- `past_due` : show answer after problem due date is past.
|
- `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.
|
- `always` : always allow answer to be shown.
|
||||||
|
|
||||||
`graded`
|
`graded`
|
||||||
|
|||||||
Reference in New Issue
Block a user