Commit 26f9b2c8 authored by Honcoop, T.'s avatar Honcoop, T.
Browse files

Feature/lesson names

parent 10134547
......@@ -33,12 +33,18 @@ class ItemSerializer(serializers.ModelSerializer):
"branch",
"item_id",
"lesson",
"lesson_name",
"order",
"type",
"name",
"optional",
]
lesson_name = serializers.SerializerMethodField()
def get_lesson_name(self, obj):
return obj.lesson.name
class VideoAnalyticsSerializer(ItemSerializer):
"""
......
......@@ -35,11 +35,20 @@ class QuizSerializer(serializers.ModelSerializer):
"update_timestamp",
"passing_fraction",
"graded",
"lesson",
"lesson_name",
]
name = serializers.CharField()
graded = serializers.BooleanField()
lesson = serializers.SerializerMethodField()
lesson_name = serializers.SerializerMethodField()
def get_lesson(self, obj):
return obj.items.all()[0].lesson.lesson_id
def get_lesson_name(self, obj):
return obj.items.all()[0].lesson.name
class QuizAnalyticsSerializer(QuizSerializer):
"""
......
......@@ -281,6 +281,7 @@ def test_video_analytics_view(
"branch",
"item_id",
"lesson",
"lesson_name",
"order",
"type",
"name",
......@@ -400,6 +401,7 @@ def test_video_analytics_view_invalid_date_filter(
"branch",
"item_id",
"lesson",
"lesson_name",
"order",
"type",
"name",
......@@ -517,6 +519,7 @@ def test_video_list_view(teacher_api_client, coursera_course_id):
- branch
- item_id
- lesson
- lesson_name
- order
- type
- name
......@@ -525,7 +528,7 @@ def test_video_list_view(teacher_api_client, coursera_course_id):
response = teacher_api_client.get(
reverse("coursera-api:video-list", kwargs={"course_id": coursera_course_id})
)
keys = ["id", "branch", "item_id", "lesson", "order", "type", "name", "optional"]
keys = ["id", "branch", "item_id", "lesson", "lesson_name", "order", "type", "name", "optional"]
assert response.status_code == 200, str(response.content)
assert len(response.data) > 0, "no videos returned"
for item in response.data:
......@@ -552,6 +555,8 @@ def test_quiz_analytics_view(
- update_timestamp
- passing_fraction
- graded
- lesson
- lesson_name
- average_grade
- grade_distribution
- average_attempts
......@@ -584,6 +589,8 @@ def test_quiz_analytics_view(
"update_timestamp",
"passing_fraction",
"graded",
"lesson",
"lesson_name",
"average_grade",
"grade_distribution",
"average_attempts",
......@@ -724,6 +731,8 @@ def test_quiz_analytics_view_invalid_date_filter(
"update_timestamp",
"passing_fraction",
"graded",
"lesson",
"lesson_name",
"average_grade",
"grade_distribution",
"average_attempts",
......@@ -770,6 +779,8 @@ def test_quiz_analytics_next_quiz(
"update_timestamp",
"passing_fraction",
"graded",
"lesson",
"lesson_name",
"average_grade",
"grade_distribution",
"average_attempts",
......@@ -827,6 +838,8 @@ def test_quiz_version_list_view(
- update_timestamp
- passing_fraction
- graded
- lesson
- lesson_name
"""
response = teacher_api_client.get(
reverse(
......@@ -846,6 +859,8 @@ def test_quiz_version_list_view(
"update_timestamp",
"passing_fraction",
"graded",
"lesson",
"lesson_name",
]
assert response.status_code == 200, str(response.content)
assert len(response.data) > 0, "no quizzes returned"
......@@ -869,6 +884,8 @@ def test_quiz_list_view(teacher_api_client, coursera_course_id):
- update_timestamp
- passing_fraction
- graded
- lesson
- lesson_name
"""
response = teacher_api_client.get(
reverse("coursera-api:quiz-list", kwargs={"course_id": coursera_course_id})
......@@ -882,6 +899,8 @@ def test_quiz_list_view(teacher_api_client, coursera_course_id):
"update_timestamp",
"passing_fraction",
"graded",
"lesson",
"lesson_name",
]
assert response.status_code == 200, str(response.content)
assert len(response.data) > 0, "no quizzes returned"
......@@ -905,6 +924,7 @@ def test_assignment_analytics_view(
- branch
- item_id
- lesson
- lesson_name
- order
- type
- name
......@@ -921,7 +941,7 @@ def test_assignment_analytics_view(
kwargs={"course_id": coursera_course_id, "item_id": coursera_assignment_id},
)
)
keys = ["id", "branch", "item_id", "lesson", "order", "type", "name", "optional", "submissions", "submission_ratio", "average_grade", "next_item", "next_assignment"]
keys = ["id", "branch", "item_id", "lesson", "lesson_name", "order", "type", "name", "optional", "submissions", "submission_ratio", "average_grade", "next_item", "next_assignment"]
assert response.status_code == 200, str(response.content)
assert list(response.data.keys()) == keys
......@@ -939,7 +959,7 @@ def test_assignment_analytics_view_next_assignment(
kwargs={"course_id": "V4m7Xf5qEeS9ISIACxWDhA", "item_id": "PoQSi"},
)
)
keys = ["id", "branch", "item_id", "lesson", "order", "type", "name", "optional", "submissions", "submission_ratio", "average_grade", "next_item", "next_assignment"]
keys = ["id", "branch", "item_id", "lesson", "lesson_name", "order", "type", "name", "optional", "submissions", "submission_ratio", "average_grade", "next_item", "next_assignment"]
assert response.status_code == 200, str(response.content)
assert list(response.data.keys()) == keys
......@@ -1016,6 +1036,7 @@ def test_assignment_analytics_view_invalid_date_filter(
"branch",
"item_id",
"lesson",
"lesson_name",
"order",
"type",
"name",
......@@ -1064,6 +1085,7 @@ def test_assignment_list_view(teacher_api_client, coursera_course_id):
- branch
- item_id
- lesson
- lesson_name
- order
- type
- name
......@@ -1074,7 +1096,7 @@ def test_assignment_list_view(teacher_api_client, coursera_course_id):
"coursera-api:assignment-list", kwargs={"course_id": coursera_course_id}
)
)
keys = ["id", "branch", "item_id", "lesson", "order", "type", "name", "optional"]
keys = ["id", "branch", "item_id", "lesson", "lesson_name", "order", "type", "name", "optional"]
assert response.status_code == 200, str(response.content)
assert len(response.data) > 0, "no assignments returned"
for item in response.data:
......
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