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
4ee4532b
Commit
4ee4532b
authored
Oct 22, 2015
by
Tim Krones
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests.
parent
769192e7
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
462 additions
and
39 deletions
+462
-39
problem_builder/public/js/plot.js
+1
-1
problem_builder/templates/html/plot.html
+3
-3
problem_builder/tests/integration/test_step_builder.py
+391
-35
problem_builder/tests/integration/xml_templates/step_builder_plot_overlays.xml
+67
-0
No files found.
problem_builder/public/js/plot.js
View file @
4ee4532b
...
@@ -171,7 +171,7 @@ function PlotBlock(runtime, element) {
...
@@ -171,7 +171,7 @@ function PlotBlock(runtime, element) {
}
}
}
else
{
}
else
{
overlayInfo
.
show
();
overlayInfo
.
show
();
if
(
!
overlayInfo
.
isEmpty
()
&&
!
plotInfo
.
is
(
':visible'
))
{
if
(
!
overlayInfo
.
isEmpty
()
&&
!
plotInfo
.
is
Visible
(
))
{
plotInfo
.
show
();
plotInfo
.
show
();
}
}
}
}
...
...
problem_builder/templates/html/plot.html
View file @
4ee4532b
...
@@ -48,14 +48,14 @@
...
@@ -48,14 +48,14 @@
{% for overlay in self.overlay_data %}
{% for overlay in self.overlay_data %}
<div
class=
"plot-overlay plot-overlay-{{ overlay.position }}"
>
<div
class=
"plot-overlay plot-overlay-{{ overlay.position }}"
>
{% if overlay.description or overlay.citation %}
{% if overlay.description or overlay.citation %}
<p
style=
"color: {{ overlay.point_color }};"
>
{{ overlay.plot_label }}
</p>
<p
class=
"overlay-plot-label"
style=
"color: {{ overlay.point_color }};"
>
{{ overlay.plot_label }}
</p>
{% if overlay.description %}
{% if overlay.description %}
<p>
<p
class=
"overlay-description"
>
<strong>
Description:
</strong>
{{ overlay.description }}
<strong>
Description:
</strong>
{{ overlay.description }}
</p>
</p>
{% endif %}
{% endif %}
{% if overlay.citation %}
{% if overlay.citation %}
<p>
<p
class=
"overlay-citation"
>
<strong>
Source:
</strong>
{{ overlay.citation }}
<strong>
Source:
</strong>
{{ overlay.citation }}
</p>
</p>
{% endif %}
{% endif %}
...
...
problem_builder/tests/integration/test_step_builder.py
View file @
4ee4532b
...
@@ -6,6 +6,28 @@ from .base_test import CORRECT, INCORRECT, PARTIAL, MentoringAssessmentBaseTest,
...
@@ -6,6 +6,28 @@ from .base_test import CORRECT, INCORRECT, PARTIAL, MentoringAssessmentBaseTest,
from
.test_dashboard
import
MockSubmissionsAPI
from
.test_dashboard
import
MockSubmissionsAPI
class
HTMLColors
(
object
):
GREEN
=
'rgba(0, 128, 0, 1)'
BLUE
=
'rgba(0, 0, 255, 1)'
RED
=
'rgba(255, 0, 0, 1)'
GREY
=
'rgba(237, 237, 237, 1)'
PURPLE
=
'rgba(128, 0, 128, 1)'
ORANGE
=
'rgba(255, 165, 0, 1)'
CORAL
=
'rgba(255, 127, 80, 1)'
CORNFLOWERBLUE
=
'rgba(100, 149, 237, 1)'
OLIVE
=
'rgba(128, 128, 0, 1)'
CRIMSON
=
'rgba(220, 20, 60, 1)'
class
PointColors
(
object
):
ORANGE
=
'rgb(255, 165, 0)'
PURPLE
=
'rgb(128, 0, 128)'
CORAL
=
'rgb(255, 127, 80)'
CORNFLOWERBLUE
=
'rgb(100, 149, 237)'
OLIVE
=
'rgb(128, 128, 0)'
CRIMSON
=
'rgb(220, 20, 60)'
class
ExtendedMockSubmissionsAPI
(
MockSubmissionsAPI
):
class
ExtendedMockSubmissionsAPI
(
MockSubmissionsAPI
):
def
get_all_submissions
(
self
,
course_key_str
,
block_id
,
block_type
):
def
get_all_submissions
(
self
,
course_key_str
,
block_id
,
block_type
):
return
(
return
(
...
@@ -587,6 +609,27 @@ class StepBuilderTest(MentoringAssessmentBaseTest):
...
@@ -587,6 +609,27 @@ class StepBuilderTest(MentoringAssessmentBaseTest):
return
plot_controls
return
plot_controls
def
additional_plot_controls
(
self
,
step_builder
):
class
Namespace
(
object
):
pass
additional_plot_controls
=
Namespace
()
additional_plot_controls
.
teacher_button
=
step_builder
.
find_element_by_css_selector
(
"input.plot-overlay.plot-overlay-0"
)
additional_plot_controls
.
researchers_button
=
step_builder
.
find_element_by_css_selector
(
"input.plot-overlay.plot-overlay-1"
)
additional_plot_controls
.
sheldon_button
=
step_builder
.
find_element_by_css_selector
(
"input.plot-overlay.plot-overlay-2"
)
additional_plot_controls
.
yoda_button
=
step_builder
.
find_element_by_css_selector
(
"input.plot-overlay.plot-overlay-3"
)
return
additional_plot_controls
def
plot_empty
(
self
,
step_builder
):
def
plot_empty
(
self
,
step_builder
):
points
=
step_builder
.
find_elements_by_css_selector
(
"circle"
)
points
=
step_builder
.
find_elements_by_css_selector
(
"circle"
)
self
.
assertEquals
(
points
,
[])
self
.
assertEquals
(
points
,
[])
...
@@ -601,43 +644,33 @@ class StepBuilderTest(MentoringAssessmentBaseTest):
...
@@ -601,43 +644,33 @@ class StepBuilderTest(MentoringAssessmentBaseTest):
]
]
if
hidden
:
if
hidden
:
self
.
assertEquals
(
quadrant_labels
,
[])
self
.
assertEquals
(
quadrant_labels
,
[])
# rgba(255, 0, 0, 1): "red"
self
.
assertTrue
(
all
(
bc
==
HTMLColors
.
RED
for
bc
in
quadrants_button_border_colors
))
self
.
assertTrue
(
all
(
bc
==
'rgba(255, 0, 0, 1)'
for
bc
in
quadrants_button_border_colors
))
else
:
else
:
self
.
assertEquals
(
len
(
quadrant_labels
),
4
)
self
.
assertEquals
(
len
(
quadrant_labels
),
4
)
self
.
assertEquals
(
set
(
label
.
text
for
label
in
quadrant_labels
),
set
(
labels
))
self
.
assertEquals
(
set
(
label
.
text
for
label
in
quadrant_labels
),
set
(
labels
))
# rgba(0, 128, 0, 1): "green"
self
.
assertTrue
(
all
(
bc
==
HTMLColors
.
GREEN
for
bc
in
quadrants_button_border_colors
))
self
.
assertTrue
(
all
(
bc
==
'rgba(0, 128, 0, 1)'
for
bc
in
quadrants_button_border_colors
))
def
click_overlay_button
(
self
,
overlay_button
,
overlay_on
,
color_on
=
None
,
color_off
=
HTMLColors
.
GREY
):
def
click_default_button
(
overlay_button
.
click
()
self
,
plot_controls
,
overlay_on
,
color_on
=
'rgba(0, 128, 0, 1)'
,
color_off
=
'rgba(237, 237, 237, 1)'
button_border_colors
=
[
):
overlay_button
.
value_of_css_property
(
'border-top-color'
),
plot_controls
.
default_button
.
click
()
overlay_button
.
value_of_css_property
(
'border-right-color'
),
default_button_border_colors
=
[
overlay_button
.
value_of_css_property
(
'border-bottom-color'
),
plot_controls
.
default_button
.
value_of_css_property
(
'border-top-color'
),
overlay_button
.
value_of_css_property
(
'border-left-color'
),
plot_controls
.
default_button
.
value_of_css_property
(
'border-right-color'
),
plot_controls
.
default_button
.
value_of_css_property
(
'border-bottom-color'
),
plot_controls
.
default_button
.
value_of_css_property
(
'border-left-color'
),
]
]
if
overlay_on
:
if
overlay_on
:
self
.
assertTrue
(
all
(
bc
==
color_on
for
bc
in
default_
button_border_colors
))
self
.
assertTrue
(
all
(
bc
==
color_on
for
bc
in
button_border_colors
))
else
:
else
:
self
.
assertTrue
(
all
(
bc
==
color_off
for
bc
in
default_
button_border_colors
))
self
.
assertTrue
(
all
(
bc
==
color_off
for
bc
in
button_border_colors
))
def
click_average_button
(
def
click_default_button
(
self
,
plot_controls
,
overlay_on
,
color_on
=
HTMLColors
.
GREEN
):
self
,
plot_controls
,
overlay_on
,
color_on
=
'rgba(0, 0, 255, 1)'
,
color_off
=
'rgba(237, 237, 237, 1)'
self
.
click_overlay_button
(
plot_controls
.
default_button
,
overlay_on
,
color_on
)
):
plot_controls
.
average_button
.
click
()
def
click_average_button
(
self
,
plot_controls
,
overlay_on
,
color_on
=
HTMLColors
.
BLUE
):
average_button_border_colors
=
[
self
.
click_overlay_button
(
plot_controls
.
average_button
,
overlay_on
,
color_on
)
plot_controls
.
average_button
.
value_of_css_property
(
'border-top-color'
),
plot_controls
.
average_button
.
value_of_css_property
(
'border-right-color'
),
def
check_button_label
(
self
,
button
,
expected_value
):
plot_controls
.
average_button
.
value_of_css_property
(
'border-bottom-color'
),
self
.
assertEquals
(
button
.
get_attribute
(
'value'
),
expected_value
)
plot_controls
.
average_button
.
value_of_css_property
(
'border-left-color'
),
]
if
overlay_on
:
self
.
assertTrue
(
all
(
bc
==
color_on
for
bc
in
average_button_border_colors
))
else
:
self
.
assertTrue
(
all
(
bc
==
color_off
for
bc
in
average_button_border_colors
))
def
test_empty_plot
(
self
):
def
test_empty_plot
(
self
):
step_builder
,
controls
=
self
.
load_assessment_scenario
(
"step_builder_plot_defaults.xml"
,
{})
step_builder
,
controls
=
self
.
load_assessment_scenario
(
"step_builder_plot_defaults.xml"
,
{})
...
@@ -655,6 +688,9 @@ class StepBuilderTest(MentoringAssessmentBaseTest):
...
@@ -655,6 +688,9 @@ class StepBuilderTest(MentoringAssessmentBaseTest):
self
.
plot_empty
(
step_builder
)
self
.
plot_empty
(
step_builder
)
# Obtain references to plot controls
# Obtain references to plot controls
plot_controls
=
self
.
plot_controls
(
step_builder
)
plot_controls
=
self
.
plot_controls
(
step_builder
)
# Check button labels
self
.
check_button_label
(
plot_controls
.
default_button
,
"yours"
)
self
.
check_button_label
(
plot_controls
.
average_button
,
"Average"
)
# Check if plot is empty (default overlay off, average overlay off)
# Check if plot is empty (default overlay off, average overlay off)
self
.
click_default_button
(
plot_controls
,
overlay_on
=
False
)
self
.
click_default_button
(
plot_controls
,
overlay_on
=
False
)
self
.
plot_empty
(
step_builder
)
self
.
plot_empty
(
step_builder
)
...
@@ -678,7 +714,8 @@ class StepBuilderTest(MentoringAssessmentBaseTest):
...
@@ -678,7 +714,8 @@ class StepBuilderTest(MentoringAssessmentBaseTest):
for
overlay
in
overlays
:
for
overlay
in
overlays
:
# Check if correct number of points is present
# Check if correct number of points is present
points
=
step_builder
.
find_elements_by_css_selector
(
overlay
[
'selector'
])
selector
=
'circle'
+
overlay
[
'selector'
]
points
=
step_builder
.
find_elements_by_css_selector
(
selector
)
self
.
assertEquals
(
len
(
points
),
overlay
[
'num_points'
])
self
.
assertEquals
(
len
(
points
),
overlay
[
'num_points'
])
# Check point colors
# Check point colors
point_colors
=
[
point_colors
=
[
...
@@ -718,11 +755,14 @@ class StepBuilderTest(MentoringAssessmentBaseTest):
...
@@ -718,11 +755,14 @@ class StepBuilderTest(MentoringAssessmentBaseTest):
# Step 2: Plot
# Step 2: Plot
# Obtain references to plot controls
# Obtain references to plot controls
plot_controls
=
self
.
plot_controls
(
step_builder
)
plot_controls
=
self
.
plot_controls
(
step_builder
)
# Check button labels
self
.
check_button_label
(
plot_controls
.
default_button
,
"Custom plot label"
)
self
.
check_button_label
(
plot_controls
.
average_button
,
"Average"
)
# Overlay data
# Overlay data
default_overlay
=
{
default_overlay
=
{
'selector'
:
'.claim-default'
,
'selector'
:
'.claim-default'
,
'num_points'
:
2
,
'num_points'
:
2
,
'point_color'
:
'rgb(255, 165, 0)'
,
# orange
'point_color'
:
PointColors
.
ORANGE
,
'titles'
:
[
'2 + 2 = 5: 1, 5'
,
'The answer to everything is 42: 5, 1'
],
'titles'
:
[
'2 + 2 = 5: 1, 5'
,
'The answer to everything is 42: 5, 1'
],
'positions'
:
[
'positions'
:
[
(
'20'
,
'396'
),
# Values computed according to xScale and yScale (cf. plot.js)
(
'20'
,
'396'
),
# Values computed according to xScale and yScale (cf. plot.js)
...
@@ -732,7 +772,7 @@ class StepBuilderTest(MentoringAssessmentBaseTest):
...
@@ -732,7 +772,7 @@ class StepBuilderTest(MentoringAssessmentBaseTest):
average_overlay
=
{
average_overlay
=
{
'selector'
:
'.claim-average'
,
'selector'
:
'.claim-average'
,
'num_points'
:
2
,
'num_points'
:
2
,
'point_color'
:
'rgb(128, 0, 128)'
,
# purple
'point_color'
:
PointColors
.
PURPLE
,
'titles'
:
[
'2 + 2 = 5: 1, 5'
,
'The answer to everything is 42: 5, 1'
],
'titles'
:
[
'2 + 2 = 5: 1, 5'
,
'The answer to everything is 42: 5, 1'
],
'positions'
:
[
'positions'
:
[
(
'20'
,
'396'
),
# Values computed according to xScale and yScale (cf. plot.js)
(
'20'
,
'396'
),
# Values computed according to xScale and yScale (cf. plot.js)
...
@@ -743,7 +783,7 @@ class StepBuilderTest(MentoringAssessmentBaseTest):
...
@@ -743,7 +783,7 @@ class StepBuilderTest(MentoringAssessmentBaseTest):
self
.
check_overlays
(
step_builder
,
total_num_points
=
2
,
overlays
=
[
default_overlay
])
self
.
check_overlays
(
step_builder
,
total_num_points
=
2
,
overlays
=
[
default_overlay
])
# Check if plot shows correct overlay(s) (default overlay on, average overlay on)
# Check if plot shows correct overlay(s) (default overlay on, average overlay on)
self
.
click_average_button
(
plot_controls
,
overlay_on
=
True
,
color_on
=
'rgba(128, 0, 128, 1)'
)
# purple
self
.
click_average_button
(
plot_controls
,
overlay_on
=
True
,
color_on
=
HTMLColors
.
PURPLE
)
self
.
check_overlays
(
step_builder
,
4
,
overlays
=
[
default_overlay
,
average_overlay
])
self
.
check_overlays
(
step_builder
,
4
,
overlays
=
[
default_overlay
,
average_overlay
])
# Check if plot shows correct overlay(s) (default overlay off, average overlay on)
# Check if plot shows correct overlay(s) (default overlay off, average overlay on)
...
@@ -755,7 +795,7 @@ class StepBuilderTest(MentoringAssessmentBaseTest):
...
@@ -755,7 +795,7 @@ class StepBuilderTest(MentoringAssessmentBaseTest):
self
.
plot_empty
(
step_builder
)
self
.
plot_empty
(
step_builder
)
# Check if plot shows correct overlay(s) (default overlay on, average overlay off)
# Check if plot shows correct overlay(s) (default overlay on, average overlay off)
self
.
click_default_button
(
plot_controls
,
overlay_on
=
True
,
color_on
=
'rgba(255, 165, 0, 1)'
)
# orange
self
.
click_default_button
(
plot_controls
,
overlay_on
=
True
,
color_on
=
HTMLColors
.
ORANGE
)
self
.
check_overlays
(
step_builder
,
2
,
overlays
=
[
default_overlay
])
self
.
check_overlays
(
step_builder
,
2
,
overlays
=
[
default_overlay
])
# Check quadrant labels
# Check quadrant labels
...
@@ -765,3 +805,319 @@ class StepBuilderTest(MentoringAssessmentBaseTest):
...
@@ -765,3 +805,319 @@ class StepBuilderTest(MentoringAssessmentBaseTest):
step_builder
,
plot_controls
,
hidden
=
False
,
step_builder
,
plot_controls
,
hidden
=
False
,
labels
=
[
'Custom Q1 label'
,
'Custom Q2 label'
,
'Custom Q3 label'
,
'Custom Q4 label'
]
labels
=
[
'Custom Q1 label'
,
'Custom Q2 label'
,
'Custom Q3 label'
,
'Custom Q4 label'
]
)
)
def
check_display_status
(
self
,
element
,
hidden
):
if
hidden
:
display_status
=
element
.
value_of_css_property
(
'display'
)
self
.
assertEquals
(
display_status
,
'none'
)
else
:
# self.wait_until_visible(element)
display_status
=
element
.
value_of_css_property
(
'display'
)
self
.
assertEquals
(
display_status
,
'block'
)
def
check_plot_info
(
self
,
step_builder
,
hidden
,
visible_overlays
=
[],
hidden_overlays
=
[]):
# Check if plot info is present and visible
plot_info
=
step_builder
.
find_element_by_css_selector
(
".plot-info"
)
self
.
check_display_status
(
plot_info
,
hidden
)
# Check if info about visible overlays is present and visible
for
overlay
in
visible_overlays
:
overlay_info
=
plot_info
.
find_element_by_css_selector
(
overlay
[
'selector'
])
self
.
check_display_status
(
overlay_info
,
hidden
=
False
)
description
=
overlay
[
'description'
]
citation
=
overlay
[
'citation'
]
if
description
is
not
None
or
citation
is
not
None
:
overlay_plot_label
=
overlay_info
.
find_element_by_css_selector
(
'.overlay-plot-label'
)
self
.
assertEquals
(
overlay_plot_label
.
text
,
overlay
[
'plot_label'
])
text_color
=
overlay_plot_label
.
value_of_css_property
(
'color'
)
self
.
assertEquals
(
text_color
,
overlay
[
'plot_label_color'
])
if
description
is
not
None
:
overlay_description
=
overlay_info
.
find_element_by_css_selector
(
'.overlay-description'
)
self
.
assertEquals
(
overlay_description
.
text
,
'Description: '
+
description
)
if
citation
is
not
None
:
overlay_citation
=
overlay_info
.
find_element_by_css_selector
(
'.overlay-citation'
)
self
.
assertEquals
(
overlay_citation
.
text
,
'Source: '
+
citation
)
# Check if info about hidden overlays is hidden
for
overlay
in
hidden_overlays
:
overlay_info
=
plot_info
.
find_element_by_css_selector
(
overlay
[
'selector'
])
self
.
check_display_status
(
overlay_info
,
hidden
=
True
)
def
test_plot_overlays
(
self
):
step_builder
,
controls
=
self
.
load_assessment_scenario
(
"step_builder_plot_overlays.xml"
,
{})
# Step 1: Questions
# Provide first rating
self
.
answer_rating_question
(
1
,
1
,
step_builder
,
"How much do you agree?"
,
"1 - Disagree"
)
# Provide second rating
self
.
answer_rating_question
(
1
,
2
,
step_builder
,
"How important do you think this is?"
,
"5 - Very important"
)
# Advance
self
.
submit_and_go_to_next_step
(
controls
)
# Step 2: Questions
# Provide first rating
self
.
answer_rating_question
(
2
,
1
,
step_builder
,
"How much do you agree?"
,
"5 - Agree"
)
# Provide second rating
self
.
answer_rating_question
(
2
,
2
,
step_builder
,
"How important do you think this is?"
,
"1 - Not important"
)
# Advance
self
.
submit_and_go_to_next_step
(
controls
,
last
=
True
)
# Step 2: Plot
# Obtain references to plot controls
additional_plot_controls
=
self
.
additional_plot_controls
(
step_builder
)
# Check button labels
self
.
check_button_label
(
additional_plot_controls
.
teacher_button
,
"Teacher"
)
self
.
check_button_label
(
additional_plot_controls
.
researchers_button
,
"Researchers"
)
self
.
check_button_label
(
additional_plot_controls
.
sheldon_button
,
"Sheldon Cooper"
)
self
.
check_button_label
(
additional_plot_controls
.
yoda_button
,
"Yoda"
)
# Overlay data
default_overlay
=
{
'selector'
:
'.claim-default'
,
'num_points'
:
2
,
'point_color'
:
PointColors
.
ORANGE
,
'titles'
:
[
'2 + 2 = 5: 1, 5'
,
'The answer to everything is 42: 5, 1'
],
'positions'
:
[
(
'20'
,
'396'
),
# Values computed according to xScale and yScale (cf. plot.js)
(
'4'
,
'380'
),
# Values computed according to xScale and yScale (cf. plot.js)
],
}
teacher_overlay
=
{
'selector'
:
'.plot-overlay.plot-overlay-0'
,
'num_points'
:
2
,
'point_color'
:
PointColors
.
CORAL
,
'titles'
:
[
'2 + 2 = 5: 2, 3'
,
'The answer to everything is 42: 4, 2'
],
'positions'
:
[
(
'8'
,
'388'
),
# Values computed according to xScale and yScale (cf. plot.js)
(
'16'
,
'392'
),
# Values computed according to xScale and yScale (cf. plot.js)
],
'plot_label'
:
'Teacher'
,
'plot_label_color'
:
HTMLColors
.
CORAL
,
'description'
:
None
,
'citation'
:
None
,
}
researchers_overlay
=
{
'selector'
:
'.plot-overlay.plot-overlay-1'
,
'num_points'
:
2
,
'point_color'
:
PointColors
.
CORNFLOWERBLUE
,
'titles'
:
[
'2 + 2 = 5: 4, 4'
,
'The answer to everything is 42: 1, 5'
],
'positions'
:
[
(
'16'
,
'384'
),
# Values computed according to xScale and yScale (cf. plot.js)
(
'4'
,
'380'
),
# Values computed according to xScale and yScale (cf. plot.js)
],
'plot_label'
:
'Researchers'
,
'plot_label_color'
:
HTMLColors
.
CORNFLOWERBLUE
,
'description'
:
'Responses of leading researchers in the field'
,
'citation'
:
None
,
}
sheldon_overlay
=
{
'selector'
:
'.plot-overlay.plot-overlay-2'
,
'num_points'
:
2
,
'point_color'
:
PointColors
.
OLIVE
,
'titles'
:
[
'2 + 2 = 5: 3, 5'
,
'The answer to everything is 42: 2, 4'
],
'positions'
:
[
(
'12'
,
'380'
),
# Values computed according to xScale and yScale (cf. plot.js)
(
'8'
,
'384'
),
# Values computed according to xScale and yScale (cf. plot.js)
],
'plot_label'
:
'Sheldon Cooper'
,
'plot_label_color'
:
HTMLColors
.
OLIVE
,
'description'
:
None
,
'citation'
:
'The Big Bang Theory'
,
}
yoda_overlay
=
{
'selector'
:
'.plot-overlay.plot-overlay-3'
,
'num_points'
:
2
,
'point_color'
:
PointColors
.
CRIMSON
,
'titles'
:
[
'2 + 2 = 5: 1, 2'
,
'The answer to everything is 42: 3, 3'
],
'positions'
:
[
(
'4'
,
'392'
),
# Values computed according to xScale and yScale (cf. plot.js)
(
'12'
,
'388'
),
# Values computed according to xScale and yScale (cf. plot.js)
],
'plot_label'
:
'Yoda'
,
'plot_label_color'
:
HTMLColors
.
CRIMSON
,
'description'
:
'Powerful you have become, the dark side I sense in you.'
,
'citation'
:
'Star Wars'
,
}
# Check if plot shows correct overlay(s) initially (default overlay on, additional overlays off)
self
.
check_overlays
(
step_builder
,
2
,
overlays
=
[
default_overlay
]
)
self
.
check_plot_info
(
step_builder
,
hidden
=
True
,
visible_overlays
=
[],
hidden_overlays
=
[
teacher_overlay
,
researchers_overlay
,
sheldon_overlay
,
yoda_overlay
]
)
# Turn on additional overlays one by one.
# - Check if plot shows correct overlay(s)
# - Check if block displays correct info about plot
# "Teacher" on
self
.
click_overlay_button
(
additional_plot_controls
.
teacher_button
,
overlay_on
=
True
,
color_on
=
HTMLColors
.
CORAL
)
self
.
check_overlays
(
step_builder
,
4
,
overlays
=
[
default_overlay
,
teacher_overlay
]
)
self
.
check_plot_info
(
step_builder
,
hidden
=
True
,
# "Teacher" overlay has no description/citation,
# so plot info as a whole should stay hidden
visible_overlays
=
[
teacher_overlay
],
hidden_overlays
=
[
researchers_overlay
,
sheldon_overlay
,
yoda_overlay
]
)
# "Researchers" on
self
.
click_overlay_button
(
additional_plot_controls
.
researchers_button
,
overlay_on
=
True
,
color_on
=
HTMLColors
.
CORNFLOWERBLUE
)
self
.
check_overlays
(
step_builder
,
6
,
overlays
=
[
default_overlay
,
teacher_overlay
,
researchers_overlay
]
)
self
.
check_plot_info
(
step_builder
,
hidden
=
False
,
visible_overlays
=
[
teacher_overlay
,
researchers_overlay
],
hidden_overlays
=
[
sheldon_overlay
,
yoda_overlay
]
)
# "Sheldon Cooper" on
self
.
click_overlay_button
(
additional_plot_controls
.
sheldon_button
,
overlay_on
=
True
,
color_on
=
HTMLColors
.
OLIVE
)
self
.
check_overlays
(
step_builder
,
8
,
overlays
=
[
default_overlay
,
teacher_overlay
,
researchers_overlay
,
sheldon_overlay
]
)
self
.
check_plot_info
(
step_builder
,
hidden
=
False
,
visible_overlays
=
[
teacher_overlay
,
researchers_overlay
,
sheldon_overlay
],
hidden_overlays
=
[
yoda_overlay
]
)
# "Yoda" on
self
.
click_overlay_button
(
additional_plot_controls
.
yoda_button
,
overlay_on
=
True
,
color_on
=
HTMLColors
.
CRIMSON
)
self
.
check_overlays
(
step_builder
,
10
,
overlays
=
[
default_overlay
,
teacher_overlay
,
researchers_overlay
,
sheldon_overlay
,
yoda_overlay
]
)
self
.
check_plot_info
(
step_builder
,
hidden
=
False
,
visible_overlays
=
[
teacher_overlay
,
researchers_overlay
,
sheldon_overlay
,
yoda_overlay
],
hidden_overlays
=
[]
)
# Turn off additional overlays one by one.
# - Check if plot shows correct overlay(s)
# - Check if block displays correct info about plot
# "Yoda" off
self
.
click_overlay_button
(
additional_plot_controls
.
yoda_button
,
overlay_on
=
False
)
self
.
check_overlays
(
step_builder
,
8
,
overlays
=
[
default_overlay
,
teacher_overlay
,
researchers_overlay
,
sheldon_overlay
]
)
self
.
check_plot_info
(
step_builder
,
hidden
=
False
,
visible_overlays
=
[
teacher_overlay
,
researchers_overlay
,
sheldon_overlay
],
hidden_overlays
=
[
yoda_overlay
]
)
# "Sheldon Cooper" off
self
.
click_overlay_button
(
additional_plot_controls
.
sheldon_button
,
overlay_on
=
False
)
self
.
check_overlays
(
step_builder
,
6
,
overlays
=
[
default_overlay
,
teacher_overlay
,
researchers_overlay
]
)
self
.
check_plot_info
(
step_builder
,
hidden
=
False
,
visible_overlays
=
[
teacher_overlay
,
researchers_overlay
],
hidden_overlays
=
[
sheldon_overlay
,
yoda_overlay
]
)
# "Researchers" off
self
.
click_overlay_button
(
additional_plot_controls
.
researchers_button
,
overlay_on
=
False
)
self
.
check_overlays
(
step_builder
,
4
,
overlays
=
[
default_overlay
,
teacher_overlay
]
)
self
.
check_plot_info
(
step_builder
,
hidden
=
True
,
# "Teacher" overlay has no description/citation,
# so plot info should be hidden at this point
visible_overlays
=
[
teacher_overlay
],
hidden_overlays
=
[
researchers_overlay
,
sheldon_overlay
,
yoda_overlay
]
)
# "Teacher" off
self
.
click_overlay_button
(
additional_plot_controls
.
teacher_button
,
overlay_on
=
False
)
self
.
check_overlays
(
step_builder
,
2
,
overlays
=
[
default_overlay
]
)
self
.
check_plot_info
(
step_builder
,
hidden
=
True
,
visible_overlays
=
[],
hidden_overlays
=
[
teacher_overlay
,
researchers_overlay
,
sheldon_overlay
,
yoda_overlay
]
)
# When deactivating an overlay that has no description/citation,
# visibility of information about remaining overlays that are currently active
# should not be affected:
# "Yoda" on:
self
.
click_overlay_button
(
additional_plot_controls
.
yoda_button
,
overlay_on
=
True
,
color_on
=
HTMLColors
.
CRIMSON
)
self
.
check_overlays
(
step_builder
,
4
,
overlays
=
[
default_overlay
,
yoda_overlay
]
)
self
.
check_plot_info
(
step_builder
,
hidden
=
False
,
# Plot info becomes visible
visible_overlays
=
[
yoda_overlay
],
hidden_overlays
=
[
teacher_overlay
,
researchers_overlay
,
sheldon_overlay
]
)
# "Teacher" on:
self
.
click_overlay_button
(
additional_plot_controls
.
teacher_button
,
overlay_on
=
True
,
color_on
=
HTMLColors
.
CORAL
)
self
.
check_overlays
(
step_builder
,
6
,
overlays
=
[
default_overlay
,
yoda_overlay
,
teacher_overlay
]
)
self
.
check_plot_info
(
step_builder
,
hidden
=
False
,
visible_overlays
=
[
yoda_overlay
,
teacher_overlay
],
hidden_overlays
=
[
researchers_overlay
,
sheldon_overlay
]
)
# "Teacher" off:
self
.
click_overlay_button
(
additional_plot_controls
.
teacher_button
,
overlay_on
=
False
)
self
.
check_overlays
(
step_builder
,
4
,
overlays
=
[
default_overlay
,
yoda_overlay
]
)
self
.
check_plot_info
(
step_builder
,
hidden
=
False
,
# Plot info stays visible
visible_overlays
=
[
yoda_overlay
],
hidden_overlays
=
[
teacher_overlay
,
researchers_overlay
,
sheldon_overlay
],
)
# "Yoda" off:
self
.
click_overlay_button
(
additional_plot_controls
.
yoda_button
,
overlay_on
=
False
)
self
.
check_overlays
(
step_builder
,
2
,
overlays
=
[
default_overlay
]
)
self
.
check_plot_info
(
step_builder
,
hidden
=
True
,
# Last remaining overlay with description/citation deactivated;
# plot info now hidden
visible_overlays
=
[],
hidden_overlays
=
[
teacher_overlay
,
researchers_overlay
,
sheldon_overlay
,
yoda_overlay
]
)
problem_builder/tests/integration/xml_templates/step_builder_plot_overlays.xml
0 → 100644
View file @
4ee4532b
<step-builder
url_name=
"step-builder"
display_name=
"Step Builder"
>
<sb-step
display_name=
"First step"
>
<pb-rating
name=
"rating_1_1"
low=
"Disagree"
high=
"Agree"
question=
"How much do you agree?"
correct_choices=
'["1", "2", "3", "4","5"]'
>
</pb-rating>
<pb-rating
name=
"rating_1_2"
low=
"Not important"
high=
"Very important"
question=
"How important do you think this is?"
correct_choices=
'["1", "2", "3", "4","5"]'
>
</pb-rating>
</sb-step>
<sb-step
display_name=
"Second step"
>
<pb-rating
name=
"rating_2_1"
low=
"Disagree"
high=
"Agree"
question=
"How much do you agree?"
correct_choices=
'["1", "2", "3", "4","5"]'
>
</pb-rating>
<pb-rating
name=
"rating_2_2"
low=
"Not important"
high=
"Very important"
question=
"How important do you think this is?"
correct_choices=
'["1", "2", "3", "4","5"]'
>
</pb-rating>
</sb-step>
<sb-step
display_name=
"Last step"
>
<sb-plot
plot_label=
"Custom plot label"
point_color_default=
"orange"
point_color_average=
"purple"
q1_label=
"Custom Q1 label"
q2_label=
"Custom Q2 label"
q3_label=
"Custom Q3 label"
q4_label=
"Custom Q4 label"
claims=
"2 + 2 = 5, rating_1_1, rating_1_2 The answer to everything is 42, rating_2_1, rating_2_2"
>
<sb-plot-overlay
plot_label=
"Teacher"
point_color=
"coral"
claim_data=
"2, 3 4, 2"
>
</sb-plot-overlay>
<sb-plot-overlay
plot_label=
"Researchers"
point_color=
"cornflowerblue"
description=
"Responses of leading researchers in the field"
claim_data=
"4, 4 1, 5"
>
</sb-plot-overlay>
<sb-plot-overlay
plot_label=
"Sheldon Cooper"
point_color=
"rgb(128, 128, 0)"
citation=
"The Big Bang Theory"
claim_data=
"3, 5 2, 4"
>
</sb-plot-overlay>
<sb-plot-overlay
plot_label=
"Yoda"
point_color=
"#dc143c"
description=
"Powerful you have become, the dark side I sense in you."
citation=
"Star Wars"
claim_data=
"1, 2 3, 3"
>
</sb-plot-overlay>
</sb-plot>
</sb-step>
<sb-review-step></sb-review-step>
</step-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