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
3c19fa3d
Commit
3c19fa3d
authored
Jun 19, 2015
by
Piotr Mitros
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Python logging
parent
7edb040e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
2 deletions
+28
-2
rate/rate.py
+26
-0
rate/static/js/src/rate.js
+2
-2
No files found.
rate/rate.py
View file @
3c19fa3d
...
...
@@ -11,6 +11,24 @@ from xblock.core import XBlock
from
xblock.fields
import
Scope
,
Integer
,
String
,
List
from
xblock.fragment
import
Fragment
try
:
from
eventtracking
import
tracker
except
ImportError
:
class
tracker
(
object
):
# pylint: disable=invalid-name
"""
Define tracker if eventtracking cannot be imported. This is a workaround
so that the code works in both edx-platform and XBlock workbench (the latter
of which does not support event emission). This should be replaced with XBlock's
emit(), but at present, emit() is broken.
"""
def
__init__
(
self
):
""" Do nothing """
pass
@staticmethod
def
emit
(
param1
,
param2
):
""" In workbench, do nothing for event emission """
pass
class
RateXBlock
(
XBlock
):
"""
...
...
@@ -91,12 +109,20 @@ class RateXBlock(XBlock):
if
self
.
user_vote
!=
-
1
:
self
.
vote_aggregate
[
self
.
user_vote
]
-=
1
tracker
.
emit
(
'edx.ratexblock.likert_rate'
,
{
'old_vote'
:
self
.
user_vote
,
'new_vote'
:
data
[
'vote'
]})
self
.
user_vote
=
data
[
'vote'
]
self
.
vote_aggregate
[
self
.
user_vote
]
+=
1
return
{
"success"
:
True
}
@XBlock.json_handler
def
feedback
(
self
,
data
,
suffix
=
''
):
tracker
.
emit
(
'edx.ratexblock.string_feedback'
,
{
'old_feedback'
:
self
.
user_feedback
,
'new_feedback'
:
data
[
'feedback'
]})
self
.
user_feedback
=
data
[
'feedback'
]
# TO-DO: change this to create the scenarios you'd like to see in the
...
...
rate/static/js/src/rate.js
View file @
3c19fa3d
...
...
@@ -22,7 +22,7 @@ function RateXBlock(runtime, element) {
$
(
'.rate_rating_active'
,
element
).
removeClass
(
"rate_rating_active"
);
$
(
'.'
+
vote_class
,
element
).
addClass
(
"rate_rating_active"
);
Logger
.
log
(
"edx.r
ecommender
.likert_rate"
,
{
"vote"
:
vote
})
Logger
.
log
(
"edx.r
atexblock
.likert_rate"
,
{
"vote"
:
vote
})
$
.
ajax
({
type
:
"POST"
,
...
...
@@ -34,7 +34,7 @@ function RateXBlock(runtime, element) {
$
(
'.rate_string_area'
,
element
).
change
(
function
(
eventObject
)
{
$
(
'.rate_thank_you'
,
element
).
css
(
'visibility'
,
'hidden'
);
var
feedback_string
=
eventObject
.
currentTarget
.
value
;
Logger
.
log
(
"edx.r
ecommender
.string_feedback"
,
{
"feedback"
:
feedback_string
})
Logger
.
log
(
"edx.r
atexblock
.string_feedback"
,
{
"feedback"
:
feedback_string
})
$
.
ajax
({
type
:
"POST"
,
url
:
feedback_handler
,
...
...
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