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
73dc9e64
Commit
73dc9e64
authored
Oct 06, 2015
by
Piotr Mitros
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Accessible
parent
ad47fb57
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
23 deletions
+33
-23
rate/rate.py
+2
-2
rate/static/css/rate.css
+26
-2
rate/static/html/rate.html
+1
-1
rate/static/js/src/rate.js
+4
-18
No files found.
rate/rate.py
View file @
73dc9e64
...
@@ -106,9 +106,9 @@ class RateXBlock(XBlock):
...
@@ -106,9 +106,9 @@ class RateXBlock(XBlock):
# Now, we render the RateXBlock. This may be redundant, since we
# Now, we render the RateXBlock. This may be redundant, since we
# don't always show it.
# don't always show it.
html
=
self
.
resource_string
(
"static/html/rate.html"
)
html
=
self
.
resource_string
(
"static/html/rate.html"
)
scale_item
=
u'<
span class="rate_likert_rating rate_rating_{i} {active}" title="{level}">{icon}</span
>'
scale_item
=
u'<
input id="radio_{i}" type="radio" name="rate_scale" class="rate_radio" title="{level}" {active}><label for="radio_{i}" title="{level}">{icon}<span class="rate_sr_text">{level}</span></label></input
>'
indexes
=
range
(
len
(
prompt
[
'icons'
]))
indexes
=
range
(
len
(
prompt
[
'icons'
]))
active_vote
=
[
"
rate_rating_active
"
if
i
==
self
.
user_vote
else
""
for
i
in
indexes
]
active_vote
=
[
"
checked
"
if
i
==
self
.
user_vote
else
""
for
i
in
indexes
]
scale
=
u""
.
join
(
scale_item
.
format
(
level
=
level
,
icon
=
icon
,
i
=
i
,
active
=
active
)
for
(
level
,
icon
,
i
,
active
)
in
zip
(
prompt
[
'mouseovers'
],
prompt
[
'icons'
],
indexes
,
active_vote
))
scale
=
u""
.
join
(
scale_item
.
format
(
level
=
level
,
icon
=
icon
,
i
=
i
,
active
=
active
)
for
(
level
,
icon
,
i
,
active
)
in
zip
(
prompt
[
'mouseovers'
],
prompt
[
'icons'
],
indexes
,
active_vote
))
rendered
=
html
.
format
(
self
=
self
,
scale
=
scale
,
string_prompt
=
prompt
[
'string'
],
likert_prompt
=
prompt
[
'likert'
])
rendered
=
html
.
format
(
self
=
self
,
scale
=
scale
,
string_prompt
=
prompt
[
'string'
],
likert_prompt
=
prompt
[
'likert'
])
...
...
rate/static/css/rate.css
View file @
73dc9e64
...
@@ -32,4 +32,29 @@
...
@@ -32,4 +32,29 @@
color
:
blue
;
color
:
blue
;
font-weight
:
bold
;
font-weight
:
bold
;
background-color
:
blanchedalmond
;
background-color
:
blanchedalmond
;
}
}
\ No newline at end of file
.rate_block
.rate_radio
{
opacity
:
0
;
width
:
0
;
padding
:
0
;
margin
:
0
;
}
.rate_block
.rate_sr_text
{
opacity
:
0
;
width
:
1px
;
height
:
1px
;
padding
:
0
;
margin
:
0
;
position
:
absolute
;
clip
:
rect
(
1px
,
1px
,
1px
,
1px
);
left
:
-10000px
;
overflow
:
hidden
;
}
.rate_block
input
[
type
=
"radio"
]
:checked
+
label
{
background-color
:
yellow
;
font-weight
:
bold
;
}
rate/static/html/rate.html
View file @
73dc9e64
...
@@ -5,5 +5,5 @@
...
@@ -5,5 +5,5 @@
<div
class=
"rate_thank_you"
>
Thank you!
</div>
<div
class=
"rate_thank_you"
>
Thank you!
</div>
</div>
</div>
<div
class=
"rate_likert_header"
>
{likert_prompt}
</div>
<div
class=
"rate_likert_header"
>
{likert_prompt}
</div>
<div
class=
"rate_likert_scale"
>
{scale}
</div>
<div
class=
"rate_likert_scale"
>
<form
action=
""
>
{scale}
</form>
</div>
</div>
</div>
rate/static/js/src/rate.js
View file @
73dc9e64
...
@@ -16,19 +16,15 @@ function RateXBlock(runtime, element) {
...
@@ -16,19 +16,15 @@ function RateXBlock(runtime, element) {
var
vote_handler
=
runtime
.
handlerUrl
(
element
,
'vote'
);
var
vote_handler
=
runtime
.
handlerUrl
(
element
,
'vote'
);
var
feedback_handler
=
runtime
.
handlerUrl
(
element
,
'feedback'
);
var
feedback_handler
=
runtime
.
handlerUrl
(
element
,
'feedback'
);
$
(
'.rate_likert_rating'
,
element
).
click
(
function
(
eventObject
)
{
$
(
'.rate_radio'
,
element
).
change
(
function
(
eventObject
)
{
var
vote_class
=
eventObject
.
currentTarget
.
className
.
split
(
' '
).
find
(
function
f
(
x
)
{
return
x
.
startsWith
(
"rate_rating_"
)
}
)
target_id
=
eventObject
.
target
.
id
;
var
vote
=
parseInt
(
vote_class
.
split
(
'_'
)[
2
]);
vote
=
parseInt
(
target_id
.
split
(
'_'
)[
1
]);
$
(
'.rate_rating_active'
,
element
).
removeClass
(
"rate_rating_active"
);
$
(
'.'
+
vote_class
,
element
).
addClass
(
"rate_rating_active"
);
Logger
.
log
(
"edx.ratexblock.likert_rate"
,
{
"vote"
:
vote
})
$
.
ajax
({
$
.
ajax
({
type
:
"POST"
,
type
:
"POST"
,
url
:
vote_handler
,
url
:
vote_handler
,
data
:
JSON
.
stringify
({
"vote"
:
vote
}),
data
:
JSON
.
stringify
({
"vote"
:
vote
}),
});
});
Logger
.
log
(
"edx.ratexblock.likert_rate"
,
{
"vote"
:
vote
})
});
});
$
(
'.rate_string_area'
,
element
).
change
(
function
(
eventObject
)
{
$
(
'.rate_string_area'
,
element
).
change
(
function
(
eventObject
)
{
...
@@ -44,13 +40,3 @@ function RateXBlock(runtime, element) {
...
@@ -44,13 +40,3 @@ function RateXBlock(runtime, element) {
});
});
}
}
/*
function updateCount(result) {
$('.count', element).text(result.count);
}
*/
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