Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
RateXBlock
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
RateXBlock
Commits
a801462b
Commit
a801462b
authored
Dec 18, 2015
by
Piotr Mitros
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test case
parent
2d828eed
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
103 additions
and
6 deletions
+103
-6
rate/rate.py
+4
-5
ratetests/__init__.py
+1
-0
ratetests/test_rate.py
+93
-0
setup.py
+5
-1
No files found.
rate/rate.py
View file @
a801462b
...
@@ -17,8 +17,6 @@ from xblock.fragment import Fragment
...
@@ -17,8 +17,6 @@ from xblock.fragment import Fragment
We provide default text which is designed to elicit student thought. We'd
We provide default text which is designed to elicit student thought. We'd
like instructors to customize this to something highly structured (not
like instructors to customize this to something highly structured (not
"What did you think?" and "How did you like it?".
"What did you think?" and "How did you like it?".
We
"""
"""
default_freeform
=
"What did you learn from this? What was missing?"
default_freeform
=
"What did you learn from this? What was missing?"
default_likert
=
"How would you rate this as a learning experience?"
default_likert
=
"How would you rate this as a learning experience?"
...
@@ -46,7 +44,8 @@ class RateXBlock(XBlock):
...
@@ -46,7 +44,8 @@ class RateXBlock(XBlock):
default
=
[
default
=
[
{
'freeform'
:
default_freeform
,
{
'freeform'
:
default_freeform
,
'default_text'
:
default_default
,
'default_text'
:
default_default
,
'likert'
:
default_likert
}
'likert'
:
default_likert
,
'placeholder'
:
default_placeholder
}
],
],
scope
=
Scope
.
settings
,
scope
=
Scope
.
settings
,
help
=
"Freeform user prompt"
,
help
=
"Freeform user prompt"
,
...
@@ -113,7 +112,8 @@ class RateXBlock(XBlock):
...
@@ -113,7 +112,8 @@ class RateXBlock(XBlock):
_
(
"Average"
),
_
(
"Average"
),
_
(
"Fair"
),
_
(
"Fair"
),
_
(
"Poor"
)],
_
(
"Poor"
)],
'icons'
:
[
u"😁"
,
u"😊"
,
u"😐"
,
u"😞"
,
u"😭"
]
'icons'
:
[
u"😁"
,
u"😊"
,
u"😐"
,
u"😞"
,
u"😭"
],
'placeholder'
:
[
"Please take a moment to thoughtfully reflect."
]
}
}
prompt
.
update
(
self
.
prompts
[
index
])
prompt
.
update
(
self
.
prompts
[
index
])
...
@@ -253,7 +253,6 @@ class RateXBlock(XBlock):
...
@@ -253,7 +253,6 @@ class RateXBlock(XBlock):
def
init_vote_aggregate
(
self
):
def
init_vote_aggregate
(
self
):
# Make sure we're initialized
# Make sure we're initialized
print
self
.
get_prompt
()
if
not
self
.
vote_aggregate
:
if
not
self
.
vote_aggregate
:
self
.
vote_aggregate
=
[
0
]
*
(
len
(
self
.
get_prompt
()[
'scale_text'
]))
self
.
vote_aggregate
=
[
0
]
*
(
len
(
self
.
get_prompt
()[
'scale_text'
]))
...
...
ratetests/__init__.py
0 → 100644
View file @
a801462b
from
.test_rate
import
TestRate
ratetests/test_rate.py
0 → 100644
View file @
a801462b
'''
Tests for the RateXBlock.
'''
import
json
from
openedx.tests.xblock_integration.xblock_testcase
import
XBlockTestCase
# pylint: disable=abstract-method
class
TestRate
(
XBlockTestCase
):
"""
Basic tests for the RateXBlock. We set up a page with two
of the block, make sure the page renders, toggle a few ratings,
and call it quits.
"""
olx_scenarios
=
{
# Currently not used
"two_rate_block_test_case"
:
"""<vertical>
<rate urlname="rate0"/>
<rate urlname="rate1"/>
</vertical>"""
}
# This is a stop-gap until we can load OLX and/or OLX from
# normal workbench scenarios
test_configuration
=
[
{
"urlname"
:
"two_rate_block_test_case"
,
"xblocks"
:
[
# Stopgap until we handle OLX
{
'blocktype'
:
'rate'
,
'urlname'
:
'rate_0'
},
{
'blocktype'
:
'rate'
,
'urlname'
:
'rate_1'
}
]
}
]
def
submit_feedback
(
self
,
block
,
data
,
desired_state
):
"""
Make an AJAX call to the XBlock, and assert the state is as
desired.
"""
resp
=
self
.
ajax
(
'feedback'
,
block
,
data
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
print
json
.
dumps
(
resp
.
data
,
indent
=
2
)
print
json
.
dumps
(
desired_state
,
indent
=
2
)
# pylint: disable=no-member
self
.
assertEqual
(
resp
.
data
,
desired_state
)
# pylint: disable=unused-argument
def
check_response
(
self
,
block_urlname
,
rendering
):
"""
Confirm that we have a 200 response code (no server error)
In the future, visual diff test the response.
"""
response
=
self
.
render_block
(
block_urlname
)
self
.
assertEqual
(
response
.
status_code
,
200
)
# To do: Below method needs to be implemented
# self.assertXBlockScreenshot(block_urlname, rendering)
def
test_rate
(
self
):
"""
Walk through a few toggles. Make sure the blocks don't mix up
state between them, initial state is correct, and final state
is correct.
"""
# We confirm we don't have errors rendering the student view
self
.
check_response
(
'rate_0'
,
'rate-unset'
)
self
.
check_response
(
'rate_1'
,
'rate-unset'
)
vote_str
=
'Thank you for voting!'
feedback_str
=
'Thank you for your feedback!'
self
.
submit_feedback
(
'rate_0'
,
{
'freeform'
:
'Worked well'
,
'vote'
:
3
},
{
'freeform'
:
'Worked well'
,
'vote'
:
3
,
'response'
:
vote_str
,
'success'
:
True
})
self
.
submit_feedback
(
'rate_0'
,
{
'vote'
:
4
},
{
'freeform'
:
'Worked well'
,
'vote'
:
4
,
'response'
:
vote_str
,
'success'
:
True
})
self
.
submit_feedback
(
'rate_0'
,
{
'freeform'
:
'Worked great'
},
{
'freeform'
:
'Worked great'
,
'vote'
:
4
,
'response'
:
feedback_str
,
'success'
:
True
})
# And confirm we render correctly
self
.
check_response
(
'rate_0'
,
'rate-unset'
)
self
.
check_response
(
'rate_1'
,
'rate-set'
)
setup.py
View file @
a801462b
...
@@ -22,10 +22,11 @@ def package_data(pkg, roots):
...
@@ -22,10 +22,11 @@ def package_data(pkg, roots):
setup
(
setup
(
name
=
'rate-xblock'
,
name
=
'rate-xblock'
,
version
=
'0.
1
'
,
version
=
'0.
0
'
,
description
=
'rate XBlock'
,
# TODO: write a better description.
description
=
'rate XBlock'
,
# TODO: write a better description.
packages
=
[
packages
=
[
'rate'
,
'rate'
,
'ratetests'
],
],
install_requires
=
[
install_requires
=
[
'XBlock'
,
'XBlock'
,
...
@@ -33,6 +34,9 @@ setup(
...
@@ -33,6 +34,9 @@ setup(
entry_points
=
{
entry_points
=
{
'xblock.v1'
:
[
'xblock.v1'
:
[
'rate = rate:RateXBlock'
,
'rate = rate:RateXBlock'
,
],
'xblock.test.v0'
:
[
'ratetest = ratetests:TestRate'
,
]
]
},
},
package_data
=
package_data
(
"rate"
,
[
"static"
,
"public"
]),
package_data
=
package_data
(
"rate"
,
[
"static"
,
"public"
]),
...
...
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