Commit 952b3468 by Vik Paruchuri

pep8 in views, remove instance state check

parent 7dec1b3c
......@@ -207,8 +207,11 @@ def change_enrollment(request):
'error': 'enrollment in {} not allowed at this time'
.format(course.display_name)}
split_course=course_id.split("/")
statsd.increment("lms.user.enrollment",tags=["org:" + str(split_course[0]),"course:" + str(split_course[1]),"run:" + str(split_course[2])])
org, course_num, run=course_id.split("/")
statsd.increment("lms.user.enrollment",
tags=["org:{0}".format(org),
"course:{0}".format(course_num),
"run:{0}".format(run)])
enrollment, created = CourseEnrollment.objects.get_or_create(user=user, course_id=course.id)
return {'success': True}
......@@ -218,9 +221,12 @@ def change_enrollment(request):
enrollment = CourseEnrollment.objects.get(user=user, course_id=course_id)
enrollment.delete()
split_course=course_id.split("/")
statsd.increment("lms.user.unenrollment",tags=["org:" + str(split_course[0]),"course:" + str(split_course[1]),"run:" + str(split_course[2])])
org, course_num, run=course_id.split("/")
statsd.increment("lms.user.unenrollment",
tags=["org:{0}".format(org),
"course:{0}".format(course_num),
"run:{0}".format(run)])
return {'success': True}
except CourseEnrollment.DoesNotExist:
return {'success': False, 'error': 'You are not enrolled for this course.'}
......
......@@ -391,13 +391,12 @@ def xqueue_callback(request, course_id, userid, id, dispatch):
score_bucket=2
org, course_num, run=course_id.split("/")
if(instance_module.state=="correct" or instance_module.state=="incorrect"):
statsd.increment("lms.user.question_answered",
tags=["org:{0}".format(org),
"course:{0}".format(course_num),
"run:{0}".format(run),
"score_bucket:{0}".format(score_bucket),
"type:xqueue"])
statsd.increment("lms.user.question_answered",
tags=["org:{0}".format(org),
"course:{0}".format(course_num),
"run:{0}".format(run),
"score_bucket:{0}".format(score_bucket),
"type:xqueue"])
return HttpResponse("")
......@@ -489,13 +488,12 @@ def modx_dispatch(request, dispatch, location, course_id):
score_bucket=2
org, course_num, run=course_id.split("/")
if(instance_module.state=="correct" or instance_module.state=="incorrect"):
statsd.increment("lms.user.question_answered",
tags=["org:{0}".format(org),
"course:{0}".format(course_num),
"run:{0}".format(run),
"score_bucket:{0}".format(score_bucket),
"type:ajax"])
statsd.increment("lms.user.question_answered",
tags=["org:{0}".format(org),
"course:{0}".format(course_num),
"run:{0}".format(run),
"score_bucket:{0}".format(score_bucket),
"type:ajax"])
if shared_module is not None:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment