Commit 51d9a5a5 by Dennis Jen

Merge pull request #70 from edx/dsjen/remove-milliseconds

Removed milliseconds from created date in problems endpoint.
parents eb085de4 fe085f5d
...@@ -604,13 +604,14 @@ class CourseProblemsListViewTests(DemoCourseMixin, TestCaseWithAuthentication): ...@@ -604,13 +604,14 @@ class CourseProblemsListViewTests(DemoCourseMixin, TestCaseWithAuthentication):
alt_module_id = 'i4x://test/problem/2' alt_module_id = 'i4x://test/problem/2'
created = datetime.datetime.utcnow() created = datetime.datetime.utcnow()
alt_created = created + datetime.timedelta(seconds=2) alt_created = created + datetime.timedelta(seconds=2)
date_time_format = '%Y-%m-%d %H:%M:%S'
o1 = G(models.ProblemResponseAnswerDistribution, course_id=self.course_id, module_id=module_id, correct=True, o1 = G(models.ProblemResponseAnswerDistribution, course_id=self.course_id, module_id=module_id, correct=True,
count=100, created=created) count=100, created=created.strftime(date_time_format))
o2 = G(models.ProblemResponseAnswerDistribution, course_id=self.course_id, module_id=alt_module_id, o2 = G(models.ProblemResponseAnswerDistribution, course_id=self.course_id, module_id=alt_module_id,
correct=True, count=100, created=created) correct=True, count=100, created=created.strftime(date_time_format))
o3 = G(models.ProblemResponseAnswerDistribution, course_id=self.course_id, module_id=module_id, correct=False, o3 = G(models.ProblemResponseAnswerDistribution, course_id=self.course_id, module_id=module_id, correct=False,
count=200, created=alt_created) count=200, created=alt_created.strftime(date_time_format))
expected = [ expected = [
{ {
......
...@@ -661,6 +661,6 @@ GROUP BY module_id; ...@@ -661,6 +661,6 @@ GROUP BY module_id;
# Rather than write custom SQL for the SQLite backend, simply parse the timestamp. # Rather than write custom SQL for the SQLite backend, simply parse the timestamp.
created = row['created'] created = row['created']
if not isinstance(created, datetime.datetime): if not isinstance(created, datetime.datetime):
row['created'] = datetime.datetime.strptime(created, '%Y-%m-%d %H:%M:%S.%f') row['created'] = datetime.datetime.strptime(created, '%Y-%m-%d %H:%M:%S')
return rows return rows
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