From 90437fa5e03c01785dfe64b53c0af9d6683a1f92 Mon Sep 17 00:00:00 2001 From: Alexander Kryklia Date: Thu, 27 Mar 2014 15:10:00 +0200 Subject: [PATCH 1/4] Display transcript translations for student in their source language. --- CHANGELOG.rst | 2 ++ common/lib/xmodule/xmodule/video_module/video_module.py | 3 ++- lms/djangoapps/courseware/tests/test_video_mongo.py | 8 +++++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 40cf14c1f2..73362827b1 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,6 +5,8 @@ These are notable changes in edx-platform. This is a rolling list of changes, in roughly chronological order, most recent first. Add your entries at or near the top. Include a label indicating the component affected. +Blades: Transcript translations should be displayed in their source language (BLD-935). + Blades: Create an upload modal for video transcript translations (BLD-751). Studio: Add ability to reorder Pages and hide the Wiki page. STUD-1375 diff --git a/common/lib/xmodule/xmodule/video_module/video_module.py b/common/lib/xmodule/xmodule/video_module/video_module.py index edbe9fa370..b95f6f4bf7 100644 --- a/common/lib/xmodule/xmodule/video_module/video_module.py +++ b/common/lib/xmodule/xmodule/video_module/video_module.py @@ -124,8 +124,9 @@ class VideoModule(VideoFields, VideoStudentViewHandlers, XModule): else: transcript_language = sorted(self.transcripts.keys())[0] + native_languages = {lang: label for lang, label in settings.LANGUAGES if len(lang) == 2} languages = { - lang: display + lang: native_languages.get(lang, display) for lang, display in settings.ALL_LANGUAGES if lang in self.transcripts } diff --git a/lms/djangoapps/courseware/tests/test_video_mongo.py b/lms/djangoapps/courseware/tests/test_video_mongo.py index ef06d8ff00..fc9e291909 100644 --- a/lms/djangoapps/courseware/tests/test_video_mongo.py +++ b/lms/djangoapps/courseware/tests/test_video_mongo.py @@ -1,6 +1,8 @@ # -*- coding: utf-8 -*- """Video xmodule tests in mongo.""" +import json import unittest +from collections import OrderedDict from mock import patch, PropertyMock, MagicMock from django.conf import settings @@ -53,7 +55,7 @@ class TestVideoYouTube(TestVideo): 'transcript_download_format': 'srt', 'transcript_download_formats_list': [{'display_name': 'SubRip (.srt) file', 'value': 'srt'}, {'display_name': 'Text (.txt) file', 'value': 'txt'}], 'transcript_language': u'en', - 'transcript_languages': '{"en": "English", "uk": "Ukrainian"}', + 'transcript_languages': json.dumps(OrderedDict({"en": "English", "uk": u"Українська"})), 'transcript_translation_url': self.item_descriptor.xmodule_runtime.handler_url( self.item_descriptor, 'transcript', 'translation' ).rstrip('/?'), @@ -97,6 +99,7 @@ class TestVideoNonYouTube(TestVideo): } context = self.item_descriptor.render('student_view').content + expected_context = { 'ajax_url': self.item_descriptor.xmodule_runtime.ajax_url + '/save_user_state', 'data_dir': getattr(self, 'data_dir', None), @@ -239,7 +242,7 @@ class TestGetHtmlMethod(BaseTestXmodule): expected_context.update({ 'transcript_download_format': None if self.item_descriptor.track and self.item_descriptor.download_track else 'srt', - 'transcript_languages': '{"en": "English"}' if not data['transcripts'] else '{"uk": "Ukrainian"}', + 'transcript_languages': '{"en": "English"}' if not data['transcripts'] else json.dumps({"uk": u'Українська'}), 'transcript_language': u'en' if not data['transcripts'] or data.get('sub') else u'uk', 'transcript_translation_url': self.item_descriptor.xmodule_runtime.handler_url( self.item_descriptor, 'transcript', 'translation' @@ -252,7 +255,6 @@ class TestGetHtmlMethod(BaseTestXmodule): 'sub': data['sub'], 'id': self.item_descriptor.location.html_id(), }) - self.assertEqual( context, self.item_descriptor.xmodule_runtime.render_template('video.html', expected_context), From 6199c8562d2138046fca266cfeeeddebe87b8ed8 Mon Sep 17 00:00:00 2001 From: Alexander Kryklia Date: Wed, 2 Apr 2014 12:32:53 +0300 Subject: [PATCH 2/4] Fix acceptance tests. --- cms/djangoapps/contentstore/features/video-editor.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cms/djangoapps/contentstore/features/video-editor.py b/cms/djangoapps/contentstore/features/video-editor.py index b0460e8163..a7974f020f 100644 --- a/cms/djangoapps/contentstore/features/video-editor.py +++ b/cms/djangoapps/contentstore/features/video-editor.py @@ -10,7 +10,12 @@ from django.conf import settings from common import upload_file, attach_file TEST_ROOT = settings.COMMON_TEST_DATA_ROOT -LANGUAGES = {l[0]: l[1] for l in settings.ALL_LANGUAGES} + +NATIVE_LANGUAGES = {lang: label for lang, label in settings.LANGUAGES if len(lang) == 2} +LANGUAGES = { + lang: NATIVE_LANGUAGES.get(lang, display) + for lang, display in settings.ALL_LANGUAGES +} TRANSLATION_BUTTONS = { 'add': '.metadata-video-translations .create-action', From d194d0e02b6a32f13caeaba80a09a81dc4d65fdc Mon Sep 17 00:00:00 2001 From: Alexander Kryklia Date: Wed, 2 Apr 2014 15:21:57 +0300 Subject: [PATCH 3/4] Wait for big subtitles to render. --- cms/djangoapps/contentstore/features/video-editor.feature | 1 + 1 file changed, 1 insertion(+) diff --git a/cms/djangoapps/contentstore/features/video-editor.feature b/cms/djangoapps/contentstore/features/video-editor.feature index 872ace45e8..8151784bc9 100644 --- a/cms/djangoapps/contentstore/features/video-editor.feature +++ b/cms/djangoapps/contentstore/features/video-editor.feature @@ -59,6 +59,7 @@ Feature: CMS Video Component Editor And I open tab "Advanced" And I upload transcript file "1mb_transcripts.srt" for "uk" language code And I save changes + And I wait for "10" seconds Then when I view the video it does show the captions And I see "Привіт, edX вітає вас." text in the captions From bae60527fb9526512be72794633e943e8d1cfa28 Mon Sep 17 00:00:00 2001 From: Alexander Kryklia Date: Wed, 2 Apr 2014 15:28:53 +0300 Subject: [PATCH 4/4] Set big timeout for big subtitles. --- cms/djangoapps/contentstore/features/transcripts.py | 2 +- cms/djangoapps/contentstore/features/video-editor.feature | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/cms/djangoapps/contentstore/features/transcripts.py b/cms/djangoapps/contentstore/features/transcripts.py index 00f898fbb6..f6413cb924 100644 --- a/cms/djangoapps/contentstore/features/transcripts.py +++ b/cms/djangoapps/contentstore/features/transcripts.py @@ -201,7 +201,7 @@ def upload_file(_step, file_name): @step('I see "([^"]*)" text in the captions') def check_text_in_the_captions(_step, text): - world.wait_for(lambda _: world.css_text('.subtitles')) + world.wait_for(lambda _: world.css_text('.subtitles'), 30) actual_text = world.css_text('.subtitles') assert (text in actual_text) diff --git a/cms/djangoapps/contentstore/features/video-editor.feature b/cms/djangoapps/contentstore/features/video-editor.feature index 8151784bc9..872ace45e8 100644 --- a/cms/djangoapps/contentstore/features/video-editor.feature +++ b/cms/djangoapps/contentstore/features/video-editor.feature @@ -59,7 +59,6 @@ Feature: CMS Video Component Editor And I open tab "Advanced" And I upload transcript file "1mb_transcripts.srt" for "uk" language code And I save changes - And I wait for "10" seconds Then when I view the video it does show the captions And I see "Привіт, edX вітає вас." text in the captions