Acceptance tests for visual correctness reset feature
This commit is contained in:
committed by
Sarina Canelake
parent
48cb05c037
commit
fe47dcb122
@@ -17,7 +17,7 @@
|
||||
|
||||
% for choice_id, choice_description in choices:
|
||||
<label for="input_${id}_${choice_id}"
|
||||
## If the student has selected this choice...
|
||||
## If the student has selected this choice...
|
||||
% if input_type == 'radio' and ( (isinstance(value, basestring) and (choice_id == value)) or (not isinstance(value, basestring) and choice_id in value) ):
|
||||
<%
|
||||
if status == 'correct':
|
||||
|
||||
@@ -352,10 +352,10 @@ class TextlineTemplateTest(TemplateTestCase):
|
||||
super(TextlineTemplateTest, self).setUp()
|
||||
|
||||
def test_section_class(self):
|
||||
cases = [({}, ' capa_inputtype '),
|
||||
({'do_math': True}, 'text-input-dynamath capa_inputtype '),
|
||||
({'inline': True}, ' capa_inputtype inline'),
|
||||
({'do_math': True, 'inline': True}, 'text-input-dynamath capa_inputtype inline'), ]
|
||||
cases = [({}, ' capa_inputtype textline'),
|
||||
({'do_math': True}, 'text-input-dynamath capa_inputtype textline'),
|
||||
({'inline': True}, ' capa_inputtype inline textline'),
|
||||
({'do_math': True, 'inline': True}, 'text-input-dynamath capa_inputtype inline textline'), ]
|
||||
|
||||
for (context, css_class) in cases:
|
||||
base_context = self.context.copy()
|
||||
|
||||
@@ -380,8 +380,6 @@ class @Problem
|
||||
classes = $(inputtype).attr('class').split(' ')
|
||||
for cls in classes
|
||||
bindMethod = @bindResetCorrectnessByInputtype[cls]
|
||||
# For debugging! Remove later
|
||||
console.log $(inputtype).attr('id'), cls, typeof bindMethod
|
||||
if bindMethod?
|
||||
bindMethod(inputtype)
|
||||
|
||||
@@ -393,7 +391,7 @@ class @Problem
|
||||
formulaequationinput: (element) ->
|
||||
$(element).find('input').on 'input', ->
|
||||
$p = $(element).find('p.status')
|
||||
$p.text "unanswered"
|
||||
$p.text gettext("unanswered")
|
||||
$p.parent().removeClass().addClass "unanswered"
|
||||
|
||||
choicegroup: (element) ->
|
||||
@@ -406,10 +404,9 @@ class @Problem
|
||||
$status.empty().css 'display', 'inline-block'
|
||||
else
|
||||
# Recreate the unanswered dot on left.
|
||||
$element.find('div.indicator_container').append "<span class='unanswered' style='display:inline-block;' id='status_#{id}'></span>"
|
||||
$("<span>", {"class": "unanswered", "style": "display: inline-block;", "id": "status_#{id}"})
|
||||
|
||||
$element.find("label").removeClass()
|
||||
.find('span').remove()
|
||||
|
||||
'option-input': (element) ->
|
||||
$select = $(element).find('select')
|
||||
@@ -417,7 +414,7 @@ class @Problem
|
||||
$select.on 'change', ->
|
||||
$status = $("#status_#{id}")
|
||||
.removeClass().addClass("unanswered")
|
||||
.find('span').text('Status: unsubmitted')
|
||||
.find('span').text(gettext('Status: unsubmitted'))
|
||||
|
||||
textline: (element) ->
|
||||
$(element).find('input').on 'input', ->
|
||||
|
||||
@@ -7,7 +7,7 @@ Feature: Answer problems
|
||||
Given External graders respond "correct"
|
||||
And I am viewing a "<ProblemType>" problem
|
||||
When I answer a "<ProblemType>" problem "correctly"
|
||||
Then My "<ProblemType>" answer is marked "correct"
|
||||
Then my "<ProblemType>" answer is marked "correct"
|
||||
And The "<ProblemType>" problem displays a "correct" answer
|
||||
|
||||
Examples:
|
||||
@@ -28,7 +28,7 @@ Feature: Answer problems
|
||||
Given External graders respond "incorrect"
|
||||
And I am viewing a "<ProblemType>" problem
|
||||
When I answer a "<ProblemType>" problem "incorrectly"
|
||||
Then My "<ProblemType>" answer is marked "incorrect"
|
||||
Then my "<ProblemType>" answer is marked "incorrect"
|
||||
And The "<ProblemType>" problem displays a "incorrect" answer
|
||||
|
||||
Examples:
|
||||
@@ -48,7 +48,7 @@ Feature: Answer problems
|
||||
Scenario: I can submit a blank answer
|
||||
Given I am viewing a "<ProblemType>" problem
|
||||
When I check a problem
|
||||
Then My "<ProblemType>" answer is marked "incorrect"
|
||||
Then my "<ProblemType>" answer is marked "incorrect"
|
||||
And The "<ProblemType>" problem displays a "blank" answer
|
||||
|
||||
Examples:
|
||||
@@ -69,7 +69,7 @@ Feature: Answer problems
|
||||
Given I am viewing a "<ProblemType>" problem
|
||||
And I answer a "<ProblemType>" problem "<Correctness>ly"
|
||||
When I reset the problem
|
||||
Then My "<ProblemType>" answer is marked "unanswered"
|
||||
Then my "<ProblemType>" answer is marked "unanswered"
|
||||
And The "<ProblemType>" problem displays a "blank" answer
|
||||
|
||||
Examples:
|
||||
@@ -171,3 +171,68 @@ Feature: Answer problems
|
||||
| numerical | 1 point possible |
|
||||
| formula | 1 point possible |
|
||||
| script | 2 points possible |
|
||||
|
||||
|
||||
Scenario: I can reset the correctness of a problem after changing my answer
|
||||
Given I am viewing a "<ProblemType>" problem
|
||||
Then my "<ProblemType>" answer is marked "unanswered"
|
||||
When I answer a "<ProblemType>" problem "<InitialCorrectness>ly"
|
||||
And I wait for "1" seconds
|
||||
And I input an answer on a "<ProblemType>" problem "<OtherCorrectness>ly"
|
||||
Then my "<ProblemType>" answer is marked "unanswered"
|
||||
And I reset the problem
|
||||
|
||||
Examples:
|
||||
| ProblemType | InitialCorrectness | OtherCorrectness |
|
||||
| drop down | correct | incorrect |
|
||||
| drop down | incorrect | correct |
|
||||
| checkbox | correct | incorrect |
|
||||
| checkbox | incorrect | correct |
|
||||
| string | correct | incorrect |
|
||||
| string | incorrect | correct |
|
||||
| numerical | correct | incorrect |
|
||||
| numerical | incorrect | correct |
|
||||
| formula | correct | incorrect |
|
||||
| formula | incorrect | correct |
|
||||
| script | correct | incorrect |
|
||||
| script | incorrect | correct |
|
||||
|
||||
# Radio groups behave slightly differently than other types of checkboxes, because they
|
||||
# don't put their status to the top left of the boxes (like checkboxes do), thus, they'll
|
||||
# not ever have a status of "unanswered" once you've made an answer. They should simply NOT
|
||||
# be marked either correct or incorrect. Arguably this behavior should be changed; when it
|
||||
# is, these cases should move into the above Scenario.
|
||||
Scenario: I can reset the correctness of a radiogroup problem after changing my answer
|
||||
Given I am viewing a "<ProblemType>" problem
|
||||
When I answer a "<ProblemType>" problem "<InitialCorrectness>ly"
|
||||
And I wait for "1" seconds
|
||||
Then my "<ProblemType>" answer is marked "<InitialCorrectness>"
|
||||
And I input an answer on a "<ProblemType>" problem "<OtherCorrectness>ly"
|
||||
Then my "<ProblemType>" answer is NOT marked "<InitialCorrectness>"
|
||||
And my "<ProblemType>" answer is NOT marked "<OtherCorrectness>"
|
||||
And I reset the problem
|
||||
|
||||
Examples:
|
||||
| ProblemType | InitialCorrectness | OtherCorrectness |
|
||||
| multiple choice | correct | incorrect |
|
||||
| multiple choice | incorrect | correct |
|
||||
| radio | correct | incorrect |
|
||||
| radio | incorrect | correct |
|
||||
|
||||
|
||||
Scenario: I can reset the correctness of a problem after submitting a blank answer
|
||||
Given I am viewing a "<ProblemType>" problem
|
||||
When I check a problem
|
||||
And I input an answer on a "<ProblemType>" problem "correctly"
|
||||
Then my "<ProblemType>" answer is marked "unanswered"
|
||||
|
||||
Examples:
|
||||
| ProblemType |
|
||||
| drop down |
|
||||
| multiple choice |
|
||||
| checkbox |
|
||||
| radio |
|
||||
| string |
|
||||
| numerical |
|
||||
| formula |
|
||||
| script |
|
||||
|
||||
@@ -82,15 +82,23 @@ def answer_problem_step(step, problem_type, correctness):
|
||||
*problem_type* is a string representing the type of problem (e.g. 'drop down')
|
||||
*correctness* is in ['correct', 'incorrect']
|
||||
"""
|
||||
|
||||
assert(correctness in ['correct', 'incorrect'])
|
||||
assert(problem_type in PROBLEM_DICT)
|
||||
answer_problem(problem_type, correctness)
|
||||
# Change the answer on the page
|
||||
input_problem_answer(step, problem_type, correctness)
|
||||
|
||||
# Submit the problem
|
||||
check_problem(step)
|
||||
|
||||
|
||||
@step(u'I input an answer on a "([^"]*)" problem "([^"]*)ly"')
|
||||
def input_problem_answer(_, problem_type, correctness):
|
||||
"""
|
||||
Have the browser input an answer (either correct or incorrect)
|
||||
"""
|
||||
assert(correctness in ['correct', 'incorrect'])
|
||||
assert(problem_type in PROBLEM_DICT)
|
||||
answer_problem(problem_type, correctness)
|
||||
|
||||
|
||||
@step(u'I check a problem')
|
||||
def check_problem(step):
|
||||
world.css_click("input.check")
|
||||
@@ -146,8 +154,8 @@ def see_score(_step, score):
|
||||
assert world.browser.is_text_present(score)
|
||||
|
||||
|
||||
@step(u'My "([^"]*)" answer is marked "([^"]*)"')
|
||||
def assert_answer_mark(step, problem_type, correctness):
|
||||
@step(u'[Mm]y "([^"]*)" answer is( NOT)? marked "([^"]*)"')
|
||||
def assert_answer_mark(_step, problem_type, isnt_marked, correctness):
|
||||
"""
|
||||
Assert that the expected answer mark is visible
|
||||
for a given problem type.
|
||||
@@ -162,7 +170,10 @@ def assert_answer_mark(step, problem_type, correctness):
|
||||
|
||||
# At least one of the correct selectors should be present
|
||||
for sel in PROBLEM_DICT[problem_type][correctness]:
|
||||
has_expected = world.is_css_present(sel)
|
||||
if isnt_marked:
|
||||
has_expected = world.is_css_not_present(sel)
|
||||
else:
|
||||
has_expected = world.is_css_present(sel)
|
||||
|
||||
# As soon as we find the selector, break out of the loop
|
||||
if has_expected:
|
||||
|
||||
@@ -24,6 +24,8 @@ from capa.tests.response_xml_factory import OptionResponseXMLFactory, \
|
||||
# Factories from capa.tests.response_xml_factory that we will use
|
||||
# to generate the problem XML, with the keyword args used to configure
|
||||
# the output.
|
||||
# 'correct', 'incorrect', and 'unanswered' keys are lists of CSS selectors
|
||||
# the presence of any in the list is sufficient
|
||||
PROBLEM_DICT = {
|
||||
'drop down': {
|
||||
'factory': OptionResponseXMLFactory(),
|
||||
|
||||
Reference in New Issue
Block a user