Commit e91481cf by Mushtaq Ali

Add language sorting,

Transcript title video file format extesion removed dynamically,
Code refactor
parent adbb953c
...@@ -575,7 +575,25 @@ def _get_index_videos(course): ...@@ -575,7 +575,25 @@ def _get_index_videos(course):
] ]
def get_all_transcript_languages(): def get_all_transcript_languages():
return get_3rd_party_transcription_plans()[TranscriptProvider.THREE_PLAY_MEDIA]['languages'] """
Returns all possible languages for transcript.
"""
transcription_plans = get_3rd_party_transcription_plans()
cielo_fidelity = transcription_plans[TranscriptProvider.CIELO24]['fidelity']
# Get third party transcription languages.
third_party_transcription_languages = transcription_plans[TranscriptProvider.THREE_PLAY_MEDIA]['languages']
third_party_transcription_languages = dict(third_party_transcription_languages, **cielo_fidelity['MECHANICAL']['languages'])
third_party_transcription_languages = dict(third_party_transcription_languages , **cielo_fidelity['PREMIUM']['languages'])
third_party_transcription_languages = dict(third_party_transcription_languages, **cielo_fidelity['PROFESSIONAL']['languages'])
# Get all settings languages dict.
all_languages = {}
for language in settings.ALL_LANGUAGES:
all_languages.update({language[0]: language[1]})
# Return combined settings and 3rd party transcript languages.
return dict(all_languages, **third_party_transcription_languages)
def videos_index_html(course): def videos_index_html(course):
""" """
......
...@@ -53,7 +53,8 @@ define([ ...@@ -53,7 +53,8 @@ define([
collection: updatedCollection, collection: updatedCollection,
encodingsDownloadUrl: encodingsDownloadUrl, encodingsDownloadUrl: encodingsDownloadUrl,
videoImageSettings: videoImageSettings, videoImageSettings: videoImageSettings,
transcriptAvailableLanguages: transcriptAvailableLanguages transcriptAvailableLanguages: transcriptAvailableLanguages,
videoSupportedFileFormats: videoSupportedFileFormats
}); });
$contentWrapper.find('.wrapper-assets').replaceWith(updatedView.render().$el); $contentWrapper.find('.wrapper-assets').replaceWith(updatedView.render().$el);
}); });
...@@ -66,7 +67,8 @@ define([ ...@@ -66,7 +67,8 @@ define([
collection: new Backbone.Collection(previousUploads), collection: new Backbone.Collection(previousUploads),
encodingsDownloadUrl: encodingsDownloadUrl, encodingsDownloadUrl: encodingsDownloadUrl,
videoImageSettings: videoImageSettings, videoImageSettings: videoImageSettings,
transcriptAvailableLanguages: transcriptAvailableLanguages transcriptAvailableLanguages: transcriptAvailableLanguages,
videoSupportedFileFormats: videoSupportedFileFormats
}); });
$contentWrapper.append(activeView.render().$el); $contentWrapper.append(activeView.render().$el);
$contentWrapper.append(previousView.render().$el); $contentWrapper.append(previousView.render().$el);
......
...@@ -33,7 +33,8 @@ define( ...@@ -33,7 +33,8 @@ define(
transcripts: this.model.get('transcripts'), transcripts: this.model.get('transcripts'),
edxVideoID: this.model.get('edx_video_id'), edxVideoID: this.model.get('edx_video_id'),
clientVideoID: this.model.get('client_video_id'), clientVideoID: this.model.get('client_video_id'),
transcriptAvailableLanguages: this.options.transcriptAvailableLanguages transcriptAvailableLanguages: options.transcriptAvailableLanguages,
videoSupportedFileFormats: options.videoSupportedFileFormats
}); });
}, },
......
...@@ -17,7 +17,8 @@ define( ...@@ -17,7 +17,8 @@ define(
videoHandlerUrl: options.videoHandlerUrl, videoHandlerUrl: options.videoHandlerUrl,
videoImageSettings: options.videoImageSettings, videoImageSettings: options.videoImageSettings,
model: model, model: model,
transcriptAvailableLanguages: options.transcriptAvailableLanguages transcriptAvailableLanguages: options.transcriptAvailableLanguages,
videoSupportedFileFormats: options.videoSupportedFileFormats
}); });
}); });
}, },
......
...@@ -19,14 +19,42 @@ define( ...@@ -19,14 +19,42 @@ define(
this.edxVideoID = options.edxVideoID; this.edxVideoID = options.edxVideoID;
this.clientVideoID = options.clientVideoID; this.clientVideoID = options.clientVideoID;
this.transcriptAvailableLanguages = options.transcriptAvailableLanguages; this.transcriptAvailableLanguages = options.transcriptAvailableLanguages;
this.videoSupportedFileFormats = options.videoSupportedFileFormats;
this.template = HtmlUtils.template(videoTranscriptsTemplate); this.template = HtmlUtils.template(videoTranscriptsTemplate);
}, },
/*
Sorts object by value and returns a sorted array.
*/
sortByValue: function(itemObject) {
var sortedArray = [];
_.each(itemObject, function(value, key) {
// Push each JSON Object entry in array by [value, key]
sortedArray.push([value, key]);
});
return sortedArray.sort();
},
/*
Returns transcript title.
*/
getTranscriptClientTitle: function() { getTranscriptClientTitle: function() {
// TODO: Use supported video file types. // Use a fixed length tranascript name.
return this.clientVideoID.substring(0, 20).replace('.mp4', ''); var clientTitle = this.clientVideoID.substring(0, 20);
// Remove video file extension for transcript title.
_.each(this.videoSupportedFileFormats, function(videoFormat) {
clientTitle.replace(videoFormat, '');
});
return clientTitle;
}, },
/*
Toggles Show/Hide transcript button and transcripts container.
*/
toggleShowTranscripts: function() { toggleShowTranscripts: function() {
var $transcriptsWrapperEl = this.$el.find('.show-video-transcripts-wrapper'); var $transcriptsWrapperEl = this.$el.find('.show-video-transcripts-wrapper');
...@@ -53,15 +81,17 @@ define( ...@@ -53,15 +81,17 @@ define(
this.$el.find('.toggle-show-transcripts-icon').removeClass('fa-caret-right'); this.$el.find('.toggle-show-transcripts-icon').removeClass('fa-caret-right');
this.$el.find('.toggle-show-transcripts-icon').addClass('fa-caret-down'); this.$el.find('.toggle-show-transcripts-icon').addClass('fa-caret-down');
} }
}, },
/*
Renders transcripts view.
*/
render: function() { render: function() {
HtmlUtils.setHtml( HtmlUtils.setHtml(
this.$el, this.$el,
this.template({ this.template({
transcripts: this.transcripts, transcripts: this.transcripts,
transcriptAvailableLanguages: this.transcriptAvailableLanguages, transcriptAvailableLanguages: this.sortByValue(this.transcriptAvailableLanguages),
edxVideoID: this.edxVideoID, edxVideoID: this.edxVideoID,
// Slice last 4 letters so that video filetype is not attached // Slice last 4 letters so that video filetype is not attached
// eg. eg. Harry-Potter.mp4 would give us eg. Harry-Potter // eg. eg. Harry-Potter.mp4 would give us eg. Harry-Potter
......
...@@ -16,8 +16,8 @@ ...@@ -16,8 +16,8 @@
<strong><%- StringUtils.interpolate(gettext('{transcriptClientTitle}_{transcriptLanguageCode}.{fileExtension}'), {transcriptClientTitle: transcriptClientTitle, transcriptLanguageCode: transcriptLanguageCode, fileExtension: transcriptDownloadFileFormat}) %></strong> <strong><%- StringUtils.interpolate(gettext('{transcriptClientTitle}_{transcriptLanguageCode}.{fileExtension}'), {transcriptClientTitle: transcriptClientTitle, transcriptLanguageCode: transcriptLanguageCode, fileExtension: transcriptDownloadFileFormat}) %></strong>
<select id='transcript-language-<%- transcriptLanguageCode %>' class='transcript-language-menu'> <select id='transcript-language-<%- transcriptLanguageCode %>' class='transcript-language-menu'>
<option value=''>Select Language</option> <option value=''>Select Language</option>
<% _.each(transcriptAvailableLanguages, function(languageText, languageCode){ %> <% _.each(transcriptAvailableLanguages, function(availableLanguage){ %>
<option value='<%- languageCode %>' <%- transcriptLanguageCode === languageCode ? 'selected': '' %>><%- languageText %></option> <option value='<%- availableLanguage[1] %>' <%- transcriptLanguageCode === availableLanguage[1] ? 'selected': '' %>><%- availableLanguage[0] %></option>
<% }) %> <% }) %>
</select> </select>
<div class='transcript-actions'> <div class='transcript-actions'>
......
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