Skip to content

Commit

Permalink
Merge pull request #380 from edx-solutions/ziafazal/api-fix-progess-c…
Browse files Browse the repository at this point in the history
…harts

merging it
  • Loading branch information
ziafazal committed Feb 3, 2015
2 parents 55006bf + b5a394a commit 249b30f
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 21 deletions.
36 changes: 24 additions & 12 deletions lms/djangoapps/api_manager/courses/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,19 @@ def setUp(self):
self.test_group_name = 'Alpha Group'
self.attempts = 3

self.course_start_date = timezone.now() + relativedelta(days=-1)
self.course_end_date = timezone.now() + relativedelta(days=60)
self.course = CourseFactory.create(
start=datetime(2014, 6, 16, 14, 30),
end=datetime(2015, 1, 16)
start=self.course_start_date,
end=self.course_end_date
)
self.test_data = '<html>{}</html>'.format(str(uuid.uuid4()))

self.chapter = ItemFactory.create(
category="chapter",
parent_location=self.course.location,
data=self.test_data,
due=datetime(2014, 5, 16, 14, 30),
due=self.course_end_date,
display_name="Overview"
)

Expand Down Expand Up @@ -199,8 +201,8 @@ def setUp(self):
)

self.empty_course = CourseFactory.create(
start=datetime(2014, 6, 16, 14, 30),
end=datetime(2015, 1, 16),
start=self.course_start_date,
end=self.course_end_date,
org="MTD"
)

Expand Down Expand Up @@ -2024,28 +2026,35 @@ def test_courses_data_time_series_metrics(self):
course = CourseFactory.create(
number='3033',
name='metrics_in_timeseries',
start=datetime(2014, 9, 16, 14, 30),
end=datetime(2015, 1, 16)
start=self.course_start_date,
end=self.course_end_date
)

second_course = CourseFactory.create(
number='3034',
name='metrics_in_timeseries',
start=self.course_start_date,
end=self.course_end_date
)

chapter = ItemFactory.create(
category="chapter",
parent_location=course.location,
data=self.test_data,
due=datetime(2015, 5, 16, 14, 30),
display_name="Overview"
due=self.course_end_date,
display_name=u"3033 Overview"
)

sub_section = ItemFactory.create(
parent_location=chapter.location,
category="sequential",
display_name=u"test subsection",
display_name="3033 test subsection",
)
unit = ItemFactory.create(
parent_location=sub_section.location,
category="vertical",
metadata={'graded': True, 'format': 'Homework'},
display_name=u"test unit",
display_name=u"3033 test unit",
)

item = ItemFactory.create(
Expand Down Expand Up @@ -2084,6 +2093,7 @@ def test_courses_data_time_series_metrics(self):
with freeze_time(enrolled_time):
for user in users:
CourseEnrollmentFactory.create(user=user, course_id=course.id)
CourseEnrollmentFactory.create(user=user, course_id=second_course.id)

points_scored = .25
points_possible = 1
Expand All @@ -2099,6 +2109,8 @@ def test_courses_data_time_series_metrics(self):

# Last 2 users as those who have completed
if j >= USER_COUNT - 2:
second_module = self.get_module_for_user(user, course, item2)
module.system.publish(second_module, 'grade', grade_dict)
try:
sg_entry = StudentGradebook.objects.get(user=user, course_id=course.id)
sg_entry.grade = 0.9
Expand Down Expand Up @@ -2139,7 +2151,7 @@ def test_courses_data_time_series_metrics(self):
self.assertEqual(total_completed, 2)
self.assertEqual(len(response.data['modules_completed']), 5)
total_modules_completed = sum([completed[1] for completed in response.data['modules_completed']])
self.assertEqual(total_modules_completed, 4)
self.assertEqual(total_modules_completed, 6)
self.assertEqual(len(response.data['active_users']), 5)
total_active = sum([active[1] for active in response.data['active_users']])
self.assertEqual(total_active, 5)
Expand Down
5 changes: 4 additions & 1 deletion lms/djangoapps/api_manager/groups/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
rake fasttest_lms[common/djangoapps/api_manager/tests/test_group_views.py]
"""
from datetime import datetime
from dateutil.relativedelta import relativedelta
from random import randint
import uuid
import json
Expand All @@ -14,6 +15,7 @@
from django.core.cache import cache
from django.test import TestCase, Client
from django.test.utils import override_settings
from django.utils import timezone

from api_manager.models import GroupRelationship, GroupProfile
from organizations.models import Organization
Expand Down Expand Up @@ -56,11 +58,12 @@ def setUp(self):
self.test_course_data = '<html>{}</html>'.format(str(uuid.uuid4()))
self.course = CourseFactory.create()
self.test_course_id = unicode(self.course.id)
self.course_end_date = timezone.now() + relativedelta(days=60)
self.course_content = ItemFactory.create(
category="videosequence",
parent_location=self.course.location,
data=self.test_course_data,
due=datetime(2016, 5, 16, 14, 30),
due=self.course_end_date,
display_name="View_Sequence"
)

Expand Down
19 changes: 11 additions & 8 deletions lms/djangoapps/api_manager/users/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
rake fasttest_lms[common/djangoapps/api_manager/tests/test_user_views.py]
"""
from datetime import datetime
from dateutil.relativedelta import relativedelta
from random import randint
import json
import uuid
Expand Down Expand Up @@ -111,26 +112,28 @@ def setUp(self):
self.test_bogus_content_id = 'i4x://foo/bar/baz/Chapter1'

self.test_course_data = '<html>{}</html>'.format(str(uuid.uuid4()))
self.course_start_date = timezone.now() + relativedelta(days=-1)
self.course_end_date = timezone.now() + relativedelta(days=60)
self.course = CourseFactory.create(
display_name="TEST COURSE",
start=datetime(2014, 6, 16, 14, 30),
end=datetime(2015, 1, 16, 14, 30),
start=self.course_start_date,
end=self.course_end_date,
org='USERTEST',
run='USERTEST1'
)
self.course_content = ItemFactory.create(
category="videosequence",
parent_location=self.course.location,
data=self.test_course_data,
due=datetime(2016, 5, 16, 14, 30),
due=self.course_end_date,
display_name="View_Sequence"
)
self.course2 = CourseFactory.create(display_name="TEST COURSE2", org='TESTORG2', run='USERTEST2')
self.course2_content = ItemFactory.create(
category="videosequence",
parent_location=self.course2.location,
data=self.test_course_data,
due=datetime(2016, 5, 16, 14, 30),
due=self.course_end_date,
display_name="View_Sequence2"
)

Expand Down Expand Up @@ -991,8 +994,8 @@ def test_user_courses_detail_post_position_invalid_course(self):
def test_user_courses_detail_get(self):
course = CourseFactory.create(
display_name="UserCoursesDetailTestCourse",
start=datetime(2014, 6, 16, 14, 30),
end=datetime(2015, 1, 16, 14, 30),
start=self.course_start_date,
end=self.course_end_date,
org='TUCDG',
run='TUCDG1'
)
Expand Down Expand Up @@ -1315,7 +1318,7 @@ def test_user_courses_grades_list_get(self):
data=StringResponseXMLFactory().build_xml(answer='bar'),
display_name=u"test mentoring homework 3",
metadata={'rerandomize': 'always', 'graded': True, 'format': "Homework"},
due=datetime(2015, 1, 16, 14, 30).replace(tzinfo=timezone.utc)
due=self.course_end_date.replace(tzinfo=timezone.utc)
)
points_scored = 1
points_possible = 1
Expand Down Expand Up @@ -1372,7 +1375,7 @@ def test_user_courses_grades_list_get(self):
data=StringResponseXMLFactory().build_xml(answer='bar'),
display_name=u"test mentoring homework 3",
metadata={'rerandomize': 'always', 'graded': True, 'format': "Homework"},
due=datetime(2015, 1, 16, 14, 30).replace(tzinfo=timezone.utc)
due=self.course_end_date.replace(tzinfo=timezone.utc)
)

test_uri = '{}/{}/courses/{}/grades'.format(self.users_base_uri, user_id, unicode(course.id))
Expand Down

0 comments on commit 249b30f

Please sign in to comment.