Commit f907d94e by Daniel Friedman

Parameterize fake data script by username, course

parent 0e46ca30
...@@ -32,7 +32,11 @@ class Command(BaseCommand): ...@@ -32,7 +32,11 @@ class Command(BaseCommand):
help = 'Generate fake data' help = 'Generate fake data'
option_list = BaseCommand.option_list + ( option_list = BaseCommand.option_list + (
make_option('-n', '--num-weeks', action='store', type="int", dest='num_weeks', make_option('-n', '--num-weeks', action='store', type="int", dest='num_weeks',
help='"Number of weeks worth of data to generate.'), help='Number of weeks worth of data to generate.'),
make_option('-c', '--course_id', action='store', type='string', dest='course_id',
help='Course ID for which to generate fake data'),
make_option('-u', '--username', action='store', type='string', dest='username',
help='Username for which to generate fake data'),
) )
def generate_daily_data(self, course_id, start_date, end_date): def generate_daily_data(self, course_id, start_date, end_date):
...@@ -192,8 +196,10 @@ class Command(BaseCommand): ...@@ -192,8 +196,10 @@ class Command(BaseCommand):
current = current + datetime.timedelta(days=1) current = current + datetime.timedelta(days=1)
for entity_type in engagement_entity_types.INDIVIDUAL_TYPES: for entity_type in engagement_entity_types.INDIVIDUAL_TYPES:
for event in engagement_events.EVENTS[entity_type]: for event in engagement_events.EVENTS[entity_type]:
count = random.randint(0, max_value) num_events = random.randint(0, max_value)
if count: if num_events:
for _ in xrange(num_events):
count = random.randint(0, max_value / 20)
entity_id = 'an-id-{}-{}'.format(entity_type, event) entity_id = 'an-id-{}-{}'.format(entity_type, event)
models.ModuleEngagement.objects.create( models.ModuleEngagement.objects.create(
course_id=course_id, username=username, date=current, course_id=course_id, username=username, date=current,
...@@ -220,7 +226,8 @@ class Command(BaseCommand): ...@@ -220,7 +226,8 @@ class Command(BaseCommand):
range_type='high', low_value=high_floor, high_value=max_value) range_type='high', low_value=high_floor, high_value=max_value)
def handle(self, *args, **options): def handle(self, *args, **options):
course_id = 'edX/DemoX/Demo_Course' course_id = options.get('course_id', 'edX/DemoX/Demo_Course')
username = options.get('username', 'ed_xavier')
video_id = '0fac49ba' video_id = '0fac49ba'
video_module_id = 'i4x-edX-DemoX-video-5c90cffecd9b48b188cbfea176bf7fe9' video_module_id = 'i4x-edX-DemoX-video-5c90cffecd9b48b188cbfea176bf7fe9'
start_date = datetime.datetime(year=2015, month=1, day=1, tzinfo=timezone.utc) start_date = datetime.datetime(year=2015, month=1, day=1, tzinfo=timezone.utc)
...@@ -236,5 +243,5 @@ class Command(BaseCommand): ...@@ -236,5 +243,5 @@ class Command(BaseCommand):
self.generate_daily_data(course_id, start_date, end_date) self.generate_daily_data(course_id, start_date, end_date)
self.generate_video_data(course_id, video_id, video_module_id) self.generate_video_data(course_id, video_id, video_module_id)
self.generate_video_timeline_data(video_id) self.generate_video_timeline_data(video_id)
self.generate_learner_engagement_data(course_id, 'ed_xavier', start_date, end_date) self.generate_learner_engagement_data(course_id, username, start_date, end_date)
self.generate_learner_engagement_range_data(course_id, start_date, end_date) self.generate_learner_engagement_range_data(course_id, start_date, end_date)
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