Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
problem-builder
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
OpenEdx
problem-builder
Commits
488409bc
Commit
488409bc
authored
Nov 23, 2016
by
Tim Krones
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure multiple completion blocks can be updated independently.
parent
07903bc1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
1 deletions
+71
-1
problem_builder/public/js/completion.js
+1
-1
problem_builder/tests/integration/test_completion.py
+66
-0
problem_builder/tests/integration/xml_templates/completion_multiple_problem.xml
+4
-0
No files found.
problem_builder/public/js/completion.js
View file @
488409bc
function
CompletionBlock
(
runtime
,
element
)
{
function
CompletionBlock
(
runtime
,
element
)
{
var
$completion
=
$
(
'.pb-completion-value'
);
var
$completion
=
$
(
'.pb-completion-value'
,
element
);
return
{
return
{
mode
:
null
,
mode
:
null
,
...
...
problem_builder/tests/integration/test_completion.py
View file @
488409bc
...
@@ -31,12 +31,30 @@ class CompletionBlockTestMixin(object):
...
@@ -31,12 +31,30 @@ class CompletionBlockTestMixin(object):
"""
"""
@property
@property
def
checkmarks
(
self
):
return
self
.
browser
.
find_elements_by_css_selector
(
'.submit-result'
)
@property
def
completion_checkbox
(
self
):
def
completion_checkbox
(
self
):
return
self
.
browser
.
find_element_by_css_selector
(
'.pb-completion-value'
)
return
self
.
browser
.
find_element_by_css_selector
(
'.pb-completion-value'
)
@property
def
completion_checkboxes
(
self
):
return
self
.
browser
.
find_elements_by_css_selector
(
'.pb-completion-value'
)
def
expect_checkmarks_visible
(
self
,
first_visible
,
second_visible
):
first_checkmark
,
second_checkmark
=
self
.
checkmarks
self
.
assertEqual
(
first_checkmark
.
is_displayed
(),
first_visible
)
self
.
assertEqual
(
second_checkmark
.
is_displayed
(),
second_visible
)
def
expect_checkbox_checked
(
self
,
checked
):
def
expect_checkbox_checked
(
self
,
checked
):
self
.
assertEqual
(
bool
(
self
.
completion_checkbox
.
get_attribute
(
'checked'
)),
checked
)
self
.
assertEqual
(
bool
(
self
.
completion_checkbox
.
get_attribute
(
'checked'
)),
checked
)
def
expect_checkboxes_checked
(
self
,
first_checked
,
second_checked
):
first_checkbox
,
second_checkbox
=
self
.
completion_checkboxes
self
.
assertEqual
(
bool
(
first_checkbox
.
get_attribute
(
'checked'
)),
first_checked
)
self
.
assertEqual
(
bool
(
second_checkbox
.
get_attribute
(
'checked'
)),
second_checked
)
class
CompletionBlockTest
(
CompletionBlockTestMixin
,
ProblemBuilderBaseTest
):
class
CompletionBlockTest
(
CompletionBlockTestMixin
,
ProblemBuilderBaseTest
):
"""
"""
...
@@ -119,6 +137,54 @@ class CompletionBlockTest(CompletionBlockTestMixin, ProblemBuilderBaseTest):
...
@@ -119,6 +137,54 @@ class CompletionBlockTest(CompletionBlockTestMixin, ProblemBuilderBaseTest):
self
.
expect_checkmark_visible
(
False
)
self
.
expect_checkmark_visible
(
False
)
self
.
expect_submit_enabled
(
True
)
self
.
expect_submit_enabled
(
True
)
def
test_multiple_completion_blocks
(
self
):
"""
Test a regular Problem Builder block containing multiple completion blocks.
"""
self
.
pb_wrapper
=
self
.
load_scenario
(
"completion_multiple_problem.xml"
)
self
.
wait_for_init
()
first_checkbox
,
second_checkbox
=
self
.
completion_checkboxes
# Checkboxes of completion blocks should not have "checked" attribute set initially,
# and "Submit" should be enabled since leaving checkboxes unchecked produces a valid value:
self
.
assertIsNone
(
first_checkbox
.
get_attribute
(
'checked'
))
self
.
assertIsNone
(
second_checkbox
.
get_attribute
(
'checked'
))
self
.
expect_checkmarks_visible
(
False
,
False
)
self
.
expect_submit_enabled
(
True
)
# Confirm completion by checking first checkbox:
first_checkbox
.
click
()
self
.
expect_checkboxes_checked
(
True
,
False
)
self
.
expect_checkmarks_visible
(
False
,
False
)
self
.
expect_submit_enabled
(
True
)
# Submit answers
self
.
click_submit
(
self
.
pb_wrapper
)
# Now, we expect "Submit" to be disabled and the checkmarks to be visible:
self
.
expect_checkboxes_checked
(
True
,
False
)
self
.
expect_checkmarks_visible
(
True
,
True
)
self
.
expect_submit_enabled
(
False
)
# Uncheck first checkbox
first_checkbox
.
click
()
# It should be possible to click "Submit" again, and the checkmarks should be hidden:
self
.
expect_checkboxes_checked
(
False
,
False
)
self
.
expect_checkmarks_visible
(
False
,
False
)
self
.
expect_submit_enabled
(
True
)
# Now reload the page:
self
.
pb_wrapper
=
self
.
reload_page
()
self
.
wait_for_init
()
# The first checkbox should be checked, and the second checkbox should be unchecked
# (since these are the values we submitted earlier);
# "Submit" should be disabled (to discourage submitting the same answer):
self
.
expect_checkboxes_checked
(
True
,
False
)
self
.
expect_checkmarks_visible
(
True
,
True
)
self
.
expect_submit_enabled
(
False
)
class
CompletionStepBlockTest
(
CompletionBlockTestMixin
,
MentoringAssessmentBaseTest
):
class
CompletionStepBlockTest
(
CompletionBlockTestMixin
,
MentoringAssessmentBaseTest
):
"""
"""
...
...
problem_builder/tests/integration/xml_templates/completion_multiple_problem.xml
0 → 100644
View file @
488409bc
<problem-builder
url_name=
"pb_with_multiple_completion"
>
<pb-completion
name=
"completion_1"
question=
"Did you attend the meeting?"
answer=
"Yes, I did."
/>
<pb-completion
name=
"completion_2"
question=
"Did you attend the social gathering?"
answer=
"Yup, I was there."
/>
</problem-builder>
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