Video status improvements

This commit is contained in:
Qubad786
2018-06-14 15:30:11 +05:00
committed by M. Rehan
parent c7c2f808e7
commit aa2afd8c0b
6 changed files with 85 additions and 10 deletions

View File

@@ -236,7 +236,8 @@ class VideosHandlerTestCase(VideoUploadTestMixin, CourseTestCase):
'duration',
'status',
'course_video_image_url',
'transcripts'
'transcripts',
'transcription_status'
])
)
dateutil.parser.parse(response_video['created'])
@@ -249,8 +250,10 @@ class VideosHandlerTestCase(VideoUploadTestMixin, CourseTestCase):
@ddt.data(
(
['edx_video_id', 'client_video_id', 'created', 'duration', 'status', 'course_video_image_url',
'transcripts'],
[
'edx_video_id', 'client_video_id', 'created', 'duration',
'status', 'course_video_image_url', 'transcripts', 'transcription_status',
],
[
{
'video_id': 'test1',
@@ -263,8 +266,10 @@ class VideosHandlerTestCase(VideoUploadTestMixin, CourseTestCase):
['en']
),
(
['edx_video_id', 'client_video_id', 'created', 'duration', 'status', 'course_video_image_url',
'transcripts'],
[
'edx_video_id', 'client_video_id', 'created', 'duration',
'status', 'course_video_image_url', 'transcripts', 'transcription_status',
],
[
{
'video_id': 'test1',
@@ -583,9 +588,20 @@ class VideosHandlerTestCase(VideoUploadTestMixin, CourseTestCase):
status = convert_video_status(video)
self.assertEqual(status, StatusDisplayStrings.get('youtube_duplicate'))
# `transcript_ready` should be converted to `file_complete`
video['status'] = 'transcript_ready'
status = convert_video_status(video)
self.assertEqual(status, StatusDisplayStrings.get('file_complete'))
# The encode status should be converted to `file_complete` if video encodes are complete
video['status'] = 'transcription_in_progress'
status = convert_video_status(video, is_video_encodes_ready=True)
self.assertEqual(status, StatusDisplayStrings.get('file_complete'))
# for all other status, there should not be any conversion
statuses = StatusDisplayStrings._STATUS_MAP.keys() # pylint: disable=protected-access
statuses.remove('invalid_token')
statuses.remove('transcript_ready')
for status in statuses:
video['status'] = status
new_status = convert_video_status(video)
@@ -635,6 +651,39 @@ class VideosHandlerTestCase(VideoUploadTestMixin, CourseTestCase):
self.assert_video_status(url, edx_video_id, 'Failed')
@ddt.data(
('test_video_token', "Transcription in Progress"),
('', "Ready"),
)
@ddt.unpack
def test_video_transcript_status_conversion(self, course_video_upload_token, expected_video_status_text):
"""
Verifies that video status `transcription_in_progress` gets converted
correctly into the `file_complete` for the new video workflow and
stays as it is, for the old video workflow.
"""
self.course.video_upload_pipeline = {
'course_video_upload_token': course_video_upload_token
}
self.save_course()
url = self.get_url_for_course_key(self.course.id)
edx_video_id = 'test1'
self.assert_video_status(url, edx_video_id, 'Uploading')
response = self.client.post(
url,
json.dumps([{
'edxVideoId': edx_video_id,
'status': 'transcription_in_progress',
'message': 'Transcription is in progress'
}]),
content_type="application/json"
)
self.assertEqual(response.status_code, 204)
self.assert_video_status(url, edx_video_id, expected_video_status_text)
@ddt.data(True, False)
@patch('openedx.core.djangoapps.video_config.models.VideoTranscriptEnabledFlag.feature_enabled')
def test_video_index_transcript_feature_enablement(self, is_video_transcript_enabled, video_transcript_feature):

View File

@@ -499,7 +499,7 @@ def _get_and_validate_course(course_key_string, user):
return None
def convert_video_status(video):
def convert_video_status(video, is_video_encodes_ready=False):
"""
Convert status of a video. Status can be converted to one of the following:
@@ -524,6 +524,8 @@ def convert_video_status(video):
])
elif video['status'] == 'invalid_token':
status = StatusDisplayStrings.get('youtube_duplicate')
elif is_video_encodes_ready or video['status'] == 'transcript_ready':
status = StatusDisplayStrings.get('file_complete')
else:
status = StatusDisplayStrings.get(video['status'])
@@ -536,10 +538,26 @@ def _get_videos(course):
"""
videos = list(get_videos_for_course(unicode(course.id), VideoSortField.created, SortDirection.desc))
# This is required to see if edx video pipeline is enabled while converting the video status.
course_video_upload_token = course.video_upload_pipeline.get('course_video_upload_token')
# convert VAL's status to studio's Video Upload feature status.
for video in videos:
video["status"] = convert_video_status(video)
# If we are using "new video workflow" and status is `transcription_in_progress` then video encodes are ready.
# This is because Transcription starts once all the encodes are complete except for YT, but according to
# "new video workflow" YT is disabled as well as deprecated. So, Its precise to say that the Transcription
# starts once all the encodings are complete *for the new video workflow*.
is_video_encodes_ready = not course_video_upload_token and video['status'] == 'transcription_in_progress'
# Update with transcript languages
video['transcripts'] = get_available_transcript_languages(video_id=video['edx_video_id'])
# Transcription status should only be visible if 3rd party transcripts are pending.
video['transcription_status'] = (
StatusDisplayStrings.get(video['status'])
if not video['transcripts'] and is_video_encodes_ready else
''
)
# Convert the video status.
video['status'] = convert_video_status(video, is_video_encodes_ready)
return videos
@@ -556,7 +574,10 @@ def _get_index_videos(course):
Returns the information about each video upload required for the video list
"""
course_id = unicode(course.id)
attrs = ['edx_video_id', 'client_video_id', 'created', 'duration', 'status', 'courses', 'transcripts']
attrs = [
'edx_video_id', 'client_video_id', 'created', 'duration',
'status', 'courses', 'transcripts', 'transcription_status',
]
def _get_values(video):
"""

View File

@@ -33,6 +33,7 @@ define(
transcripts: this.model.get('transcripts'),
edxVideoID: this.model.get('edx_video_id'),
clientVideoID: this.model.get('client_video_id'),
transcriptionStatus: this.model.get('transcription_status'),
transcriptAvailableLanguages: options.transcriptAvailableLanguages,
videoSupportedFileFormats: options.videoSupportedFileFormats,
videoTranscriptSettings: options.videoTranscriptSettings

View File

@@ -22,6 +22,7 @@ define(
this.transcripts = options.transcripts;
this.edxVideoID = options.edxVideoID;
this.clientVideoID = options.clientVideoID;
this.transcriptionStatus = options.transcriptionStatus;
this.transcriptAvailableLanguages = options.transcriptAvailableLanguages;
this.videoSupportedFileFormats = options.videoSupportedFileFormats;
this.videoTranscriptSettings = options.videoTranscriptSettings;
@@ -337,6 +338,7 @@ define(
this.$el,
this.template({
transcripts: this.transcripts,
transcription_status: this.transcriptionStatus,
transcriptAvailableLanguages: this.transcriptAvailableLanguages,
edxVideoID: this.edxVideoID,
transcriptClientTitle: this.getTranscriptClientTitle(),

View File

@@ -15,8 +15,8 @@
<div class="video-head-col video-col date-col"><%- gettext("Date Added") %></div>
<div class="video-head-col video-col video-id-col"><%- gettext("Video ID") %></div>
<div class="video-head-col video-col transcripts-col"><%- gettext("Transcripts") %></div>
<div class="video-head-col video-col status-col"><%- gettext("Status") %></div>
<div class="video-head-col video-col actions-col"><%- gettext("Action") %></div>
<div class="video-head-col video-col status-col"><%- gettext("Video Status") %></div>
<div class="video-head-col video-col actions-col"><%- gettext("Action") %></div>
</div>
</div>
<div class="js-table-body"></div>

View File

@@ -8,6 +8,8 @@
</span>
</strong>
</button>
<% } else if (transcription_status) { %>
<span class='transcripts-empty-text'><%- transcription_status %></span>
<% } else { %>
<span class='transcripts-empty-text'><%- gettext('No transcript uploaded.') %></span>
<% }%>