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
e8ca0073
Commit
e8ca0073
authored
Oct 16, 2015
by
Piotr Mitros
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
i18n, p_r becomes p_user
parent
75df8df4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
13 deletions
+12
-13
rate/rate.py
+12
-13
No files found.
rate/rate.py
View file @
e8ca0073
...
...
@@ -31,7 +31,7 @@ except ImportError:
""" In workbench, do nothing for event emission """
pass
@XBlock.needs
(
'i18n'
)
class
RateXBlock
(
XBlock
):
"""
This is an XBlock -- eventually, hopefully an aside -- which
...
...
@@ -39,12 +39,6 @@ class RateXBlock(XBlock):
long time, but Dartmouth finally encourage me to start to build
this.
"""
default_prompt
=
{
'freeform'
:
"Please provide us feedback on this section."
,
'likert'
:
"Please rate your overall experience with this section."
,
'mouseovers'
:
[
"Excellent"
,
"Good"
,
"Average"
,
"Fair"
,
"Poor"
],
'icons'
:
[
u"😁"
,
u"😊"
,
u"😐"
,
u"😞"
,
u"😭"
]}
# This is a list of prompts. If we have multiple elements in the
# list, one will be chosen at random. This is currently not
# exposed in the UX. If the prompt is missing any portions, we
...
...
@@ -72,7 +66,7 @@ class RateXBlock(XBlock):
help
=
"What percent of the time should this show?"
)
p_r
=
Float
(
p_
use
r
=
Float
(
default
=-
1
,
scope
=
Scope
.
user_state
,
help
=
"Random number generated for p. -1 if uninitialized"
)
...
...
@@ -102,7 +96,12 @@ class RateXBlock(XBlock):
randomization if necessary, and falling back to defaults when
necessary.
"""
prompt
=
dict
(
self
.
default_prompt
)
_
=
self
.
runtime
.
service
(
self
,
'i18n'
)
.
ugettext
prompt
=
{
'freeform'
:
_
(
"Please provide us feedback on this section."
),
'likert'
:
_
(
"Please rate your overall experience with this section."
),
'mouseovers'
:
[
_
(
"Excellent"
),
_
(
"Good"
),
_
(
"Average"
),
_
(
"Fair"
),
_
(
"Poor"
)],
'icons'
:
[
u"😁"
,
u"😊"
,
u"😐"
,
u"😞"
,
u"😭"
]}
prompt
.
update
(
self
.
prompts
[
index
])
return
prompt
...
...
@@ -138,14 +137,14 @@ class RateXBlock(XBlock):
likert_prompt
=
prompt
[
'likert'
],
response
=
response
)
# We initialize self.p_r if not initialized -- this sets whether
# We initialize self.p_
use
r if not initialized -- this sets whether
# or not we show it. From there, if it is less than odds of showing,
# we set the fragment to the rendered XBlock. Otherwise, we return
# empty HTML. There ought to be a way to return None, but XBlocks
# doesn't support that.
if
self
.
p_r
==
-
1
:
self
.
p_r
=
random
.
uniform
(
0
,
100
)
if
self
.
p_r
<
self
.
p
:
if
self
.
p_
use
r
==
-
1
:
self
.
p_
use
r
=
random
.
uniform
(
0
,
100
)
if
self
.
p_
use
r
<
self
.
p
:
frag
=
Fragment
(
rendered
)
else
:
frag
=
Fragment
(
u""
)
...
...
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