Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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
edx-platform
Commits
95a435ab
Commit
95a435ab
authored
Nov 10, 2014
by
Will Daly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Include course ID in analytics events for logistration
parent
a13f4f2f
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
74 additions
and
9 deletions
+74
-9
common/djangoapps/user_api/helpers.py
+14
-0
common/djangoapps/user_api/tests/test_helpers.py
+11
-0
common/djangoapps/user_api/views.py
+15
-1
lms/static/js/spec/student_account/login_spec.js
+0
-0
lms/static/js/spec/student_account/register_spec.js
+0
-0
lms/static/js/student_account/models/LoginModel.js
+17
-4
lms/static/js/student_account/models/RegisterModel.js
+17
-4
No files found.
common/djangoapps/user_api/helpers.py
View file @
95a435ab
...
...
@@ -343,6 +343,20 @@ def shim_student_view(view_func, check_logged_in=False):
if
"course_id"
in
request
.
POST
:
del
request
.
POST
[
"course_id"
]
# Include the course ID if it's specified in the analytics info
# so it can be included in analytics events.
if
"analytics"
in
request
.
POST
:
try
:
analytics
=
json
.
loads
(
request
.
POST
[
"analytics"
])
if
"enroll_course_id"
in
analytics
:
request
.
POST
[
"course_id"
]
=
analytics
.
get
(
"enroll_course_id"
)
except
(
ValueError
,
TypeError
):
LOGGER
.
error
(
u"Could not parse analytics object sent to user API: {analytics}"
.
format
(
analytics
=
analytics
)
)
# Backwards compatibility: the student view expects both
# terms of service and honor code values. Since we're combining
# these into a single checkbox, the only value we may get
...
...
common/djangoapps/user_api/tests/test_helpers.py
View file @
95a435ab
...
...
@@ -150,6 +150,17 @@ class StudentViewShimTest(TestCase):
self
.
assertNotIn
(
"enrollment_action"
,
self
.
captured_request
.
POST
)
self
.
assertNotIn
(
"course_id"
,
self
.
captured_request
.
POST
)
def
test_include_analytics_info
(
self
):
view
=
self
.
_shimmed_view
(
HttpResponse
())
request
=
HttpRequest
()
request
.
POST
[
"analytics"
]
=
json
.
dumps
({
"enroll_course_id"
:
"edX/DemoX/Fall"
})
view
(
request
)
# Expect that the analytics course ID was passed to the view
self
.
assertEqual
(
self
.
captured_request
.
POST
.
get
(
"course_id"
),
"edX/DemoX/Fall"
)
def
test_third_party_auth_login_failure
(
self
):
view
=
self
.
_shimmed_view
(
HttpResponse
(
status
=
403
),
...
...
common/djangoapps/user_api/views.py
View file @
95a435ab
...
...
@@ -133,6 +133,13 @@ class LoginSessionView(APIView):
def
post
(
self
,
request
):
"""Log in a user.
You must send all required form fields with the request.
You can optionally send an `analytics` param with a JSON-encoded
object with additional info to include in the login analytics event.
Currently, the only supported field is "enroll_course_id" to indicate
that the user logged in while enrolling in a particular course.
Arguments:
request (HttpRequest)
...
...
@@ -148,7 +155,7 @@ class LoginSessionView(APIView):
Example Usage:
POST /user_api/v1/login_session
with POST params `email`
and `password`
with POST params `email`
, `password`, and `remember`.
200 OK
...
...
@@ -246,6 +253,13 @@ class RegistrationView(APIView):
def
post
(
self
,
request
):
"""Create the user's account.
You must send all required form fields with the request.
You can optionally send an `analytics` param with a JSON-encoded
object with additional info to include in the registration analytics event.
Currently, the only supported field is "enroll_course_id" to indicate
that the user registered while enrolling in a particular course.
Arguments:
request (HTTPRequest)
...
...
lms/static/js/spec/student_account/login_spec.js
View file @
95a435ab
This diff is collapsed.
Click to expand it.
lms/static/js/spec/student_account/register_spec.js
View file @
95a435ab
This diff is collapsed.
Click to expand it.
lms/static/js/student_account/models/LoginModel.js
View file @
95a435ab
...
...
@@ -24,14 +24,27 @@ var edx = edx || {};
},
sync
:
function
(
method
,
model
)
{
var
headers
=
{
'X-CSRFToken'
:
$
.
cookie
(
'csrftoken'
)
};
var
headers
=
{
'X-CSRFToken'
:
$
.
cookie
(
'csrftoken'
)
},
data
=
{},
analytics
,
courseId
=
$
.
url
(
'?course_id'
);
// If there is a course ID in the query string param,
// send that to the server as well so it can be included
// in analytics events.
if
(
courseId
)
{
analytics
=
JSON
.
stringify
({
enroll_course_id
:
decodeURIComponent
(
courseId
)
});
}
// Include all form fields and analytics info in the data sent to the server
$
.
extend
(
data
,
model
.
attributes
,
{
analytics
:
analytics
});
$
.
ajax
({
url
:
model
.
urlRoot
,
type
:
model
.
ajaxType
,
data
:
model
.
attributes
,
data
:
data
,
headers
:
headers
,
success
:
function
()
{
model
.
trigger
(
'sync'
);
...
...
lms/static/js/student_account/models/RegisterModel.js
View file @
95a435ab
...
...
@@ -30,14 +30,27 @@ var edx = edx || {};
},
sync
:
function
(
method
,
model
)
{
var
headers
=
{
'X-CSRFToken'
:
$
.
cookie
(
'csrftoken'
)
};
var
headers
=
{
'X-CSRFToken'
:
$
.
cookie
(
'csrftoken'
)
},
data
=
{},
analytics
,
courseId
=
$
.
url
(
'?course_id'
);
// If there is a course ID in the query string param,
// send that to the server as well so it can be included
// in analytics events.
if
(
courseId
)
{
analytics
=
JSON
.
stringify
({
enroll_course_id
:
decodeURIComponent
(
courseId
)
});
}
// Include all form fields and analytics info in the data sent to the server
$
.
extend
(
data
,
model
.
attributes
,
{
analytics
:
analytics
});
$
.
ajax
({
url
:
model
.
urlRoot
,
type
:
model
.
ajaxType
,
data
:
model
.
attributes
,
data
:
data
,
headers
:
headers
,
success
:
function
()
{
model
.
trigger
(
'sync'
);
...
...
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