def asset_chapter(_step, name, ordinal):
    index = ["first", "second", "third"].index(ordinal)
    input_css = ".textbook .chapter{i} input.chapter-asset-path".format(
        i=index + 1)
    world.css_fill(input_css, name)
    if world.is_firefox():
        world.trigger_event(input_css)
示例#2
0
def add_subsection(name='Subsection One'):
    css = 'a.new-subsection-item'
    world.css_click(css)
    name_css = 'input.new-subsection-name-input'
    save_css = 'input.new-subsection-name-save'
    world.css_fill(name_css, name)
    world.css_click(save_css)
示例#3
0
def add_subsection(name='Subsection One'):
    css = 'a.new-subsection-item'
    world.css_click(css)
    name_css = 'input.new-subsection-name-input'
    save_css = 'input.new-subsection-name-save'
    world.css_fill(name_css, name)
    world.css_click(save_css)
示例#4
0
def add_subsection(name="Subsection One"):
    css = "a.new-subsection-item"
    world.css_click(css)
    name_css = "input.new-subsection-name-input"
    save_css = "input.new-subsection-name-save"
    world.css_fill(name_css, name)
    world.css_click(save_css)
示例#5
0
def answer_problem(problem_type, correctness):
    if problem_type == "drop down":
        select_name = "input_i4x-edx-model_course-problem-drop_down_2_1"
        option_text = 'Option 2' if correctness == 'correct' else 'Option 3'
        world.browser.select(select_name, option_text)

    elif problem_type == "multiple choice":
        if correctness == 'correct':
            world.css_check(inputfield('multiple choice', choice='choice_2'))
        else:
            world.css_check(inputfield('multiple choice', choice='choice_1'))

    elif problem_type == "checkbox":
        if correctness == 'correct':
            world.css_check(inputfield('checkbox', choice='choice_0'))
            world.css_check(inputfield('checkbox', choice='choice_2'))
        else:
            world.css_check(inputfield('checkbox', choice='choice_3'))

    elif problem_type == 'radio':
        if correctness == 'correct':
            world.css_check(inputfield('radio', choice='choice_2'))
        else:
            world.css_check(inputfield('radio', choice='choice_1'))

    elif problem_type == 'string':
        textvalue = 'correct string' if correctness == 'correct' else 'incorrect'
        world.css_fill(inputfield('string'), textvalue)

    elif problem_type == 'numerical':
        textvalue = "pi + 1" if correctness == 'correct' else str(random.randint(-2, 2))
        world.css_fill(inputfield('numerical'), textvalue)

    elif problem_type == 'formula':
        textvalue = "x^2+2*x+y" if correctness == 'correct' else 'x^2'
        world.css_fill(inputfield('formula'), textvalue)

    elif problem_type == 'script':
        # Correct answer is any two integers that sum to 10
        first_addend = random.randint(-100, 100)
        second_addend = 10 - first_addend

        # If we want an incorrect answer, then change
        # the second addend so they no longer sum to 10
        if correctness == 'incorrect':
            second_addend += random.randint(1, 10)

        world.css_fill(inputfield('script', input_num=1), str(first_addend))
        world.css_fill(inputfield('script', input_num=2), str(second_addend))

    elif problem_type == 'code':
        # The fake xqueue server is configured to respond
        # correct / incorrect no matter what we submit.
        # Furthermore, since the inline code response uses
        # JavaScript to make the code display nicely, it's difficult
        # to programatically input text
        # (there's not <textarea> we can just fill text into)
        # For this reason, we submit the initial code in the response
        # (configured in the problem XML above)
        pass
def i_can_modify_the_display_name(step):
    # Verifying that the display name can be a string containing a floating point value
    # (to confirm that we don't throw an error because it is of the wrong type).
    index = world.get_setting_entry_index(DISPLAY_NAME)
    world.css_fill('.wrapper-comp-setting .setting-input', '3.4', index=index)
    if world.is_firefox():
        world.trigger_event('.wrapper-comp-setting .setting-input', index=index)
    verify_modified_display_name()
示例#7
0
 def answer_problem(self, step):
     r"""I answer that annotation problem$"""
     world.css_fill(self.active_problem_selector('.comment'),
                    'Test Response')
     world.css_click(
         self.active_problem_selector('.tag[data-id="{}"]'.format(
             self.active_problem)))
     world.css_click(self.active_problem_selector('.check'))
def i_can_modify_the_display_name(_step):
    # Verifying that the display name can be a string containing a floating point value
    # (to confirm that we don't throw an error because it is of the wrong type).
    index = world.get_setting_entry_index(DISPLAY_NAME)
    world.css_fill('.wrapper-comp-setting .setting-input', '3.4', index=index)
    if world.is_firefox():
        world.trigger_event('.wrapper-comp-setting .setting-input', index=index)
    verify_modified_display_name()
示例#9
0
def set_date_or_time(css, date_or_time):
    """
    Sets date or time field.
    """
    world.css_fill(css, date_or_time)
    e = world.css_find(css).first
    # hit Enter to apply the changes
    e._element.send_keys(Keys.ENTER)
示例#10
0
文件: pages.py 项目: eliesmr4/myedx
def change_name(step, new_name):
    settings_css = '.settings-button'
    world.css_click(settings_css)
    input_css = 'input.setting-input'
    world.css_fill(input_css, new_name)
    if world.is_firefox():
        world.trigger_event(input_css)
    world.save_component()
示例#11
0
def set_date_or_time(css, date_or_time):
    """
    Sets date or time field.
    """
    world.css_fill(css, date_or_time)
    e = world.css_find(css).first
    # hit Enter to apply the changes
    e._element.send_keys(Keys.ENTER)
示例#12
0
def change_name(step, new_name):
    settings_css = '.settings-button'
    world.css_click(settings_css)
    input_css = 'input.setting-input'
    world.css_fill(input_css, new_name)
    if world.is_firefox():
        world.trigger_event(input_css)
    world.save_component()
示例#13
0
def set_weight(weight):
    index = world.get_setting_entry_index(PROBLEM_WEIGHT)
    world.css_fill('.wrapper-comp-setting .setting-input', weight, index=index)
    if world.is_firefox():
        world.trigger_event('.wrapper-comp-setting .setting-input',
                            index=index,
                            event='blur')
        world.trigger_event('a.save-button', event='focus')
示例#14
0
def i_can_modify_the_display_name_with_special_chars(step):
    index = world.get_setting_entry_index(DISPLAY_NAME)
    world.css_fill('.wrapper-comp-setting .setting-input',
                   "updated ' \" &",
                   index=index)
    if world.is_firefox():
        world.trigger_event('.wrapper-comp-setting .setting-input',
                            index=index)
    verify_modified_display_name_with_special_chars()
示例#15
0
def set_the_max_attempts(step, max_attempts_set):
    # on firefox with selenium, the behaviour is different.  eg 2.34 displays as 2.34 and is persisted as 2
    index = world.get_setting_entry_index(MAXIMUM_ATTEMPTS)
    world.css_fill('.wrapper-comp-setting .setting-input', max_attempts_set, index=index)
    if world.is_firefox():
        world.trigger_event('.wrapper-comp-setting .setting-input', index=index)
    world.save_component_and_reopen(step)
    value =  int(world.css_value('input.setting-input', index=index))
    assert value >= 0
示例#16
0
def change_name(_step, new_name):
    settings_css = "#settings-mode a"
    world.css_click(settings_css)
    input_css = "input.setting-input"
    world.css_fill(input_css, new_name)
    if world.is_firefox():
        world.trigger_event(input_css)
    save_button = "a.save-button"
    world.css_click(save_button)
def set_the_max_attempts(step, max_attempts_set):
    # on firefox with selenium, the behaviour is different.  eg 2.34 displays as 2.34 and is persisted as 2
    index = world.get_setting_entry_index(MAXIMUM_ATTEMPTS)
    world.css_fill('.wrapper-comp-setting .setting-input', max_attempts_set, index=index)
    if world.is_firefox():
        world.trigger_event('.wrapper-comp-setting .setting-input', index=index)
    world.save_component_and_reopen(step)
    value =  int(world.css_value('input.setting-input', index=index))
    assert value >= 0
示例#18
0
def add_section(name="My Section"):
    link_css = "a.new-courseware-section-button"
    world.css_click(link_css)
    name_css = "input.new-section-name"
    save_css = "input.new-section-name-save"
    world.css_fill(name_css, name)
    world.css_click(save_css)
    span_css = "span.section-name-span"
    assert_true(world.is_css_present(span_css))
示例#19
0
def change_name(step, new_name):
    settings_css = '#settings-mode a'
    world.css_click(settings_css)
    input_css = 'input.setting-input'
    world.css_fill(input_css, new_name)
    if world.is_firefox():
        world.trigger_event(input_css)
    save_button = 'a.save-button'
    world.css_click(save_button)
示例#20
0
def set_date_and_time(date_css, desired_date, time_css, desired_time):
    world.css_fill(date_css, desired_date)
    # hit TAB to get to the time field
    e = world.css_find(date_css).first
    e._element.send_keys(Keys.TAB)
    world.css_fill(time_css, desired_time)
    e = world.css_find(time_css).first
    e._element.send_keys(Keys.TAB)
    time.sleep(float(1))
示例#21
0
def add_section(name='My Section'):
    link_css = 'a.new-courseware-section-button'
    world.css_click(link_css)
    name_css = 'input.new-section-name'
    save_css = 'input.new-section-name-save'
    world.css_fill(name_css, name)
    world.css_click(save_css)
    span_css = 'span.section-name-span'
    assert_true(world.is_css_present(span_css))
示例#22
0
def add_section(name='My Section'):
    link_css = 'a.new-courseware-section-button'
    world.css_click(link_css)
    name_css = 'input.new-section-name'
    save_css = 'input.new-section-name-save'
    world.css_fill(name_css, name)
    world.css_click(save_css)
    span_css = 'span.section-name-span'
    assert_true(world.is_css_present(span_css))
示例#23
0
def set_date_and_time(date_css, desired_date, time_css, desired_time):
    world.css_fill(date_css, desired_date)
    # hit TAB to get to the time field
    e = world.css_find(date_css).first
    e._element.send_keys(Keys.TAB)
    world.css_fill(time_css, desired_time)
    e = world.css_find(time_css).first
    e._element.send_keys(Keys.TAB)
    time.sleep(float(1))    
示例#24
0
def change_name(step, new_name):
    settings_css = '#settings-mode a'
    world.css_click(settings_css)
    input_css = 'input.setting-input'
    world.css_fill(input_css, new_name)
    if world.is_firefox():
        world.trigger_event(input_css)
    save_button = 'a.save-button'
    world.css_click(save_button)
示例#25
0
def clear_field(_step, index):
    index = int(index) - 1
    world.css_fill(SELECTORS['url_inputs'], '', index)

    # For some reason ChromeDriver doesn't trigger an 'input' event after filling
    # the field with an empty value. That's why we trigger it manually via jQuery.
    world.trigger_event(SELECTORS['url_inputs'], event='input', index=index)

    world.wait(DELAY)
    world.wait_for_ajax_complete()
示例#26
0
def clear_field(_step, index):
    index = int(index) - 1
    world.css_fill(SELECTORS['url_inputs'], '', index)

    # For some reason ChromeDriver doesn't trigger an 'input' event after filling
    # the field with an empty value. That's why we trigger it manually via jQuery.
    world.trigger_event(SELECTORS['url_inputs'], event='input', index=index)

    world.wait(DELAY)
    world.wait_for_ajax_complete()
示例#27
0
def add_other_user(_step, name):
    new_user_css = 'a.create-user-button'
    world.css_click(new_user_css)
    world.wait(0.5)

    email_css = 'input#user-email-input'
    world.css_fill(email_css, name + '@edx.org')
    if world.is_firefox():
        world.trigger_event(email_css)
    confirm_css = 'form.create-user button.action-primary'
    world.css_click(confirm_css)
示例#28
0
def i_enter_a_source(_step, link, index):
    index = int(index) - 1

    if index is not 0 and not world.css_visible(SELECTORS["collapse_bar"]):
        world.css_click(SELECTORS["collapse_link"])

        assert world.css_visible(SELECTORS["collapse_bar"])

    world.css_fill(SELECTORS["url_inputs"], link, index)
    world.wait(DELAY)
    world.wait_for_ajax_complete()
示例#29
0
def i_enter_a_source(_step, link, index):
    index = int(index) - 1

    if index is not 0 and not world.css_visible(SELECTORS['collapse_bar']):
        world.css_click(SELECTORS['collapse_link'])

        assert world.css_visible(SELECTORS['collapse_bar'])

    world.css_fill(SELECTORS['url_inputs'], link, index)
    world.wait(DELAY)
    world.wait_for_ajax_complete()
示例#30
0
def fill_in_course_info(
        name='Robot Super Course',
        org='MITx',
        num='101',
        run='2013_Spring',
        subject='Mathematics'):
    world.css_fill('.new-course-name', name)
    world.css_fill('.new-course-org', org)
    world.css_fill('.new-course-number', num)
    world.css_fill('.new-course-run', run)
    world.css_fill('.new-course-subject', subject)
示例#31
0
def add_other_user(_step, name):
    new_user_css = 'a.create-user-button'
    world.css_click(new_user_css)
    world.wait(0.5)

    email_css = 'input#user-email-input'
    world.css_fill(email_css, name + EMAIL_EXTENSION)
    if world.is_firefox():
        world.trigger_event(email_css)
    confirm_css = 'form.create-user button.action-primary'
    world.css_click(confirm_css)
示例#32
0
def add_other_user(_step, name):
    new_user_css = 'a.create-user-button'
    world.css_click(new_user_css)

    # Wait for the css animation to apply the is-shown class
    shown_css = 'div.wrapper-create-user.is-shown'
    world.wait_for_present(shown_css)

    email_css = 'input#user-email-input'
    world.css_fill(email_css, name + '@edx.org')
    if world.is_firefox():
        world.trigger_event(email_css)
    confirm_css = 'form.create-user button.action-primary'
    world.css_click(confirm_css)
示例#33
0
def add_other_user(_step, name):
    new_user_css = 'a.create-user-button'
    world.css_click(new_user_css)

    # Wait for the css animation to apply the is-shown class
    shown_css = 'div.wrapper-create-user.is-shown'
    world.wait_for_present(shown_css)

    email_css = 'input#user-email-input'
    world.css_fill(email_css, name + '@edx.org')
    if world.is_firefox():
        world.trigger_event(email_css)
    confirm_css = 'form.create-user button.action-primary'
    world.css_click(confirm_css)
示例#34
0
def fill_in_course_info(name='Robot Super Course',
                        org='MITx',
                        num='101',
                        run='2013_Spring'):
    world.css_fill('.new-course-name', name)
    world.css_fill('.new-course-org', org)
    world.css_fill('.new-course-number', num)
    world.css_fill('.new-course-run', run)
示例#35
0
def when_i_send_an_email(step, recipient):

    # Check that the recipient is valid
    assert_in(
        recipient, SEND_TO_OPTIONS,
        msg="Invalid recipient: {}".format(recipient)
    )

    # Clear the queue of existing emails
    while not mail.queue.empty():  # pylint: disable=E1101
        mail.queue.get()  # pylint: disable=E1101

    # Because we flush the database before each run,
    # we need to ensure that the email template fixture
    # is re-loaded into the database
    call_command('loaddata', 'course_email_template.json')

    # Go to the email section of the instructor dash
    world.visit('/courses/edx/999/Test_Course')
    world.css_click('a[href="/courses/edx/999/Test_Course/instructor"]')
    world.css_click('div.beta-button-wrapper>a')
    world.css_click('a[data-section="send_email"]')

    # Select the recipient
    world.select_option('send_to', SEND_TO_OPTIONS[recipient])

    # Enter subject and message
    world.css_fill('input#id_subject', 'Hello')

    with world.browser.get_iframe('mce_0_ifr') as iframe:
        editor = iframe.find_by_id('tinymce')[0]
        editor.fill('test message')

    # Click send
    world.css_click('input[name="send"]')

    # Confirm the alert
    world.browser.get_alert().accept()

    # Expect to see a message that the email was sent
    expected_msg = "Your email was successfully queued for sending."
    world.wait_for_visible('#request-response')
    assert_in(
        expected_msg, world.css_text('#request-response'),
        msg="Could not find email success message."
    )
示例#36
0
def fill_in_course_info(
        name='Robot Super Course',
        org='MITx',
        num='999'):
    world.css_fill('.new-course-name', name)
    world.css_fill('.new-course-org', org)
    world.css_fill('.new-course-number', num)
示例#37
0
def fill_in_course_info(
        name=_COURSE_NAME,
        org=_COURSE_ORG,
        num=_COURSE_NUM):
    world.css_fill('.new-course-name', name)
    world.css_fill('.new-course-org', org)
    world.css_fill('.new-course-number', num)
示例#38
0
def fill_in_course_info(
        name='Robot Super Course',
        org='MITx',
        num='999'):
    world.css_fill('.new-course-name', name)
    world.css_fill('.new-course-org', org)
    world.css_fill('.new-course-number', num)
示例#39
0
def when_i_send_an_email(step, recipient):  # pylint: disable=unused-argument

    # Check that the recipient is valid
    assert_in(recipient, SEND_TO_OPTIONS, msg="Invalid recipient: {}".format(recipient))

    # Clear the queue of existing emails
    while not mail.queue.empty():  # pylint: disable=no-member
        mail.queue.get()  # pylint: disable=no-member

    # Because we flush the database before each run,
    # we need to ensure that the email template fixture
    # is re-loaded into the database
    call_command("loaddata", "course_email_template.json")

    # Go to the email section of the instructor dash
    url = "/courses/{}".format(world.bulk_email_course_key)
    world.visit(url)
    world.css_click('a[href="{}/instructor"]'.format(url))
    world.css_click('a[data-section="send_email"]')

    # Select the recipient
    world.select_option("send_to", SEND_TO_OPTIONS[recipient])

    # Enter subject and message
    world.css_fill("input#id_subject", "Hello")

    with world.browser.get_iframe("mce_0_ifr") as iframe:
        editor = iframe.find_by_id("tinymce")[0]
        editor.fill("test message")

    # Click send
    world.css_click('input[name="send"]', dismiss_alert=True)

    # Expect to see a message that the email was sent
    expected_msg = "Your email was successfully queued for sending."
    world.wait_for_visible("#request-response")
    assert_in(expected_msg, world.css_text("#request-response"), msg="Could not find email success message.")
示例#40
0
def save_section_name(name):
    name_css = '.new-section-name'
    save_css = '.new-section-name-save'
    world.css_fill(name_css, name)
    world.css_click(save_css)
示例#41
0
def save_subsection_name(name):
    name_css = 'input.new-subsection-name-input'
    save_css = 'input.new-subsection-name-save'
    world.css_fill(name_css, name)
    world.css_click(save_css)
示例#42
0
def asset_chapter(_step, name, ordinal):
    index = ["first", "second", "third"].index(ordinal)
    input_css = ".textbook .chapter{i} input.chapter-asset-path".format(i=index+1)
    world.css_fill(input_css, name)
    if world.is_firefox():
        world.trigger_event(input_css)
示例#43
0
def name_textbook(_step, name):
    input_css = ".textbook input[name=textbook-name]"
    world.css_fill(input_css, name)
    if world.is_firefox():
        world.trigger_event(input_css)
示例#44
0
 def answer_problem(self, step):
     r"""I answer that annotation problem$"""
     world.css_fill(self.active_problem_selector('.comment'), 'Test Response')
     world.css_click(self.active_problem_selector('.tag[data-id="{}"]'.format(self.active_problem)))
     world.css_click(self.active_problem_selector('.check'))
示例#45
0
def answer_problem(problem_type, correctness):
    if problem_type == "drop down":
        select_name = "input_i4x-edx-model_course-problem-drop_down_2_1"
        option_text = 'Option 2' if correctness == 'correct' else 'Option 3'
        world.select_option(select_name, option_text)

    elif problem_type == "multiple choice":
        if correctness == 'correct':
            world.css_check(inputfield('multiple choice', choice='choice_2'))
        else:
            world.css_check(inputfield('multiple choice', choice='choice_1'))

    elif problem_type == "checkbox":
        if correctness == 'correct':
            world.css_check(inputfield('checkbox', choice='choice_0'))
            world.css_check(inputfield('checkbox', choice='choice_2'))
        else:
            world.css_check(inputfield('checkbox', choice='choice_3'))

    elif problem_type == 'radio':
        if correctness == 'correct':
            world.css_check(inputfield('radio', choice='choice_2'))
        else:
            world.css_check(inputfield('radio', choice='choice_1'))

    elif problem_type == 'string':
        textvalue = 'correct string' if correctness == 'correct' else 'incorrect'
        world.css_fill(inputfield('string'), textvalue)

    elif problem_type == 'numerical':
        textvalue = "pi + 1" if correctness == 'correct' else str(
            random.randint(-2, 2))
        world.css_fill(inputfield('numerical'), textvalue)

    elif problem_type == 'formula':
        textvalue = "x^2+2*x+y" if correctness == 'correct' else 'x^2'
        world.css_fill(inputfield('formula'), textvalue)

    elif problem_type == 'script':
        # Correct answer is any two integers that sum to 10
        first_addend = random.randint(-100, 100)
        second_addend = 10 - first_addend

        # If we want an incorrect answer, then change
        # the second addend so they no longer sum to 10
        if correctness == 'incorrect':
            second_addend += random.randint(1, 10)

        world.css_fill(inputfield('script', input_num=1), str(first_addend))
        world.css_fill(inputfield('script', input_num=2), str(second_addend))

    elif problem_type == 'code':
        # The fake xqueue server is configured to respond
        # correct / incorrect no matter what we submit.
        # Furthermore, since the inline code response uses
        # JavaScript to make the code display nicely, it's difficult
        # to programatically input text
        # (there's not <textarea> we can just fill text into)
        # For this reason, we submit the initial code in the response
        # (configured in the problem XML above)
        pass

    elif problem_type == 'radio_text' or problem_type == 'checkbox_text':

        input_value = "8" if correctness == 'correct' else "5"
        choice = "choiceinput_0bc" if correctness == 'correct' else "choiceinput_1bc"
        world.css_fill(
            inputfield(problem_type,
                       choice="choiceinput_0_numtolerance_input_0"),
            input_value)
        world.css_check(inputfield(problem_type, choice=choice))
示例#46
0
def answer_problem(course, problem_type, correctness):
    # Make sure that the problem has been completely rendered before
    # starting to input an answer.
    world.wait_for_ajax_complete()

    section_loc = section_location(course)

    if problem_type == "drop down":
        select_name = "input_{}_2_1".format(
            section_loc.course_key.make_usage_key('problem', 'drop_down').html_id()
        )
        option_text = 'Option 2' if correctness == 'correct' else 'Option 3'
        world.select_option(select_name, option_text)

    elif problem_type == "multiple choice":
        if correctness == 'correct':
            world.css_check(inputfield(course, 'multiple choice', choice='choice_2'))
        else:
            world.css_check(inputfield(course, 'multiple choice', choice='choice_1'))

    elif problem_type == "checkbox":
        if correctness == 'correct':
            world.css_check(inputfield(course, 'checkbox', choice='choice_0'))
            world.css_check(inputfield(course, 'checkbox', choice='choice_2'))
        else:
            world.css_check(inputfield(course, 'checkbox', choice='choice_3'))

    elif problem_type == 'radio':
        if correctness == 'correct':
            world.css_check(inputfield(course, 'radio', choice='choice_2'))
        else:
            world.css_check(inputfield(course, 'radio', choice='choice_1'))

    elif problem_type == 'string':
        textvalue = 'correct string' if correctness == 'correct' else 'incorrect'
        world.css_fill(inputfield(course, 'string'), textvalue)

    elif problem_type == 'numerical':
        textvalue = "pi + 1" if correctness == 'correct' else str(random.randint(-2, 2))
        world.css_fill(inputfield(course, 'numerical'), textvalue)

    elif problem_type == 'formula':
        textvalue = "x^2+2*x+y" if correctness == 'correct' else 'x^2'
        world.css_fill(inputfield(course, 'formula'), textvalue)

    elif problem_type == 'script':
        # Correct answer is any two integers that sum to 10
        first_addend = random.randint(-100, 100)
        second_addend = 10 - first_addend

        # If we want an incorrect answer, then change
        # the second addend so they no longer sum to 10
        if correctness == 'incorrect':
            second_addend += random.randint(1, 10)

        world.css_fill(inputfield(course, 'script', input_num=1), str(first_addend))
        world.css_fill(inputfield(course, 'script', input_num=2), str(second_addend))

    elif problem_type == 'code':
        # The fake xqueue server is configured to respond
        # correct / incorrect no matter what we submit.
        # Furthermore, since the inline code response uses
        # JavaScript to make the code display nicely, it's difficult
        # to programatically input text
        # (there's not <textarea> we can just fill text into)
        # For this reason, we submit the initial code in the response
        # (configured in the problem XML above)
        pass

    elif problem_type == 'radio_text' or problem_type == 'checkbox_text':

        input_value = "8" if correctness == 'correct' else "5"
        choice = "choiceinput_0bc" if correctness == 'correct' else "choiceinput_1bc"
        world.css_fill(
            inputfield(
                course,
                problem_type,
                choice="choiceinput_0_numtolerance_input_0"
            ),
            input_value
        )
        world.css_check(inputfield(course, problem_type, choice=choice))
    elif problem_type == 'image':
        offset = 25 if correctness == "correct" else -25

        def try_click():
            problem_html_loc = section_loc.course_key.make_usage_key('problem', 'image').html_id()
            image_selector = "#imageinput_{}_2_1".format(problem_html_loc)
            input_selector = "#input_{}_2_1".format(problem_html_loc)

            world.browser.execute_script('$("body").on("click", function(event) {console.log(event);})')

            initial_input = world.css_value(input_selector)
            world.wait_for_visible(image_selector)
            image = world.css_find(image_selector).first
            (image.action_chains
                .move_to_element(image._element)
                .move_by_offset(offset, offset)
                .click()
                .perform())

            world.wait_for(lambda _: world.css_value(input_selector) != initial_input)

        world.retry_on_exception(try_click)
示例#47
0
def save_subsection_name(name):
    name_css = 'input.new-subsection-name-input'
    save_css = 'input.new-subsection-name-save'
    world.css_fill(name_css, name)
    world.css_click(save_css)
示例#48
0
 def fill_in_link_fields():
     world.css_fill('.mce-textbox', path, 0)
     world.css_fill('.mce-textbox', 'picture', 1)
示例#49
0
def i_click_on_image_plugin_icon(step, path):
    use_plugin(
        '.mce-i-image',
        lambda: world.css_fill('.mce-textbox', path, 0)
    )
示例#50
0
def i_edit_the_password_field(step):
    password_css = 'form#login_form input#password'
    world.css_fill(password_css, 'test')
示例#51
0
def i_submit_the_answer_text(step, text):
    world.css_fill('textarea', text)
    world.css_click('input.check')
示例#52
0
def fill_inputs(_step):
    input_css = '.input_cloud_section .input-cloud'
    world.css_fill(input_css, 'text1', 0)

    for index in range(1, 4):
        world.css_fill('.input_cloud_section .input-cloud', 'text2', index)
def name_textbook(_step, name):
    input_css = ".textbook input[name=textbook-name]"
    world.css_fill(input_css, name)
    if world.is_firefox():
        world.trigger_event(input_css)
示例#54
0
def enter_the_answer_text(step, text):
    world.css_fill('textarea', text)
示例#55
0
def i_click_on_image_plugin_icon(_step, path):
    use_plugin('.mce-i-image', lambda: world.css_fill('.mce-textbox', path, 0))
示例#56
0
def answer_problem(course, problem_type, correctness):
    # Make sure that the problem has been completely rendered before
    # starting to input an answer.
    world.wait_for_ajax_complete()

    section_loc = section_location(course)

    if problem_type == "drop down":
        select_name = "input_{}_2_1".format(
            section_loc.course_key.make_usage_key('problem',
                                                  'drop_down').html_id())
        option_text = 'Option 2' if correctness == 'correct' else 'Option 3'
        world.select_option(select_name, option_text)

    elif problem_type == "multiple choice":
        if correctness == 'correct':
            world.css_check(
                inputfield(course, 'multiple choice', choice='choice_2'))
        else:
            world.css_check(
                inputfield(course, 'multiple choice', choice='choice_1'))

    elif problem_type == "checkbox":
        if correctness == 'correct':
            world.css_check(inputfield(course, 'checkbox', choice='choice_0'))
            world.css_check(inputfield(course, 'checkbox', choice='choice_2'))
        else:
            world.css_check(inputfield(course, 'checkbox', choice='choice_3'))

    elif problem_type == 'radio':
        if correctness == 'correct':
            world.css_check(inputfield(course, 'radio', choice='choice_2'))
        else:
            world.css_check(inputfield(course, 'radio', choice='choice_1'))

    elif problem_type == 'string':
        textvalue = 'correct string' if correctness == 'correct' else 'incorrect'
        world.css_fill(inputfield(course, 'string'), textvalue)

    elif problem_type == 'numerical':
        textvalue = "pi + 1" if correctness == 'correct' else str(
            random.randint(-2, 2))
        world.css_fill(inputfield(course, 'numerical'), textvalue)

    elif problem_type == 'formula':
        textvalue = "x^2+2*x+y" if correctness == 'correct' else 'x^2'
        world.css_fill(inputfield(course, 'formula'), textvalue)

    elif problem_type == 'script':
        # Correct answer is any two integers that sum to 10
        first_addend = random.randint(-100, 100)
        second_addend = 10 - first_addend

        # If we want an incorrect answer, then change
        # the second addend so they no longer sum to 10
        if correctness == 'incorrect':
            second_addend += random.randint(1, 10)

        world.css_fill(inputfield(course, 'script', input_num=1),
                       str(first_addend))
        world.css_fill(inputfield(course, 'script', input_num=2),
                       str(second_addend))

    elif problem_type == 'code':
        # The fake xqueue server is configured to respond
        # correct / incorrect no matter what we submit.
        # Furthermore, since the inline code response uses
        # JavaScript to make the code display nicely, it's difficult
        # to programatically input text
        # (there's not <textarea> we can just fill text into)
        # For this reason, we submit the initial code in the response
        # (configured in the problem XML above)
        pass

    elif problem_type == 'radio_text' or problem_type == 'checkbox_text':

        input_value = "8" if correctness == 'correct' else "5"
        choice = "choiceinput_0bc" if correctness == 'correct' else "choiceinput_1bc"
        world.css_fill(
            inputfield(course,
                       problem_type,
                       choice="choiceinput_0_numtolerance_input_0"),
            input_value)
        world.css_check(inputfield(course, problem_type, choice=choice))
    elif problem_type == 'image':
        offset = 25 if correctness == "correct" else -25

        def try_click():
            problem_html_loc = section_loc.course_key.make_usage_key(
                'problem', 'image').html_id()
            image_selector = "#imageinput_{}_2_1".format(problem_html_loc)
            input_selector = "#input_{}_2_1".format(problem_html_loc)

            world.browser.execute_script(
                '$("body").on("click", function(event) {console.log(event);})')

            initial_input = world.css_value(input_selector)
            world.wait_for_visible(image_selector)
            image = world.css_find(image_selector).first
            (image.action_chains.move_to_element(
                image._element).move_by_offset(offset,
                                               offset).click().perform())

            world.wait_for(
                lambda _: world.css_value(input_selector) != initial_input)

        world.retry_on_exception(try_click)
示例#57
0
 def fill_in_link_fields():
     world.css_fill('.mce-textbox', path, 0)
     world.css_fill('.mce-textbox', 'picture', 1)