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
7edb040e
Commit
7edb040e
authored
Jun 19, 2015
by
Piotr Mitros
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Javascript logging
parent
e52780e0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
4 deletions
+19
-4
rate/static/js/src/rate.js
+19
-4
No files found.
rate/static/js/src/rate.js
View file @
7edb040e
/* Javascript for RateXBlock. */
var
x
;
// Work-around so we can log in edx-platform, but not fail in Workbench
if
(
typeof
Logger
===
'undefined'
)
{
var
Logger
=
{
log
:
function
(
a
,
b
)
{
console
.
log
(
"<<Log>>"
);
console
.
log
(
a
);
console
.
log
(
b
);
console
.
log
(
"<</Log>>"
);
}
}
}
function
RateXBlock
(
runtime
,
element
)
{
var
vote_handler
=
runtime
.
handlerUrl
(
element
,
'vote'
);
var
feedback_handler
=
runtime
.
handlerUrl
(
element
,
'feedback'
);
$
(
'.rate_likert_rating'
,
element
).
click
(
function
(
eventObject
)
{
vote_class
=
eventObject
.
currentTarget
.
className
.
split
(
' '
).
find
(
function
f
(
x
)
{
return
x
.
startsWith
(
"rate_rating_"
)
}
)
vote
=
parseInt
(
vote_class
.
split
(
'_'
)[
2
]);
v
ar
v
ote_class
=
eventObject
.
currentTarget
.
className
.
split
(
' '
).
find
(
function
f
(
x
)
{
return
x
.
startsWith
(
"rate_rating_"
)
}
)
v
ar
v
ote
=
parseInt
(
vote_class
.
split
(
'_'
)[
2
]);
$
(
'.rate_rating_active'
,
element
).
removeClass
(
"rate_rating_active"
);
$
(
'.'
+
vote_class
,
element
).
addClass
(
"rate_rating_active"
);
Logger
.
log
(
"edx.recommender.likert_rate"
,
{
"vote"
:
vote
})
$
.
ajax
({
type
:
"POST"
,
url
:
vote_handler
,
...
...
@@ -20,10 +33,12 @@ 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.recommender.string_feedback"
,
{
"feedback"
:
feedback_string
})
$
.
ajax
({
type
:
"POST"
,
url
:
feedback_handler
,
data
:
JSON
.
stringify
({
"feedback"
:
eventObject
.
currentTarget
.
value
}),
data
:
JSON
.
stringify
({
"feedback"
:
feedback_string
}),
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