Commit d6acfa67 by Qubad786 Committed by muzaffaryousaf

Add video source language support for Cielo24 - EDUCATOR-1491

parent c0b5932d
...@@ -953,7 +953,8 @@ class TranscriptPreferencesTestCase(VideoUploadTestBase, CourseTestCase): ...@@ -953,7 +953,8 @@ class TranscriptPreferencesTestCase(VideoUploadTestBase, CourseTestCase):
{ {
'provider': TranscriptProvider.CIELO24, 'provider': TranscriptProvider.CIELO24,
'cielo24_fidelity': 'PROFESSIONAL', 'cielo24_fidelity': 'PROFESSIONAL',
'cielo24_turnaround': 'STANDARD' 'cielo24_turnaround': 'STANDARD',
'video_source_language': 'en'
}, },
True, True,
u"Invalid languages [].", u"Invalid languages [].",
...@@ -962,8 +963,20 @@ class TranscriptPreferencesTestCase(VideoUploadTestBase, CourseTestCase): ...@@ -962,8 +963,20 @@ class TranscriptPreferencesTestCase(VideoUploadTestBase, CourseTestCase):
( (
{ {
'provider': TranscriptProvider.CIELO24, 'provider': TranscriptProvider.CIELO24,
'cielo24_fidelity': 'PREMIUM',
'cielo24_turnaround': 'STANDARD',
'video_source_language': 'es'
},
True,
u"Unsupported source language es.",
400
),
(
{
'provider': TranscriptProvider.CIELO24,
'cielo24_fidelity': 'PROFESSIONAL', 'cielo24_fidelity': 'PROFESSIONAL',
'cielo24_turnaround': 'STANDARD', 'cielo24_turnaround': 'STANDARD',
'video_source_language': 'en',
'preferred_languages': ['es', 'ur'] 'preferred_languages': ['es', 'ur']
}, },
True, True,
...@@ -1016,6 +1029,7 @@ class TranscriptPreferencesTestCase(VideoUploadTestBase, CourseTestCase): ...@@ -1016,6 +1029,7 @@ class TranscriptPreferencesTestCase(VideoUploadTestBase, CourseTestCase):
'provider': TranscriptProvider.CIELO24, 'provider': TranscriptProvider.CIELO24,
'cielo24_fidelity': 'PROFESSIONAL', 'cielo24_fidelity': 'PROFESSIONAL',
'cielo24_turnaround': 'STANDARD', 'cielo24_turnaround': 'STANDARD',
'video_source_language': 'es',
'preferred_languages': ['en'] 'preferred_languages': ['en']
}, },
True, True,
......
...@@ -266,7 +266,7 @@ def validate_transcript_preferences(provider, cielo24_fidelity, cielo24_turnarou ...@@ -266,7 +266,7 @@ def validate_transcript_preferences(provider, cielo24_fidelity, cielo24_turnarou
cielo24_fidelity: Cielo24 transcription fidelity. cielo24_fidelity: Cielo24 transcription fidelity.
cielo24_turnaround: Cielo24 transcription turnaround. cielo24_turnaround: Cielo24 transcription turnaround.
three_play_turnaround: 3PlayMedia transcription turnaround. three_play_turnaround: 3PlayMedia transcription turnaround.
video_source_language: Source/Speech language of the videos that are going to be submitted to 3PlayMedia. video_source_language: Source/Speech language of the videos that are going to be submitted to the Providers.
preferred_languages: list of language codes. preferred_languages: list of language codes.
Returns: Returns:
...@@ -291,12 +291,17 @@ def validate_transcript_preferences(provider, cielo24_fidelity, cielo24_turnarou ...@@ -291,12 +291,17 @@ def validate_transcript_preferences(provider, cielo24_fidelity, cielo24_turnarou
# Validate transcription languages # Validate transcription languages
supported_languages = transcription_plans[provider]['fidelity'][cielo24_fidelity]['languages'] supported_languages = transcription_plans[provider]['fidelity'][cielo24_fidelity]['languages']
if video_source_language not in supported_languages:
error = 'Unsupported source language {}.'.format(video_source_language)
return error, preferences
if not len(preferred_languages) or not (set(preferred_languages) <= set(supported_languages.keys())): if not len(preferred_languages) or not (set(preferred_languages) <= set(supported_languages.keys())):
error = 'Invalid languages {}.'.format(preferred_languages) error = 'Invalid languages {}.'.format(preferred_languages)
return error, preferences return error, preferences
# Validated Cielo24 preferences # Validated Cielo24 preferences
preferences = { preferences = {
'video_source_language': video_source_language,
'cielo24_fidelity': cielo24_fidelity, 'cielo24_fidelity': cielo24_fidelity,
'cielo24_turnaround': cielo24_turnaround, 'cielo24_turnaround': cielo24_turnaround,
'preferred_languages': preferred_languages, 'preferred_languages': preferred_languages,
......
...@@ -101,6 +101,13 @@ function($, Backbone, _, gettext, moment, HtmlUtils, StringUtils, TranscriptSett ...@@ -101,6 +101,13 @@ function($, Backbone, _, gettext, moment, HtmlUtils, StringUtils, TranscriptSett
if (selectedPlan) { if (selectedPlan) {
if (this.selectedProvider === CIELO24 && this.selectedFidelityPlan) { if (this.selectedProvider === CIELO24 && this.selectedFidelityPlan) {
availableLanguages = selectedPlan.fidelity[this.selectedFidelityPlan].languages; availableLanguages = selectedPlan.fidelity[this.selectedFidelityPlan].languages;
// If fidelity is mechanical then target language would be same as source language.
if (this.selectedFidelityPlan === 'MECHANICAL' && this.selectedVideoSourceLanguage) {
availableLanguages = _.pick(
availableLanguages,
this.selectedVideoSourceLanguage
);
}
} else if (this.selectedProvider === THREE_PLAY_MEDIA) { } else if (this.selectedProvider === THREE_PLAY_MEDIA) {
availableLanguages = selectedPlan.languages; availableLanguages = selectedPlan.languages;
} }
...@@ -108,6 +115,16 @@ function($, Backbone, _, gettext, moment, HtmlUtils, StringUtils, TranscriptSett ...@@ -108,6 +115,16 @@ function($, Backbone, _, gettext, moment, HtmlUtils, StringUtils, TranscriptSett
return availableLanguages; return availableLanguages;
}, },
getSourceLanguages: function() {
var sourceLanguages = [];
if (this.selectedProvider === THREE_PLAY_MEDIA) {
sourceLanguages = this.availableTranscriptionPlans[this.selectedProvider].translations;
} else {
sourceLanguages = this.getTargetLanguages();
}
return sourceLanguages;
},
fidelitySelected: function(event) { fidelitySelected: function(event) {
var $fidelityContainer = this.$el.find('.transcript-fidelity-wrapper'); var $fidelityContainer = this.$el.find('.transcript-fidelity-wrapper');
this.selectedFidelityPlan = event.target.value; this.selectedFidelityPlan = event.target.value;
...@@ -116,6 +133,9 @@ function($, Backbone, _, gettext, moment, HtmlUtils, StringUtils, TranscriptSett ...@@ -116,6 +133,9 @@ function($, Backbone, _, gettext, moment, HtmlUtils, StringUtils, TranscriptSett
// Clear active and selected languages. // Clear active and selected languages.
this.selectedLanguages = this.activeLanguages = []; this.selectedLanguages = this.activeLanguages = [];
// Also clear selected language.
this.selectedVideoSourceLanguage = '';
this.renderSourceLanguages();
this.renderTargetLanguages(); this.renderTargetLanguages();
}, },
...@@ -272,8 +292,8 @@ function($, Backbone, _, gettext, moment, HtmlUtils, StringUtils, TranscriptSett ...@@ -272,8 +292,8 @@ function($, Backbone, _, gettext, moment, HtmlUtils, StringUtils, TranscriptSett
$languagesContainer.empty(); $languagesContainer.empty();
// Show language container if fidelity or source language is selected . // Show language container if source language is selected .
if (self.selectedVideoSourceLanguage || self.selectedFidelityPlan) { if (self.selectedVideoSourceLanguage) {
_.each(self.activeLanguages, function(language) { _.each(self.activeLanguages, function(language) {
// Only add if not in the list already. // Only add if not in the list already.
if (_.indexOf(self.selectedLanguages, language) === -1) { if (_.indexOf(self.selectedLanguages, language) === -1) {
...@@ -289,16 +309,18 @@ function($, Backbone, _, gettext, moment, HtmlUtils, StringUtils, TranscriptSett ...@@ -289,16 +309,18 @@ function($, Backbone, _, gettext, moment, HtmlUtils, StringUtils, TranscriptSett
} }
}, },
renderVideoSourceLanguageMenu: function() { renderSourceLanguages: function() {
var self = this, var self = this,
availableTranslations,
availableLanguages = self.getTargetLanguages(), availableLanguages = self.getTargetLanguages(),
availableTranslations = self.getSourceLanguages(),
$videoSourceLanguageContainer = self.$el.find('.video-source-language-wrapper'), $videoSourceLanguageContainer = self.$el.find('.video-source-language-wrapper'),
$languageMenuEl = self.$el.find('.video-source-language'), $languageMenuEl = self.$el.find('.video-source-language'),
selectOptionEl = new Option(gettext('Select language'), ''); selectOptionEl = new Option(gettext('Select language'), '');
if (this.selectedProvider === THREE_PLAY_MEDIA) { // Clear error state if present any.
availableTranslations = self.availableTranscriptionPlans[this.selectedProvider].translations; self.clearPreferenceErrorState($videoSourceLanguageContainer);
if (!_.isEmpty(availableTranslations)) {
$videoSourceLanguageContainer.show(); $videoSourceLanguageContainer.show();
// We need to set id due to a11y aria-labelledby // We need to set id due to a11y aria-labelledby
...@@ -368,7 +390,7 @@ function($, Backbone, _, gettext, moment, HtmlUtils, StringUtils, TranscriptSett ...@@ -368,7 +390,7 @@ function($, Backbone, _, gettext, moment, HtmlUtils, StringUtils, TranscriptSett
this.renderProviders(); this.renderProviders();
this.renderTurnaround(); this.renderTurnaround();
this.renderFidelity(); this.renderFidelity();
this.renderVideoSourceLanguageMenu(); this.renderSourceLanguages();
this.renderTargetLanguages(); this.renderTargetLanguages();
}, },
......
...@@ -143,9 +143,6 @@ ...@@ -143,9 +143,6 @@
} }
.transcript-language-menu-container { .transcript-language-menu-container {
margin-top: ($baseline*0.8); margin-top: ($baseline*0.8);
.transcript-language-menu {
width: 60%;
}
.add-language-action { .add-language-action {
display: inline-block; display: inline-block;
.action-add-language { .action-add-language {
...@@ -153,6 +150,9 @@ ...@@ -153,6 +150,9 @@
} }
} }
} }
.transcript-language-menu, .video-source-language {
width: 60%;
}
} }
.course-video-settings-footer { .course-video-settings-footer {
......
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