Skip to content

Conversation

@mushtaqak
Copy link
Contributor

@mushtaqak mushtaqak commented Sep 26, 2016

Description

This change handles the case when no transcript file is uploaded for a language then raise an exception that transcript file is not uploaded yet. This wouldn't let user save transcript language if no transcript file is uploaded for it.

Also, this change handles the videos that have language already added in the database but no transcript file was uploaded. This prevents showing of such languages as transcript on the video.

TNL-5200

Sandbox

Testing

  • Unit
  • Acceptance

Reviewers

If you've been tagged for review, please check your corresponding box once you've given the 👍.

Post-review

  • Squash commits

@mushtaqak mushtaqak force-pushed the mushtaq/video-transcript branch from a2661d2 to f90705e Compare September 26, 2016 11:13
@muzaffaryousaf
Copy link

@mushtaqak Can you bake sandbox for this change to look at the behavior.

@mushtaqak
Copy link
Contributor Author

@muzaffaryousaf Sure, I will make one right away :)

@mushtaqak
Copy link
Contributor Author

I have started the jenkins build which would create the video transcript sandbox

@mushtaqak
Copy link
Contributor Author

@sstack22 If you try to add a new transcript language and upload no transcript file here in sandbox, you would get the error message and corresponding transcript language is not saved now :

screen shot 2016-09-27 at 5 16 47 pm

The issue is the error message is too generic and does not tell what the error has occurred leading user ambiguity.

I have tried to find the correct solution but to implement a good solution would take good amount of time.

I have also tried to catch this exception at _save_xblock method which is also called when editor is saved, handling exception here outputs the correct error message :

screen shot 2016-09-27 at 5 16 14 pm

What do you think, we should do here ?

@mushtaqak
Copy link
Contributor Author

@marcotuts Since @sstack22 is on leave, can you please reply to above question. Thanks :)

@marcotuts
Copy link
Contributor

marcotuts commented Sep 29, 2016

@mushtaqak - My suggestion here might be to allow save but to instead reuse the validation message pattern used by the Randomized Content Block (and in this Conditional UI block PR ex: https://github.com/edx/edx-platform/pull/11710) to say something to the effect of: "There is no language transcript file associated with one of the defined transcript languages" (cc'ed @catong here as well). The link / action on this message could read: "Upload transcript file"

I included an example of the validation message shown for the conditional block
image

Does this work in terms of reduction in complexity and scope?

@catong
Copy link
Contributor

catong commented Sep 30, 2016

If I understand correctly, this error is associated with a specific "Save" of video settings. Perhaps just a slight tweak to @marcotuts' suggestion:
"There is no transcript file associated with the selected transcript language." (rather than "one of the defined languages"?)
@mushtaqak please let me know if my understanding is correct.

@mushtaqak mushtaqak force-pushed the mushtaq/video-transcript branch 4 times, most recently from 08ee17f to 1a992fb Compare October 4, 2016 12:37
@mushtaqak
Copy link
Contributor Author

@sstack22 Please review from product perspective.

You can look at the video component which now shows the validation message if transcript file is not uploaded for a language as suggested by @marcotuts

screen shot 2016-10-04 at 5 42 18 pm

@catong FYI about the validation message containing language name.

@muzaffaryousaf
Copy link

@mushtaqak I'm seeing error on this page, can you confirm that's its not happening due to our change ?
https://studio-videotranscript.sandbox.edx.org/container/block-v1:edX+Test101+course+type@vertical+block@f29b97786e7840dbb532bdd248d792d1

@catong
Copy link
Contributor

catong commented Oct 4, 2016

@mushtaqak Looks great with the language name brought into the message. Is the language name itself also localized when the message is localized?

@mushtaqak
Copy link
Contributor Author

@catong Only message is localized, language names are not localized.

@catong
Copy link
Contributor

catong commented Oct 4, 2016

Thanks @mushtaqak. Is it preferable to have the specific language name in the message if it will appear only in English regardless of the language of the UI/message or should we have something generic to avoid this? @sstack22 @marcotuts what are your thoughts?

@mushtaqak
Copy link
Contributor Author

@catong yes, it is infact, I have done that part where we show language name instead of language code. It's just there is some translation issue which I was working on.

@mushtaqak mushtaqak force-pushed the mushtaq/video-transcript branch 2 times, most recently from 45f8e92 to ebb789e Compare October 5, 2016 13:07
Copy link
Contributor

@muhammad-ammar muhammad-ammar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mushtaqak I am done with first pass of the review. Let me know once you addressed the feedback.


def test_save_language_upload_no_transcript(self):
"""
Scenario: User can can not save transcript language if no transcript file is uploaded
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicate can

[u"en", u"English"],
[u"eo", u"Esperanto"],
[u"ur", u"Urdu"]
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mushtaqak We need to restore settings.ALL_LANGUAGES to its original value, otherwise other tests will see this modified value.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mushtaqak Can we not use @override_settings(ALL_LANGUAGES =()) ?

"""
validation = super(VideoDescriptor, self).validate()
if not isinstance(validation, StudioValidation):
validation = StudioValidation.copy(validation)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mushtaqak Why we need to make copy here?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's the way to have validation copy object when we don't have one. Already being used in couple of places.

And I open tab "Advanced"
And I add a language "uk" but do not upload an .srt file
And I save changes
Then when I view the video
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mushtaqak I think Then i view the video is enough.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I view the video captions/language menu
Then I cannot see the language "uk" translation

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then I am not able to see the language "uk" translation

self.assertIn(unicode_text, self.video.captions_text)
self.assertEqual(self.video.caption_languages.keys(), ['zh', 'uk'])

def test_save_language_upload_no_transcript(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mushtaqak This tests check studio side flow. Do we also need a test for lms?
@muzaffaryousaf Any thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@muhammad-ammar Actually this test checks if a transcript language is shown in language menu if no transcript file is uploaded on video which would be same on LMS side as well.

self.assertEqual(StudioValidationMessage.WARNING, validation.summary.type)
self.assertIn("There is no transcript file associated", validation.summary.text)

def test_no_transcript_multi_lang_validation_message(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mushtaqak I think we can merge test_no_transcript_multi_lang_validation_message and test_no_transcript_single_lang_validation_message into test using ddt. You can see ddt exmamples in test_capa_problem.py

Also please check the complete validation message.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't need ddt here, we can just merge both tests.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we can check both the messages completely without ddt then its good.

translations = descriptor.available_translations(descriptor.get_transcripts_info(), verify_assets=False)
self.assertEqual(translations, ['en'])

def test_video_with_lang_with_no_transcripts_translation(self):
Copy link

@muzaffaryousaf muzaffaryousaf Oct 6, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say to change the name to more readable form, Maybe you can choose test_video_with_language_do_not_have_transcripts_translation.

# remove key from transcripts because proper srt file does not exist in assets.
item.transcripts.pop(lang)
reraised_message += ' ' + ex.message
pass

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we don't need this anymore ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because now we are saving language and not raising exception.

"""
# If user transcript filename is empty, raise `TranscriptException` to avoid `InvalidKeyError`.
if not filename:
raise TranscriptException("Transcript not uploaded yet")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does raising this exception results into error on studio/lms ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After @marcotuts 's suggestion to save the language even if the associated transcript file is not uploaded, this does not result into the error on studio/lms.

However, as a precaution, I have added this so that a correct exception would be generated which may/may-not be handled (depends upon the caller of asset_location method). This is just a way for us to be safe from InvalidKeyError when no asset is present.

sub = self.sub

# Only attach transcripts that are not empty.
transcripts = {k: v for k, v in transcripts.items() if v != ''}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we rename k & v according to the content.

validation = StudioValidation.copy(validation)

no_transcript_lang = []
for lang, transcript in self.transcripts.items():

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lang --> lang_code


def test_save_language_upload_no_transcript(self):
"""
Scenario: Transcript language is not shown in captions if no transcript file is uploaded

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

captions menu

@muzaffaryousaf
Copy link

@mushtaqak I've done my first pas and left some comments, let me know when you're done with addressing them.

@mushtaqak mushtaqak force-pushed the mushtaq/video-transcript branch from c1b9c75 to 2d478a2 Compare October 7, 2016 09:36
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mushtaqak @muzaffaryousaf There is too much duplication in this test. It can be written far better with ddt.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mushtaqak I think this will fail. s is missing at the end of language.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use ddt here for <transcript /> to inject in xml_data_transcripts instead of repeating same thing twice.

Copy link

@muzaffaryousaf muzaffaryousaf Oct 7, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Asserts that the validation message has all expected content

@muzaffaryousaf
Copy link

@mushtaqak i'm done with 2nd pass and left couple of comments. Let me know when you're done.

@mushtaqak mushtaqak force-pushed the mushtaq/video-transcript branch 2 times, most recently from 09fa876 to bb82426 Compare October 7, 2016 12:19
@sstack22
Copy link

sstack22 commented Oct 7, 2016

@mushtaqak - this looks great 👍 on my end. @catong is the language used here good to go?

@mushtaqak
Copy link
Contributor Author

@mushtaqak mushtaqak force-pushed the mushtaq/video-transcript branch from bb82426 to c03c4d3 Compare October 7, 2016 13:15
@muzaffaryousaf
Copy link

👍

@catong
Copy link
Contributor

catong commented Oct 7, 2016

@mushtaqak @sstack22 The error message seems to have changed a bit since I last looked at this PR. Previously we had the word "the" in front of the language name, which reads correctly. Now it looks as if "the" is removed, and it does not read quite grammatically, at least in English. My suggestion is to restore "the", so that the message reads, "There is no transcript associated with the Urdu language." OR remove the word language so that the message reads, "There is no transcript associated with Urdu."

@muhammad-ammar
Copy link
Contributor

👍

@mushtaqak
Copy link
Contributor Author

@catong Thanks for the suggestion.

So for surety, the messages would read as follows;

When one language missing transcript file :

There is no transcript file associated with the Urdu language.

When multiple languages missing transcript files :

There are no transcript files associated with the Esperanto, Urdu languages.

Please correct me if I am wrong.

@catong
Copy link
Contributor

catong commented Oct 7, 2016

@mushtaqak That is exactly right. Thanks!

@catong
Copy link
Contributor

catong commented Oct 7, 2016

👍 with the message revisions as captured above. Thanks!

…ge in a video component in studio.

Also, don't show respective transcript language in video language menu when a related transcript is not uploaded for that language.

TNL-5200
@mushtaqak mushtaqak force-pushed the mushtaq/video-transcript branch from c03c4d3 to 11a07ca Compare October 7, 2016 14:16
@mushtaqak mushtaqak merged commit 2338858 into master Oct 7, 2016
@mushtaqak mushtaqak deleted the mushtaq/video-transcript branch October 7, 2016 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants