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
17647abd
Commit
17647abd
authored
Jun 07, 2013
by
Greg Price
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add datadog reporting to the feedback submission mechanism
parent
976280e6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
68 additions
and
46 deletions
+68
-46
common/djangoapps/util/tests/test_submit_feedback.py
+0
-0
common/djangoapps/util/views.py
+64
-42
lms/templates/help_modal.html
+3
-3
lms/urls.py
+1
-1
No files found.
common/djangoapps/util/tests/test_
zendes
k.py
→
common/djangoapps/util/tests/test_
submit_feedbac
k.py
View file @
17647abd
This diff is collapsed.
Click to expand it.
common/djangoapps/util/views.py
View file @
17647abd
...
@@ -12,6 +12,7 @@ from django.core.validators import ValidationError, validate_email
...
@@ -12,6 +12,7 @@ from django.core.validators import ValidationError, validate_email
from
django.http
import
Http404
,
HttpResponse
,
HttpResponseBadRequest
,
HttpResponseNotAllowed
,
HttpResponseServerError
from
django.http
import
Http404
,
HttpResponse
,
HttpResponseBadRequest
,
HttpResponseNotAllowed
,
HttpResponseServerError
from
django.shortcuts
import
redirect
from
django.shortcuts
import
redirect
from
django_future.csrf
import
ensure_csrf_cookie
from
django_future.csrf
import
ensure_csrf_cookie
from
dogapi
import
dog_stats_api
from
mitxmako.shortcuts
import
render_to_response
,
render_to_string
from
mitxmako.shortcuts
import
render_to_response
,
render_to_string
from
urllib
import
urlencode
from
urllib
import
urlencode
import
zendesk
import
zendesk
...
@@ -73,11 +74,63 @@ class _ZendeskApi(object):
...
@@ -73,11 +74,63 @@ class _ZendeskApi(object):
self
.
_zendesk_instance
.
update_ticket
(
ticket_id
=
ticket_id
,
data
=
update
)
self
.
_zendesk_instance
.
update_ticket
(
ticket_id
=
ticket_id
,
data
=
update
)
def
submit_feedback_via_zendesk
(
request
):
def
_record_feedback_in_zendesk
(
realname
,
email
,
subject
,
details
,
tags
,
additional_info
):
"""
"""
Create a new user-requested Zendesk ticket.
Create a new user-requested Zendesk ticket.
If Zendesk submission is not enabled, any request will raise `Http404`.
Once created, the ticket will be updated with a private comment containing
additional information from the browser and server, such as HTTP headers
and user state. Returns a boolean value indicating whether ticket creation
was successful, regardless of whether the private comment update succeeded.
"""
zendesk_api
=
_ZendeskApi
()
additional_info_string
=
(
"Additional information:
\n\n
"
+
"
\n
"
.
join
(
"
%
s:
%
s"
%
(
key
,
value
)
for
(
key
,
value
)
in
additional_info
.
items
()
if
value
is
not
None
)
)
zendesk_tags
=
list
(
tags
.
values
())
new_ticket
=
{
"ticket"
:
{
"requester"
:
{
"name"
:
realname
,
"email"
:
email
},
"subject"
:
subject
,
"comment"
:
{
"body"
:
details
},
"tags"
:
zendesk_tags
}
}
try
:
ticket_id
=
zendesk_api
.
create_ticket
(
new_ticket
)
except
zendesk
.
ZendeskError
as
err
:
log
.
error
(
"Error creating Zendesk ticket:
%
s"
,
str
(
err
))
return
False
# Additional information is provided as a private update so the information
# is not visible to the user.
ticket_update
=
{
"ticket"
:
{
"comment"
:
{
"public"
:
False
,
"body"
:
additional_info_string
}}}
try
:
zendesk_api
.
update_ticket
(
ticket_id
,
ticket_update
)
except
zendesk
.
ZendeskError
as
err
:
log
.
error
(
"Error updating Zendesk ticket:
%
s"
,
str
(
err
))
# The update is not strictly necessary, so do not indicate failure to the user
pass
return
True
DATADOG_FEEDBACK_METRIC
=
"lms_feedback_submissions"
def
_record_feedback_in_datadog
(
tags
):
datadog_tags
=
[
"{k}:{v}"
.
format
(
k
=
k
,
v
=
v
)
for
k
,
v
in
tags
.
items
()]
dog_stats_api
.
increment
(
DATADOG_FEEDBACK_METRIC
,
tags
=
datadog_tags
)
def
submit_feedback
(
request
):
"""
Create a new user-requested ticket, currently implemented with Zendesk.
If feedback submission is not enabled, any request will raise `Http404`.
If any configuration parameter (`ZENDESK_URL`, `ZENDESK_USER`, or
If any configuration parameter (`ZENDESK_URL`, `ZENDESK_USER`, or
`ZENDESK_API_KEY`) is missing, any request will raise an `Exception`.
`ZENDESK_API_KEY`) is missing, any request will raise an `Exception`.
The request must be a POST request specifying `subject` and `details`.
The request must be a POST request specifying `subject` and `details`.
...
@@ -85,12 +138,9 @@ def submit_feedback_via_zendesk(request):
...
@@ -85,12 +138,9 @@ def submit_feedback_via_zendesk(request):
`email`. If the user is authenticated, the `name` and `email` will be
`email`. If the user is authenticated, the `name` and `email` will be
populated from the user's information. If any required parameter is
populated from the user's information. If any required parameter is
missing, a 400 error will be returned indicating which field is missing and
missing, a 400 error will be returned indicating which field is missing and
providing an error message. If Zendesk returns any error on ticket
providing an error message. If Zendesk ticket creation fails, 500 error
creation, a 500 error will be returned with no body. Once created, the
will be returned with no body; if ticket creation succeeds, an empty
ticket will be updated with a private comment containing additional
successful response (200) will be returned.
information from the browser and server, such as HTTP headers and user
state. Whether or not the update succeeds, if the user's ticket is
successfully created, an empty successful response (200) will be returned.
"""
"""
if
not
settings
.
MITX_FEATURES
.
get
(
'ENABLE_FEEDBACK_SUBMISSION'
,
False
):
if
not
settings
.
MITX_FEATURES
.
get
(
'ENABLE_FEEDBACK_SUBMISSION'
,
False
):
raise
Http404
()
raise
Http404
()
...
@@ -124,9 +174,9 @@ def submit_feedback_via_zendesk(request):
...
@@ -124,9 +174,9 @@ def submit_feedback_via_zendesk(request):
subject
=
request
.
POST
[
"subject"
]
subject
=
request
.
POST
[
"subject"
]
details
=
request
.
POST
[
"details"
]
details
=
request
.
POST
[
"details"
]
tags
=
[]
tags
=
dict
(
if
"tag"
in
request
.
POST
:
[(
tag
,
request
.
POST
[
tag
])
for
tag
in
[
"issue_type"
]
if
tag
in
request
.
POST
]
tags
=
[
request
.
POST
[
"tag"
]]
)
if
request
.
user
.
is_authenticated
():
if
request
.
user
.
is_authenticated
():
realname
=
request
.
user
.
profile
.
name
realname
=
request
.
user
.
profile
.
name
...
@@ -143,38 +193,10 @@ def submit_feedback_via_zendesk(request):
...
@@ -143,38 +193,10 @@ def submit_feedback_via_zendesk(request):
for
header
in
[
"HTTP_REFERER"
,
"HTTP_USER_AGENT"
]:
for
header
in
[
"HTTP_REFERER"
,
"HTTP_USER_AGENT"
]:
additional_info
[
header
]
=
request
.
META
.
get
(
header
)
additional_info
[
header
]
=
request
.
META
.
get
(
header
)
zendesk_api
=
_ZendeskApi
()
success
=
_record_feedback_in_zendesk
(
realname
,
email
,
subject
,
details
,
tags
,
additional_info
)
_record_feedback_in_datadog
(
tags
)
additional_info_string
=
(
"Additional information:
\n\n
"
+
"
\n
"
.
join
(
"
%
s:
%
s"
%
(
key
,
value
)
for
(
key
,
value
)
in
additional_info
.
items
()
if
value
is
not
None
)
)
new_ticket
=
{
"ticket"
:
{
"requester"
:
{
"name"
:
realname
,
"email"
:
email
},
"subject"
:
subject
,
"comment"
:
{
"body"
:
details
},
"tags"
:
tags
}
}
try
:
ticket_id
=
zendesk_api
.
create_ticket
(
new_ticket
)
except
zendesk
.
ZendeskError
as
err
:
log
.
error
(
"Error creating Zendesk ticket:
%
s"
,
str
(
err
))
return
HttpResponse
(
status
=
500
)
# Additional information is provided as a private update so the information
# is not visible to the user.
ticket_update
=
{
"ticket"
:
{
"comment"
:
{
"public"
:
False
,
"body"
:
additional_info_string
}}}
try
:
zendesk_api
.
update_ticket
(
ticket_id
,
ticket_update
)
except
zendesk
.
ZendeskError
as
err
:
log
.
error
(
"Error updating Zendesk ticket:
%
s"
,
str
(
err
))
# The update is not strictly necessary, so do not indicate failure to the user
pass
return
HttpResponse
()
return
HttpResponse
(
status
=
(
200
if
success
else
500
)
)
def
info
(
request
):
def
info
(
request
):
...
...
lms/templates/help_modal.html
View file @
17647abd
...
@@ -64,7 +64,7 @@ discussion_link = get_discussion_link(course) if course else None
...
@@ -64,7 +64,7 @@ discussion_link = get_discussion_link(course) if course else None
<label
data-field=
"details"
>
Tell us the details*
<label
data-field=
"details"
>
Tell us the details*
<span
class=
"tip"
>
Include error messages, steps which lead to the issue, etc
</span></label>
<span
class=
"tip"
>
Include error messages, steps which lead to the issue, etc
</span></label>
<textarea
name=
"details"
></textarea>
<textarea
name=
"details"
></textarea>
<input
name=
"
tag
"
type=
"hidden"
>
<input
name=
"
issue_type
"
type=
"hidden"
>
<div
class=
"submit"
>
<div
class=
"submit"
>
<input
name=
"submit"
type=
"submit"
value=
"Submit"
>
<input
name=
"submit"
type=
"submit"
value=
"Submit"
>
</div>
</div>
...
@@ -114,9 +114,9 @@ discussion_link = get_discussion_link(course) if course else None
...
@@ -114,9 +114,9 @@ discussion_link = get_discussion_link(course) if course else None
$
(
"#feedback_success_wrapper"
).
css
(
"display"
,
"none"
);
$
(
"#feedback_success_wrapper"
).
css
(
"display"
,
"none"
);
$
(
"#help_wrapper"
).
css
(
"display"
,
"block"
);
$
(
"#help_wrapper"
).
css
(
"display"
,
"block"
);
});
});
showFeedback
=
function
(
e
,
tag
,
title
)
{
showFeedback
=
function
(
e
,
issue_type
,
title
)
{
$
(
"#help_wrapper"
).
css
(
"display"
,
"none"
);
$
(
"#help_wrapper"
).
css
(
"display"
,
"none"
);
$
(
"#feedback_form input[name='
tag']"
).
val
(
tag
);
$
(
"#feedback_form input[name='
issue_type']"
).
val
(
issue_type
);
$
(
"#feedback_form_wrapper"
).
css
(
"display"
,
"block"
);
$
(
"#feedback_form_wrapper"
).
css
(
"display"
,
"block"
);
$
(
"#feedback_form_wrapper header"
).
html
(
"<h2>"
+
title
+
"</h2><hr>"
);
$
(
"#feedback_form_wrapper header"
).
html
(
"<h2>"
+
title
+
"</h2><hr>"
);
e
.
preventDefault
();
e
.
preventDefault
();
...
...
lms/urls.py
View file @
17647abd
...
@@ -111,7 +111,7 @@ if not settings.MITX_FEATURES["USE_CUSTOM_THEME"]:
...
@@ -111,7 +111,7 @@ if not settings.MITX_FEATURES["USE_CUSTOM_THEME"]:
# Favicon
# Favicon
(
r'^favicon\.ico$'
,
'django.views.generic.simple.redirect_to'
,
{
'url'
:
'/static/images/favicon.ico'
}),
(
r'^favicon\.ico$'
,
'django.views.generic.simple.redirect_to'
,
{
'url'
:
'/static/images/favicon.ico'
}),
url
(
r'^submit_feedback$'
,
'util.views.submit_feedback
_via_zendesk
'
),
url
(
r'^submit_feedback$'
,
'util.views.submit_feedback'
),
# TODO: These urls no longer work. They need to be updated before they are re-enabled
# TODO: These urls no longer work. They need to be updated before they are re-enabled
# url(r'^reactivate/(?P<key>[^/]*)$', 'student.views.reactivation_email'),
# url(r'^reactivate/(?P<key>[^/]*)$', 'student.views.reactivation_email'),
...
...
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