Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-analytics-data-api
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-analytics-data-api
Commits
254f5980
Commit
254f5980
authored
Oct 30, 2014
by
Dennis Jen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Education level returned as a string (rather than an education level object).
parent
ac59ba71
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
8 additions
and
116 deletions
+8
-116
Makefile
+2
-2
analytics_data_api/fixtures/education_levels.json
+0
-75
analytics_data_api/management/commands/generate_fake_course_data.py
+1
-2
analytics_data_api/v0/models.py
+1
-12
analytics_data_api/v0/serializers.py
+1
-10
analytics_data_api/v0/tests/test_models.py
+0
-11
analytics_data_api/v0/tests/test_views.py
+3
-4
No files found.
Makefile
View file @
254f5980
...
...
@@ -50,7 +50,7 @@ syncdb:
$
(
foreach db_name,
$(DATABASES)
,./manage.py syncdb
--migrate
--noinput
--database
=
$(db_name)
;
)
loaddata
:
syncdb
python manage.py loaddata
education_levels
problem_response_answer_distribution
--database
=
analytics
python manage.py loaddata problem_response_answer_distribution
--database
=
analytics
python manage.py generate_fake_course_data
demo
:
clean requirements loaddata
...
...
@@ -58,5 +58,5 @@ demo: clean requirements loaddata
travis
:
clean requirements syncdb
python manage.py set_api_key edx edx
python manage.py loaddata
education_levels
problem_response_answer_distribution
--database
=
analytics
python manage.py loaddata problem_response_answer_distribution
--database
=
analytics
python manage.py generate_fake_course_data
--num-weeks
=
1
analytics_data_api/fixtures/education_levels.json
deleted
100644 → 0
View file @
ac59ba71
[
{
"pk"
:
1
,
"model"
:
"v0.educationlevel"
,
"fields"
:
{
"name"
:
"None"
,
"short_name"
:
"none"
}
},
{
"pk"
:
2
,
"model"
:
"v0.educationlevel"
,
"fields"
:
{
"name"
:
"Other"
,
"short_name"
:
"other"
}
},
{
"pk"
:
3
,
"model"
:
"v0.educationlevel"
,
"fields"
:
{
"name"
:
"Elementary/Primary School"
,
"short_name"
:
"primary"
}
},
{
"pk"
:
4
,
"model"
:
"v0.educationlevel"
,
"fields"
:
{
"name"
:
"Junior Secondary/Junior High/Middle School"
,
"short_name"
:
"junior_secondary"
}
},
{
"pk"
:
5
,
"model"
:
"v0.educationlevel"
,
"fields"
:
{
"name"
:
"Secondary/High School"
,
"short_name"
:
"secondary"
}
},
{
"pk"
:
6
,
"model"
:
"v0.educationlevel"
,
"fields"
:
{
"name"
:
"Associate's Degree"
,
"short_name"
:
"associates"
}
},
{
"pk"
:
7
,
"model"
:
"v0.educationlevel"
,
"fields"
:
{
"name"
:
"Bachelor's Degree"
,
"short_name"
:
"bachelors"
}
},
{
"pk"
:
8
,
"model"
:
"v0.educationlevel"
,
"fields"
:
{
"name"
:
"Master's or Professional Degree"
,
"short_name"
:
"masters"
}
},
{
"pk"
:
9
,
"model"
:
"v0.educationlevel"
,
"fields"
:
{
"name"
:
"Doctorate"
,
"short_name"
:
"doctorate"
}
}
]
\ No newline at end of file
analytics_data_api/management/commands/generate_fake_course_data.py
View file @
254f5980
...
...
@@ -105,8 +105,7 @@ class Command(BaseCommand):
models
.
CourseEnrollmentByGender
.
objects
.
create
(
course_id
=
course_id
,
date
=
date
,
count
=
count
,
gender
=
gender
)
for
short_name
,
ratio
in
education_level_ratios
.
iteritems
():
education_level
=
models
.
EducationLevel
.
objects
.
get
(
short_name
=
short_name
)
for
education_level
,
ratio
in
education_level_ratios
.
iteritems
():
count
=
int
(
ratio
*
daily_total
)
models
.
CourseEnrollmentByEducation
.
objects
.
create
(
course_id
=
course_id
,
date
=
date
,
count
=
count
,
education_level
=
education_level
)
...
...
analytics_data_api/v0/models.py
View file @
254f5980
...
...
@@ -63,19 +63,8 @@ class CourseEnrollmentByBirthYear(BaseCourseEnrollment):
unique_together
=
[(
'course_id'
,
'date'
,
'birth_year'
)]
class
EducationLevel
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
255
,
null
=
False
,
unique
=
True
)
short_name
=
models
.
CharField
(
max_length
=
255
,
null
=
False
,
unique
=
True
)
class
Meta
(
object
):
db_table
=
'education_levels'
def
__unicode__
(
self
):
return
"{0} - {1}"
.
format
(
self
.
short_name
,
self
.
name
)
class
CourseEnrollmentByEducation
(
BaseCourseEnrollment
):
education_level
=
models
.
ForeignKey
(
EducationLevel
)
education_level
=
models
.
CharField
(
max_length
=
255
,
null
=
True
)
class
Meta
(
BaseCourseEnrollment
.
Meta
):
db_table
=
'course_enrollment_education_level_daily'
...
...
analytics_data_api/v0/serializers.py
View file @
254f5980
...
...
@@ -132,15 +132,8 @@ class CountrySerializer(serializers.Serializer):
name
=
serializers
.
CharField
()
# pylint: disable=no-value-for-parameter
class
EducationLevelSerializer
(
serializers
.
ModelSerializer
):
class
Meta
(
object
):
model
=
models
.
EducationLevel
fields
=
(
'name'
,
'short_name'
)
class
CourseEnrollmentByCountrySerializer
(
BaseCourseEnrollmentModelSerializer
):
# pylint: disable=unexpected-keyword-arg
# pylint: disable=unexpected-keyword-arg
, no-value-for-parameter
country
=
CountrySerializer
(
many
=
False
)
class
Meta
(
object
):
...
...
@@ -160,8 +153,6 @@ class CourseEnrollmentByGenderSerializer(BaseCourseEnrollmentModelSerializer):
class
CourseEnrollmentByEducationSerializer
(
BaseCourseEnrollmentModelSerializer
):
education_level
=
EducationLevelSerializer
()
class
Meta
(
object
):
model
=
models
.
CourseEnrollmentByEducation
fields
=
(
'course_id'
,
'date'
,
'education_level'
,
'count'
,
'created'
)
...
...
analytics_data_api/v0/tests/test_models.py
View file @
254f5980
...
...
@@ -6,17 +6,6 @@ from analytics_data_api.v0 import models
from
analytics_data_api.constants.country
import
UNKNOWN_COUNTRY
class
EducationLevelTests
(
TestCase
):
def
test_unicode
(
self
):
short_name
=
'high_school'
name
=
'High School'
education_level
=
G
(
models
.
EducationLevel
,
short_name
=
short_name
,
name
=
name
)
self
.
assertEqual
(
unicode
(
education_level
),
"{0} - {1}"
.
format
(
short_name
,
name
))
class
CourseEnrollmentByCountryTests
(
TestCase
):
def
test_country
(
self
):
country
=
countries
.
get
(
'US'
)
...
...
analytics_data_api/v0/tests/test_views.py
View file @
254f5980
...
...
@@ -296,15 +296,14 @@ class CourseEnrollmentByEducationViewTests(CourseEnrollmentViewTestCaseMixin, Te
def
setUp
(
self
):
super
(
CourseEnrollmentByEducationViewTests
,
self
)
.
setUp
()
self
.
el1
=
G
(
models
.
EducationLevel
,
name
=
'Doctorate'
,
short_name
=
'doctorate'
)
self
.
el2
=
G
(
models
.
EducationLevel
,
name
=
'Top Secret'
,
short_name
=
'top_secret'
)
self
.
el1
=
'doctorate'
self
.
el2
=
'top_secret'
self
.
generate_data
()
def
format_as_response
(
self
,
*
args
):
return
[
{
'course_id'
:
unicode
(
ce
.
course_id
),
'count'
:
ce
.
count
,
'date'
:
ce
.
date
.
strftime
(
settings
.
DATE_FORMAT
),
'education_level'
:
{
'name'
:
ce
.
education_level
.
name
,
'short_name'
:
ce
.
education_level
.
short_name
},
'created'
:
ce
.
created
.
strftime
(
settings
.
DATETIME_FORMAT
)}
for
'education_level'
:
ce
.
education_level
,
'created'
:
ce
.
created
.
strftime
(
settings
.
DATETIME_FORMAT
)}
for
ce
in
args
]
...
...
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