Commit e5e0dc4b by Will Daly

Merge pull request #1865 from MITx/feature/will/more_capa_tests

Feature/will/more capa tests
parents a3233b67 52c2f3ae
...@@ -15,6 +15,7 @@ Feature: Answer problems ...@@ -15,6 +15,7 @@ Feature: Answer problems
| drop down | | drop down |
| multiple choice | | multiple choice |
| checkbox | | checkbox |
| radio |
| string | | string |
| numerical | | numerical |
| formula | | formula |
...@@ -33,6 +34,7 @@ Feature: Answer problems ...@@ -33,6 +34,7 @@ Feature: Answer problems
| drop down | | drop down |
| multiple choice | | multiple choice |
| checkbox | | checkbox |
| radio |
| string | | string |
| numerical | | numerical |
| formula | | formula |
...@@ -50,6 +52,7 @@ Feature: Answer problems ...@@ -50,6 +52,7 @@ Feature: Answer problems
| drop down | | drop down |
| multiple choice | | multiple choice |
| checkbox | | checkbox |
| radio |
| string | | string |
| numerical | | numerical |
| formula | | formula |
...@@ -71,6 +74,8 @@ Feature: Answer problems ...@@ -71,6 +74,8 @@ Feature: Answer problems
| multiple choice | incorrect | | multiple choice | incorrect |
| checkbox | correct | | checkbox | correct |
| checkbox | incorrect | | checkbox | incorrect |
| radio | correct |
| radio | incorrect |
| string | correct | | string | correct |
| string | incorrect | | string | incorrect |
| numerical | correct | | numerical | correct |
......
...@@ -42,7 +42,13 @@ PROBLEM_FACTORY_DICT = { ...@@ -42,7 +42,13 @@ PROBLEM_FACTORY_DICT = {
'choice_type': 'checkbox', 'choice_type': 'checkbox',
'choices': [True, False, True, False, False], 'choices': [True, False, True, False, False],
'choice_names': ['Choice 1', 'Choice 2', 'Choice 3', 'Choice 4']}}, 'choice_names': ['Choice 1', 'Choice 2', 'Choice 3', 'Choice 4']}},
'radio': {
'factory': ChoiceResponseXMLFactory(),
'kwargs': {
'question_text': 'The correct answer is Choice 3',
'choice_type': 'radio',
'choices': [False, False, True, False],
'choice_names': ['Choice 1', 'Choice 2', 'Choice 3', 'Choice 4']}},
'string': { 'string': {
'factory': StringResponseXMLFactory(), 'factory': StringResponseXMLFactory(),
'kwargs': { 'kwargs': {
...@@ -174,6 +180,12 @@ def answer_problem(step, problem_type, correctness): ...@@ -174,6 +180,12 @@ def answer_problem(step, problem_type, correctness):
else: else:
inputfield('checkbox', choice='choice_3').check() inputfield('checkbox', choice='choice_3').check()
elif problem_type == 'radio':
if correctness == 'correct':
inputfield('radio', choice='choice_2').check()
else:
inputfield('radio', choice='choice_1').check()
elif problem_type == 'string': elif problem_type == 'string':
textvalue = 'correct string' if correctness == 'correct' \ textvalue = 'correct string' if correctness == 'correct' \
else 'incorrect' else 'incorrect'
...@@ -252,6 +264,14 @@ def assert_problem_has_answer(step, problem_type, answer_class): ...@@ -252,6 +264,14 @@ def assert_problem_has_answer(step, problem_type, answer_class):
else: else:
assert_checked('checkbox', []) assert_checked('checkbox', [])
elif problem_type == "radio":
if answer_class == 'correct':
assert_checked('radio', ['choice_2'])
elif answer_class == 'incorrect':
assert_checked('radio', ['choice_1'])
else:
assert_checked('radio', [])
elif problem_type == 'string': elif problem_type == 'string':
if answer_class == 'blank': if answer_class == 'blank':
expected = '' expected = ''
...@@ -298,6 +318,7 @@ CORRECTNESS_SELECTORS = { ...@@ -298,6 +318,7 @@ CORRECTNESS_SELECTORS = {
'correct': {'drop down': ['span.correct'], 'correct': {'drop down': ['span.correct'],
'multiple choice': ['label.choicegroup_correct'], 'multiple choice': ['label.choicegroup_correct'],
'checkbox': ['span.correct'], 'checkbox': ['span.correct'],
'radio': ['label.choicegroup_correct'],
'string': ['div.correct'], 'string': ['div.correct'],
'numerical': ['div.correct'], 'numerical': ['div.correct'],
'formula': ['div.correct'], 'formula': ['div.correct'],
...@@ -308,6 +329,8 @@ CORRECTNESS_SELECTORS = { ...@@ -308,6 +329,8 @@ CORRECTNESS_SELECTORS = {
'multiple choice': ['label.choicegroup_incorrect', 'multiple choice': ['label.choicegroup_incorrect',
'span.incorrect'], 'span.incorrect'],
'checkbox': ['span.incorrect'], 'checkbox': ['span.incorrect'],
'radio': ['label.choicegroup_incorrect',
'span.incorrect'],
'string': ['div.incorrect'], 'string': ['div.incorrect'],
'numerical': ['div.incorrect'], 'numerical': ['div.incorrect'],
'formula': ['div.incorrect'], 'formula': ['div.incorrect'],
...@@ -317,6 +340,7 @@ CORRECTNESS_SELECTORS = { ...@@ -317,6 +340,7 @@ CORRECTNESS_SELECTORS = {
'unanswered': {'drop down': ['span.unanswered'], 'unanswered': {'drop down': ['span.unanswered'],
'multiple choice': ['span.unanswered'], 'multiple choice': ['span.unanswered'],
'checkbox': ['span.unanswered'], 'checkbox': ['span.unanswered'],
'radio': ['span.unanswered'],
'string': ['div.unanswered'], 'string': ['div.unanswered'],
'numerical': ['div.unanswered'], 'numerical': ['div.unanswered'],
'formula': ['div.unanswered'], 'formula': ['div.unanswered'],
......
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