Commit 7f6d55ad by Jay Zoldak

Create acceptance tests for open ended grading.

parent 6df565e4
......@@ -3,19 +3,31 @@ Feature: Open ended grading
In order to complete the courseware questions
I want the machine learning grading to be functional
Scenario: I can submit an answer for instructor grading
Given I am registered for course "MITx/3.091x/2012_Fall"
And I log in
And I navigate to an openended question
When I enter the answer "I have no idea."
And I press the "Check" button
Then I see the grader status "Submitted for grading"
And I see the grader message "Feedback not yet available."
Scenario: An answer that is too short is rejected
Given I navigate to an openended question
And I enter the answer "z"
When I press the "Check" button
And I wait for "8" seconds
And I see the grader status "Submitted for grading"
And I press the "Recheck for Feedback" button
Then I see the red X
And I see the grader score "0"
Scenario: I can submit an answer for instructor grading
Given I am staff for course "MITx/3.091x/2012_Fall"
And I log in
And I navigate to an openended question
Scenario: An answer with too many spelling errors is rejected
Given I navigate to an openended question
And I enter the answer "az"
When I press the "Check" button
And I wait for "8" seconds
And I see the grader status "Submitted for grading"
And I press the "Recheck for Feedback" button
Then I see the red X
And I see the grader score "0"
When I click the link for full output
Then I see the spelling grading message "More spelling errors than average."
Scenario: An answer makes its way to the instructor dashboard
Given I navigate to an openended question as staff
When I submit the answer "I love Chemistry."
And I wait for "8" seconds
And I visit the staff grading page
Then my answer is queued for instructor grading
\ No newline at end of file
from lettuce import world, step
from lettuce.django import django_url
from nose.tools import assert_equals, assert_in
from logging import getLogger
logger = getLogger(__name__)
@step('I navigate to an openended question$')
def navigate_to_an_openended_question(step):
world.register_by_course_id('MITx/3.091x/2012_Fall')
world.log_in('robot@edx.org','test')
problem = '/courses/MITx/3.091x/2012_Fall/courseware/Week_10/Polymer_Synthesis/'
world.browser.visit(django_url(problem))
tab_css = 'ol#sequence-list > li > a[data-element="5"]'
world.browser.find_by_css(tab_css).click()
@step(u'I enter the answer "([^"]*)"')
@step('I navigate to an openended question as staff$')
def navigate_to_an_openended_question_as_staff(step):
world.register_by_course_id('MITx/3.091x/2012_Fall', True)
world.log_in('robot@edx.org','test')
problem = '/courses/MITx/3.091x/2012_Fall/courseware/Week_10/Polymer_Synthesis/'
world.browser.visit(django_url(problem))
tab_css = 'ol#sequence-list > li > a[data-element="5"]'
world.browser.find_by_css(tab_css).click()
@step(u'I enter the answer "([^"]*)"$')
def enter_the_answer_text(step, text):
textarea_css = 'textarea'
world.browser.find_by_css(textarea_css).first.fill(text)
@step(u'I submit the answer "([^"]*)"$')
def i_submit_the_answer_text(step, text):
textarea_css = 'textarea'
world.browser.find_by_css(textarea_css).first.fill(text)
check_css = 'input.check'
world.browser.find_by_css(check_css).click()
@step('I click the link for full output$')
def click_full_output_link(step):
link_css = 'a.full'
world.browser.find_by_css(link_css).first.click()
@step(u'I visit the staff grading page$')
def i_visit_the_staff_grading_page(step):
# course_u = '/courses/MITx/3.091x/2012_Fall'
# sg_url = '%s/staff_grading' % course_u
world.browser.click_link_by_text('Instructor')
world.browser.click_link_by_text('Staff grading')
# world.browser.visit(django_url(sg_url))
@step(u'I see the grader message "([^"]*)"$')
def see_grader_message(step, msg):
message_css = 'div.external-grader-message'
grader_msg = world.browser.find_by_css(message_css).text
assert_in(msg, grader_msg)
@step(u'I see the grader status "([^"]*)"')
@step(u'I see the grader status "([^"]*)"$')
def see_the_grader_status(step, status):
status_css = 'div.grader-status'
grader_status = world.browser.find_by_css(status_css).text
assert_equals(status, grader_status)
@step(u'I submit the answer "([^"]*)"$')
def i_submit_the_answer_text(step, text):
textarea_css = 'textarea'
world.browser.find_by_css(textarea_css).first.fill(text)
check_css = 'input.check'
world.browser.find_by_css(check_css).click()
@step('I see the red X$')
def see_the_red_x(step):
x_css = 'div.grader-status > span.incorrect'
assert world.browser.find_by_css(x_css)
@step(u'I visit the staff grading page$')
def i_visit_the_staff_grading_page(step):
course_u = '/courses/MITx/3.091x/2012_Fall'
world.browser.visit(django_url('%s/staff_grading' % course_u))
@step(u'I see the grader score "([^"]*)"$')
def see_the_grader_score(step, score):
score_css = 'div.result-output > p'
score_text = world.browser.find_by_css(score_css).text
assert_equals(score_text, 'Score: %s' % score)
@step('I see the link for full output$')
def see_full_output_link(step):
link_css = 'a.full'
assert world.browser.find_by_css(link_css)
@step('I see the spelling grading message "([^"]*)"$')
def see_spelling_msg(step, msg):
spelling_css = 'div.spelling'
spelling_msg = world.browser.find_by_css(spelling_css).text
assert_equals('Spelling: %s' % msg, spelling_msg)
@step(u'my answer is queued for instructor grading')
@step(u'my answer is queued for instructor grading$')
def answer_is_queued_for_instructor_grading(step):
assert False, 'This step must be implemented'
\ No newline at end of file
list_css = 'ul.problem-list > li > a'
actual_msg = world.browser.find_by_css(list_css).text
expected_msg = "(0 graded, 1 pending)"
assert_in(expected_msg, actual_msg)
......@@ -70,17 +70,11 @@ def i_am_registered_for_a_course(step):
@step('I am registered for course "([^"]*)"$')
def i_am_registered_for_course_by_id(step, course_id):
create_user('robot')
u = User.objects.get(username='robot')
CourseEnrollment.objects.get_or_create(user=u, course_id=course_id)
register_by_course_id(course_id)
@step('I am staff for course "([^"]*)"$')
def i_am_staff_for_course_by_id(step, course_id):
create_user('robot')
u = User.objects.get(username='robot')
u.is_staff=True
u.save()
CourseEnrollment.objects.get_or_create(user=u, course_id=course_id)
register_by_course_id(course_id, True)
@step('I log in$')
def i_log_in(step):
......@@ -103,6 +97,7 @@ def create_user(uname):
user_profile = UserProfileFactory(user=portal_user)
@world.absorb
def log_in(email, password):
world.browser.cookies.delete()
world.browser.visit(django_url('/'))
......@@ -117,6 +112,15 @@ def log_in(email, password):
assert world.browser.is_element_present_by_css('.content-wrapper', 10)
@world.absorb
def register_by_course_id(course_id, is_staff=False):
create_user('robot')
u = User.objects.get(username='robot')
if is_staff:
u.is_staff=True
u.save()
CourseEnrollment.objects.get_or_create(user=u, course_id=course_id)
@world.absorb
def save_the_html(path='/tmp'):
u = world.browser.url
html = world.browser.html.encode('ascii', 'ignore')
......
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