Skip to content

Commit

Permalink
feat: add util method in edx-val for listing transcript_languages for…
Browse files Browse the repository at this point in the history
… a course
  • Loading branch information
AfaqShuaib09 committed Feb 17, 2025
1 parent b7c5db6 commit 5bc096f
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions edxval/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,29 @@ def get_videos_for_course(course_id, sort_field=None, sort_dir=SortDirection.asc
)


def get_transcript_languages(course_id, provider_type):
"""
Returns a list of languages for which transcripts are available for a course
Args:
course_id (str): course id
provider_type (str): transcript provider type
Returns:
(list): A list of language codes
"""
transcript_languages = set()
video_transcripts = VideoTranscript.objects.filter(

Check warning on line 748 in edxval/api.py

View check run for this annotation

Codecov / codecov/patch

edxval/api.py#L747-L748

Added lines #L747 - L748 were not covered by tests
video__edx_video_id__in=CourseVideo.objects.filter(
course_id=course_id
).values_list("video__edx_video_id", flat=True)
).select_related("video", "transcript", "transcript__file")
for transcript in video_transcripts:
if transcript.provider == provider_type:
transcript_languages.add(transcript.language_code)
return list(transcript_languages)

Check warning on line 756 in edxval/api.py

View check run for this annotation

Codecov / codecov/patch

edxval/api.py#L755-L756

Added lines #L755 - L756 were not covered by tests


def get_course_videos_qset(course_id):
"""
Get a QuerySet of CourseVideos for a given course.
Expand Down

0 comments on commit 5bc096f

Please sign in to comment.