Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
3d8625da
Commit
3d8625da
authored
Mar 14, 2013
by
Will Daly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored problem lettuce test implementation
parent
5a2a4055
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
19 deletions
+41
-19
lms/djangoapps/courseware/features/problems.py
+41
-19
No files found.
lms/djangoapps/courseware/features/problems.py
View file @
3d8625da
...
...
@@ -4,17 +4,10 @@ from selenium.webdriver.support.ui import Select
import
random
from
common
import
i_am_registered_for_the_course
problem_urls
=
{
'drop down'
:
'/courses/edX/model_course/2013_Spring/courseware/Problem_Components/Drop_Down_Problems'
,
'multiple choice'
:
'/courses/edX/model_course/2013_Spring/courseware/Problem_Components/Multiple_Choice_Problems'
,
'checkbox'
:
'/courses/edX/model_course/2013_Spring/courseware/Problem_Components/Checkbox_Problems'
,
'string'
:
'/courses/edX/model_course/2013_Spring/courseware/Problem_Components/String_Problems'
,
'numerical'
:
'/courses/edX/model_course/2013_Spring/courseware/Problem_Components/Numerical_Problems'
,
'formula'
:
'/courses/edX/model_course/2013_Spring/courseware/Problem_Components/Formula_Problems'
,
}
@step
(
u'I am viewing a "([^"]*)" problem'
)
def
view_problem
(
step
,
problem_type
):
i_am_registered_for_the_course
(
step
,
'edX/model_course/2013_Spring'
)
url
=
django_url
(
problem_url
s
[
problem_type
]
)
url
=
django_url
(
problem_url
(
problem_type
)
)
world
.
browser
.
visit
(
url
)
@step
(
u'I answer a "([^"]*)" problem "([^"]*)ly"'
)
...
...
@@ -28,31 +21,28 @@ def answer_problem(step, problem_type, correctness):
elif
problem_type
==
"multiple choice"
:
if
correctness
==
'correct'
:
world
.
browser
.
find_by_css
(
"input#input_i4x-edX-model_course-problem-Multiple_Choice_Problem_2_1_choice_choice_3"
)
.
check
()
inputfield
(
'multiple choice'
,
choice
=
'choice_3'
)
.
check
()
else
:
world
.
browser
.
find_by_css
(
"input#input_i4x-edX-model_course-problem-Multiple_Choice_Problem_2_1_choice_choice_2"
)
.
check
()
inputfield
(
'multiple choice'
,
choice
=
'choice_2'
)
.
check
()
elif
problem_type
==
"checkbox"
:
if
correctness
==
'correct'
:
world
.
browser
.
find_by_css
(
'input#input_i4x-edX-model_course-problem-Checkbox_Problem_2_1_
choice_0'
)
.
check
()
world
.
browser
.
find_by_css
(
'input#input_i4x-edX-model_course-problem-Checkbox_Problem_2_1_
choice_2'
)
.
check
()
inputfield
(
'checkbox'
,
choice
=
'
choice_0'
)
.
check
()
inputfield
(
'checkbox'
,
choice
=
'
choice_2'
)
.
check
()
else
:
world
.
browser
.
find_by_css
(
'input#input_i4x-edX-model_course-problem-Checkbox_Problem_2_1_
choice_3'
)
.
check
()
inputfield
(
'checkbox'
,
choice
=
'
choice_3'
)
.
check
()
elif
problem_type
==
'string'
:
textfield
=
world
.
browser
.
find_by_css
(
"input#input_i4x-edX-model_course-problem-String_Problem_2_1"
)
textvalue
=
'correct string'
if
correctness
==
'correct'
else
'incorrect'
textfield
.
fill
(
textvalue
)
inputfield
(
'string'
)
.
fill
(
textvalue
)
elif
problem_type
==
'numerical'
:
textfield
=
world
.
browser
.
find_by_css
(
"input#input_i4x-edX-model_course-problem-Numerical_Problem_2_1"
)
textvalue
=
"pi + 1"
if
correctness
==
'correct'
else
str
(
random
.
randint
(
-
2
,
2
))
textfield
.
fill
(
textvalue
)
inputfield
(
'numerical'
)
.
fill
(
textvalue
)
elif
problem_type
==
'formula'
:
textfield
=
world
.
browser
.
find_by_css
(
"input#input_i4x-edX-model_course-problem-Formula_Problem_2_1"
)
textvalue
=
"x^2+2*x+y"
if
correctness
==
'correct'
else
'x^2'
textfield
.
fill
(
textvalue
)
inputfield
(
'formula'
)
.
fill
(
textvalue
)
check_problem
(
step
)
...
...
@@ -104,3 +94,35 @@ def assert_answer_mark(step, problem_type, correctness):
else
:
mark_class
=
'span.correct'
if
correctness
==
'correct'
else
'span.incorrect'
assert
(
world
.
browser
.
is_element_present_by_css
(
mark_class
,
wait_time
=
4
))
def
problem_url
(
problem_type
):
base
=
'/courses/edX/model_course/2013_Spring/courseware/Problem_Components/'
url_extensions
=
{
'drop down'
:
'Drop_Down_Problems'
,
'multiple choice'
:
'Multiple_Choice_Problems'
,
'checkbox'
:
'Checkbox_Problems'
,
'string'
:
'String_Problems'
,
'numerical'
:
'Numerical_Problems'
,
'formula'
:
'Formula_Problems'
,
}
assert
(
problem_type
in
url_extensions
)
return
base
+
url_extensions
[
problem_type
]
def
inputfield
(
problem_type
,
choice
=
None
):
field_extensions
=
{
'drop down'
:
'Drop_Down_Problem'
,
'multiple choice'
:
'Multiple_Choice_Problem'
,
'checkbox'
:
'Checkbox_Problem'
,
'string'
:
'String_Problem'
,
'numerical'
:
'Numerical_Problem'
,
'formula'
:
'Formula_Problem'
,
}
assert
(
problem_type
in
field_extensions
)
extension
=
field_extensions
[
problem_type
]
sel
=
"input#input_i4x-edX-model_course-problem-
%
s_2_1"
%
extension
if
choice
is
not
None
:
base
=
"_choice_"
if
problem_type
==
"multiple choice"
else
"_"
sel
=
sel
+
base
+
str
(
choice
)
return
world
.
browser
.
find_by_css
(
sel
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment