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
5646645d
Commit
5646645d
authored
Apr 24, 2015
by
E. Kolpakov
Committed by
Jonathan Piacenti
Apr 24, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allowed overriding average labels per mentoring
parent
51a820ee
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
11 deletions
+42
-11
problem_builder/dashboard.py
+33
-6
problem_builder/templates/html/dashboard.html
+1
-1
problem_builder/tests/integration/test_dashboard.py
+8
-4
No files found.
problem_builder/dashboard.py
View file @
5646645d
...
...
@@ -221,10 +221,14 @@ class DashboardBlock(StudioEditableXBlockMixin, XBlock):
),
scope
=
Scope
.
content
,
)
average_label
=
String
(
average_label
s
=
Dict
(
display_name
=
_
(
"Label for average value"
),
default
=
_
(
"Average"
),
help
=
_
(
"Label to be shown for calculated average"
),
help
=
_
(
"This settings allows overriding label for the calculated average per mentoring block. Must be in JSON "
"format. Examples: {examples_here}."
)
.
format
(
examples_here
=
'{"2754b8afc03a439693b9887b6f1d9e36": "Avg.", "215028f7df3d4c68b14fb5fea4da7053": "Mean"}'
),
scope
=
Scope
.
content
,
)
show_numbers
=
Boolean
(
...
...
@@ -235,7 +239,7 @@ class DashboardBlock(StudioEditableXBlockMixin, XBlock):
)
editable_fields
=
(
'display_name'
,
'mentoring_ids'
,
'exclude_questions'
,
'average_label'
,
'show_numbers'
,
'display_name'
,
'mentoring_ids'
,
'exclude_questions'
,
'average_label
s
'
,
'show_numbers'
,
'color_rules'
,
'visual_rules'
,
'visual_title'
,
'visual_desc'
)
css_path
=
'public/css/dashboard.css'
...
...
@@ -408,6 +412,7 @@ class DashboardBlock(StudioEditableXBlockMixin, XBlock):
if
numeric_values
:
average_value
=
sum
(
numeric_values
)
/
len
(
numeric_values
)
block
[
'average'
]
=
average_value
block
[
'average_label'
]
=
self
.
average_labels
.
get
(
mentoring_block
.
url_name
,
_
(
"Average"
))
block
[
'has_average'
]
=
True
block
[
'average_color'
]
=
self
.
color_for_value
(
average_value
)
blocks
.
append
(
block
)
...
...
@@ -434,7 +439,6 @@ class DashboardBlock(StudioEditableXBlockMixin, XBlock):
'blocks'
:
blocks
,
'display_name'
:
self
.
display_name
,
'visual_repr'
:
visual_repr
,
'average_label'
:
self
.
average_label
,
'show_numbers'
:
self
.
show_numbers
,
})
...
...
@@ -462,10 +466,33 @@ class DashboardBlock(StudioEditableXBlockMixin, XBlock):
for
key
,
value
in
data
.
exclude_questions
.
iteritems
():
if
not
isinstance
(
value
,
list
):
add_error
(
_
(
u"Exclude questions is malformed: value for key {key} is {value}, expected list of integers"
)
_
(
u"'Questions to be hidden' is malformed: value for key {key} is {value}, "
u"expected list of integers"
)
.
format
(
key
=
key
,
value
=
value
)
)
if
key
not
in
data
.
mentoring_ids
:
add_error
(
_
(
u"'Questions to be hidden' is malformed: mentoring url_name {url_name} "
u"is not added to Dashboard"
)
.
format
(
url_name
=
key
)
)
if
data
.
average_labels
:
for
key
,
value
in
data
.
average_labels
.
iteritems
():
if
not
isinstance
(
value
,
basestring
):
add_error
(
_
(
u"'Label for average value' is malformed: value for key {key} is {value}, expected string"
)
.
format
(
key
=
key
,
value
=
value
)
)
if
key
not
in
data
.
mentoring_ids
:
add_error
(
_
(
u"'Label for average value' is malformed: mentoring url_name {url_name} "
u"is not added to Dashboard"
)
.
format
(
url_name
=
key
)
)
if
data
.
color_rules
:
try
:
self
.
parse_color_rules_str
(
data
.
color_rules
,
ignore_errors
=
False
)
...
...
problem_builder/templates/html/dashboard.html
View file @
5646645d
...
...
@@ -56,7 +56,7 @@
{% endfor %}
{% if block.has_average %}
<tr
class=
"avg-row"
>
<th
class=
"desc"
>
{{ average_label }}
</th>
<th
class=
"desc"
>
{{
block.
average_label }}
</th>
<td
class=
"value"
{%
if
block
.
average_color
%}
style=
"border-right-color: {{block.average_color}};"
{%
endif
%}
{%
if
not
show_numbers
%}
...
...
problem_builder/tests/integration/test_dashboard.py
View file @
5646645d
...
...
@@ -58,11 +58,13 @@ class TestDashboardBlock(SeleniumXBlockTest):
"""
SIMPLE_DASHBOARD
=
"""<pb-dashboard mentoring_ids='["dummy-value"]'/>"""
ALTERNATIVE_DASHBOARD
=
dedent
(
"""
<pb-dashboard mentoring_ids='["dummy-value"]' average_label="Avg." show_numbers="false"/>
<pb-dashboard mentoring_ids='["dummy-value"]' show_numbers="false"
average_labels='{"Step 1": "Avg.", "Step 2":"Mean", "Step 3":"Second Quartile"}'
/>
"""
)
HIDE_QUESTIONS_DASHBOARD
=
dedent
(
"""
<pb-dashboard mentoring_ids='["dummy-value"]'
exclude_questions='{"Step 1": [2, 3], "Step 2":[3], "Step 3":[2]}'
exclude_questions='{"Step 1": [2, 3], "Step 2":[3], "Step 3":[2]}'
/>
"""
)
MALFORMED_HIDE_QUESTIONS_DASHBOARD
=
dedent
(
"""
...
...
@@ -185,7 +187,9 @@ class TestDashboardBlock(SeleniumXBlockTest):
steps
=
dashboard
.
find_elements_by_css_selector
(
'tbody'
)
self
.
assertEqual
(
len
(
steps
),
3
)
for
step
in
steps
:
average_labels
=
[
"Avg."
,
"Mean"
,
"Second Quartile"
]
for
step_num
,
step
in
enumerate
(
steps
):
mcq_rows
=
step
.
find_elements_by_css_selector
(
'tr:not(.avg-row)'
)
self
.
assertTrue
(
2
<=
len
(
mcq_rows
)
<=
3
)
for
mcq
in
mcq_rows
:
...
...
@@ -194,7 +198,7 @@ class TestDashboardBlock(SeleniumXBlockTest):
# Check the average:
avg_row
=
step
.
find_element_by_css_selector
(
'tr.avg-row'
)
left_col
=
avg_row
.
find_element_by_css_selector
(
'.desc'
)
self
.
assertEqual
(
left_col
.
text
,
"Avg."
)
self
.
assertEqual
(
left_col
.
text
,
average_labels
[
step_num
]
)
right_col
=
avg_row
.
find_element_by_css_selector
(
'.value'
)
self
.
assertEqual
(
right_col
.
text
,
""
)
...
...
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