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
29437878
Commit
29437878
authored
Oct 02, 2014
by
Clinton Blackburn
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #33 from edx/travis-update
Updates for Travis
parents
0d6266f0
04871273
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
1 deletions
+19
-1
Makefile
+5
-0
analytics_data_api/management/commands/generate_fake_course_data.py
+14
-1
No files found.
Makefile
View file @
29437878
...
@@ -55,3 +55,8 @@ loaddata: syncdb
...
@@ -55,3 +55,8 @@ loaddata: syncdb
demo
:
clean requirements loaddata
demo
:
clean requirements loaddata
python manage.py set_api_key edx edx
python manage.py set_api_key edx edx
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 generate_fake_course_data
--num-weeks
=
1
analytics_data_api/management/commands/generate_fake_course_data.py
View file @
29437878
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
import
datetime
import
datetime
import
logging
import
logging
from
optparse
import
make_option
import
random
import
random
from
django.core.management.base
import
BaseCommand
from
django.core.management.base
import
BaseCommand
...
@@ -28,6 +29,11 @@ def get_count(start):
...
@@ -28,6 +29,11 @@ def get_count(start):
class
Command
(
BaseCommand
):
class
Command
(
BaseCommand
):
help
=
'Generate fake data'
option_list
=
BaseCommand
.
option_list
+
(
make_option
(
'-n'
,
'--num-weeks'
,
action
=
'store'
,
type
=
"int"
,
dest
=
'num_weeks'
,
help
=
'"Number of weeks worth of data to generate.'
),
)
def
generate_daily_data
(
self
,
course_id
,
start_date
,
end_date
):
def
generate_daily_data
(
self
,
course_id
,
start_date
,
end_date
):
# Use the preset ratios below to generate data in the specified demographics
# Use the preset ratios below to generate data in the specified demographics
...
@@ -129,7 +135,8 @@ class Command(BaseCommand):
...
@@ -129,7 +135,8 @@ class Command(BaseCommand):
models
.
CourseActivityWeekly
.
objects
.
create
(
course_id
=
course_id
,
activity_type
=
activity_type
,
models
.
CourseActivityWeekly
.
objects
.
create
(
course_id
=
course_id
,
activity_type
=
activity_type
,
count
=
count
,
interval_start
=
start
,
interval_end
=
end
)
count
=
count
,
interval_start
=
start
,
interval_end
=
end
)
models
.
CourseActivityWeekly
.
objects
.
create
(
course_id
=
course_id
,
activity_type
=
'ACTIVE'
,
count
=
active_students
,
models
.
CourseActivityWeekly
.
objects
.
create
(
course_id
=
course_id
,
activity_type
=
'ACTIVE'
,
count
=
active_students
,
interval_start
=
start
,
interval_end
=
end
)
interval_start
=
start
,
interval_end
=
end
)
start
=
end
start
=
end
...
@@ -139,7 +146,13 @@ class Command(BaseCommand):
...
@@ -139,7 +146,13 @@ class Command(BaseCommand):
def
handle
(
self
,
*
args
,
**
options
):
def
handle
(
self
,
*
args
,
**
options
):
course_id
=
'edX/DemoX/Demo_Course'
course_id
=
'edX/DemoX/Demo_Course'
start_date
=
datetime
.
datetime
(
year
=
2014
,
month
=
1
,
day
=
1
,
tzinfo
=
timezone
.
utc
)
start_date
=
datetime
.
datetime
(
year
=
2014
,
month
=
1
,
day
=
1
,
tzinfo
=
timezone
.
utc
)
num_weeks
=
options
[
'num_weeks'
]
if
num_weeks
:
end_date
=
start_date
+
datetime
.
timedelta
(
weeks
=
num_weeks
)
else
:
end_date
=
timezone
.
now
()
.
replace
(
microsecond
=
0
)
end_date
=
timezone
.
now
()
.
replace
(
microsecond
=
0
)
logger
.
info
(
"Generating data for
%
s..."
,
course_id
)
logger
.
info
(
"Generating data for
%
s..."
,
course_id
)
self
.
generate_weekly_data
(
course_id
,
start_date
,
end_date
)
self
.
generate_weekly_data
(
course_id
,
start_date
,
end_date
)
self
.
generate_daily_data
(
course_id
,
start_date
,
end_date
)
self
.
generate_daily_data
(
course_id
,
start_date
,
end_date
)
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