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
c766feb5
Commit
c766feb5
authored
Jun 18, 2015
by
Piotr Mitros
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MVP version. Ugly styling
parent
0e00e04c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
8 deletions
+26
-8
rate/rate.py
+5
-3
rate/static/css/rate.css
+14
-1
rate/static/html/rate.html
+1
-0
rate/static/js/src/rate.js
+6
-4
No files found.
rate/rate.py
View file @
c766feb5
...
@@ -68,8 +68,10 @@ class RateXBlock(XBlock):
...
@@ -68,8 +68,10 @@ class RateXBlock(XBlock):
when viewing courses.
when viewing courses.
"""
"""
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}" title="{level}">{icon}</span>'
scale_item
=
u'<span class="rate_likert_rating rate_rating_{i} {active}" title="{level}">{icon}</span>'
scale
=
u""
.
join
(
scale_item
.
format
(
level
=
level
,
icon
=
icon
,
i
=
i
)
for
(
level
,
icon
,
i
)
in
zip
(
self
.
mouseover_levels
,
self
.
mouseover_icons
,
range
(
len
(
self
.
mouseover_icons
))))
indexes
=
range
(
len
(
self
.
mouseover_icons
))
active_vote
=
[
" rate_rating_active "
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
(
self
.
mouseover_levels
,
self
.
mouseover_icons
,
indexes
,
active_vote
))
frag
=
Fragment
(
html
.
format
(
self
=
self
,
scale
=
scale
))
frag
=
Fragment
(
html
.
format
(
self
=
self
,
scale
=
scale
))
frag
.
add_css
(
self
.
resource_string
(
"static/css/rate.css"
))
frag
.
add_css
(
self
.
resource_string
(
"static/css/rate.css"
))
frag
.
add_javascript
(
self
.
resource_string
(
"static/js/src/rate.js"
))
frag
.
add_javascript
(
self
.
resource_string
(
"static/js/src/rate.js"
))
...
@@ -87,7 +89,7 @@ class RateXBlock(XBlock):
...
@@ -87,7 +89,7 @@ class RateXBlock(XBlock):
# Remove old vote if we voted before
# Remove old vote if we voted before
if
self
.
user_vote
!=
-
1
:
if
self
.
user_vote
!=
-
1
:
self
.
vote_aggregate
[
self
.
vote
]
-=
1
self
.
vote_aggregate
[
self
.
user_
vote
]
-=
1
self
.
user_vote
=
data
[
'vote'
]
self
.
user_vote
=
data
[
'vote'
]
self
.
vote_aggregate
[
self
.
user_vote
]
+=
1
self
.
vote_aggregate
[
self
.
user_vote
]
+=
1
...
...
rate/static/css/rate.css
View file @
c766feb5
...
@@ -9,6 +9,11 @@
...
@@ -9,6 +9,11 @@
padding
:
10px
padding
:
10px
}
}
.rate_thank_you
{
color
:
green
;
visibility
:
hidden
;
}
.rate_block
.rate_header
{
.rate_block
.rate_header
{
font-weight
:
bold
;
font-weight
:
bold
;
font-size
:
large
;
font-size
:
large
;
...
@@ -16,8 +21,15 @@
...
@@ -16,8 +21,15 @@
.rate_block
.rate_likert_rating
{
.rate_block
.rate_likert_rating
{
cursor
:
pointer
;
cursor
:
pointer
;
border-radius
:
5px
;
}
}
.rate_block
.rate_string_input
{
.rate_block
.rate_string_input
{
margin-bottom
:
2em
;
margin-bottom
:
1em
;
}
.rate_block
.rate_rating_active
{
color
:
blue
;
font-weight
:
bold
;
background-color
:
blanchedalmond
;
}
}
\ No newline at end of file
rate/static/html/rate.html
View file @
c766feb5
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
<div
class=
"rate_header"
>
{self.string_prompt}
</div>
<div
class=
"rate_header"
>
{self.string_prompt}
</div>
<div
class=
"rate_string_input"
>
<div
class=
"rate_string_input"
>
<textarea
class=
"rate_string_area"
rows=
"4"
cols=
"50"
>
{self.user_feedback}
</textarea>
<textarea
class=
"rate_string_area"
rows=
"4"
cols=
"50"
>
{self.user_feedback}
</textarea>
<div
class=
"rate_thank_you"
>
Thank you!
</div>
</div>
</div>
<div
class=
"rate_likert_header"
>
{self.likert_prompt}
</div>
<div
class=
"rate_likert_header"
>
{self.likert_prompt}
</div>
<div
class=
"rate_likert_scale"
>
{scale}
</div>
<div
class=
"rate_likert_scale"
>
{scale}
</div>
...
...
rate/static/js/src/rate.js
View file @
c766feb5
...
@@ -8,21 +8,23 @@ function RateXBlock(runtime, element) {
...
@@ -8,21 +8,23 @@ function RateXBlock(runtime, element) {
$
(
'.rate_likert_rating'
,
element
).
click
(
function
(
eventObject
)
{
$
(
'.rate_likert_rating'
,
element
).
click
(
function
(
eventObject
)
{
vote_class
=
eventObject
.
currentTarget
.
className
.
split
(
' '
).
find
(
function
f
(
x
)
{
return
x
.
startsWith
(
"rate_rating_"
)
}
)
vote_class
=
eventObject
.
currentTarget
.
className
.
split
(
' '
).
find
(
function
f
(
x
)
{
return
x
.
startsWith
(
"rate_rating_"
)
}
)
vote
=
parseInt
(
vote_class
.
split
(
'_'
)[
2
]);
vote
=
parseInt
(
vote_class
.
split
(
'_'
)[
2
]);
alert
(
vote
);
$
(
'.rate_rating_active'
,
element
).
removeClass
(
"rate_rating_active"
);
$
(
'.'
+
vote_class
,
element
).
addClass
(
"rate_rating_active"
);
$
.
ajax
({
$
.
ajax
({
type
:
"POST"
,
type
:
"POST"
,
url
:
vote_handler
,
url
:
vote_handler
,
data
:
JSON
.
stringify
({
"vote"
:
vote
_class
}),
data
:
JSON
.
stringify
({
"vote"
:
vote
}),
});
});
});
});
$
(
'.rate_string_area'
,
element
).
change
(
function
(
eventObject
)
{
$
(
'.rate_string_area'
,
element
).
change
(
function
(
eventObject
)
{
x
=
eventObject
$
(
'.rate_thank_you'
,
element
).
css
(
'visibility'
,
'hidden'
);
alert
(
eventObject
.
currentTarget
.
value
);
$
.
ajax
({
$
.
ajax
({
type
:
"POST"
,
type
:
"POST"
,
url
:
feedback_handler
,
url
:
feedback_handler
,
data
:
JSON
.
stringify
({
"feedback"
:
eventObject
.
currentTarget
.
value
}),
data
:
JSON
.
stringify
({
"feedback"
:
eventObject
.
currentTarget
.
value
}),
success
:
function
()
{
$
(
'.rate_thank_you'
,
element
).
css
(
'visibility'
,
'visible'
)},
});
});
});
});
...
...
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