From 66e106a9e2b222002c328243be526cd9867402b5 Mon Sep 17 00:00:00 2001 From: Valera Rozuvan Date: Fri, 7 Jun 2013 17:35:57 +0300 Subject: [PATCH 1/4] Copied autoplay attribute from video xmoudle to videoalpha. Now students will have the video autoplaying, and in Studio it will be pause by default. --- .../xmodule/js/src/videoalpha/display/video_player.coffee | 2 +- lms/templates/videoalpha.html | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/common/lib/xmodule/xmodule/js/src/videoalpha/display/video_player.coffee b/common/lib/xmodule/xmodule/js/src/videoalpha/display/video_player.coffee index 8d251cc1f8..9217784a26 100644 --- a/common/lib/xmodule/xmodule/js/src/videoalpha/display/video_player.coffee +++ b/common/lib/xmodule/xmodule/js/src/videoalpha/display/video_player.coffee @@ -99,7 +99,7 @@ class @VideoPlayerAlpha extends SubviewAlpha @video.log 'load_video' if @video.videoType is 'html5' @player.setPlaybackRate @video.speed - unless onTouchBasedDevice() + unless onTouchBasedDevice() or $('.video:first').data('autoplay') == 'False' $('.video-load-complete:first').data('video').player.play() onStateChange: (event) => diff --git a/lms/templates/videoalpha.html b/lms/templates/videoalpha.html index 2028d3c320..fff251de51 100644 --- a/lms/templates/videoalpha.html +++ b/lms/templates/videoalpha.html @@ -18,6 +18,7 @@ data-start="${start}" data-end="${end}" data-caption-asset-path="${caption_asset_path}" + data-autoplay="${settings.MITX_FEATURES['AUTOPLAY_VIDEOS']}" >
From 4c544d6f4984f624d5e71137b28eec99e5aafb33 Mon Sep 17 00:00:00 2001 From: Valera Rozuvan Date: Tue, 11 Jun 2013 13:48:43 +0300 Subject: [PATCH 2/4] Added lettuce tests for autoplay in videoalpha. --- .../courseware/features/videoalpha.feature | 6 ++++ .../courseware/features/videoalpha.py | 34 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 lms/djangoapps/courseware/features/videoalpha.feature create mode 100644 lms/djangoapps/courseware/features/videoalpha.py diff --git a/lms/djangoapps/courseware/features/videoalpha.feature b/lms/djangoapps/courseware/features/videoalpha.feature new file mode 100644 index 0000000000..2a0acb0f9b --- /dev/null +++ b/lms/djangoapps/courseware/features/videoalpha.feature @@ -0,0 +1,6 @@ +Feature: Video Alpha component + As a student, I want to view course videos in LMS. + + Scenario: Autoplay is enabled in LMS + Given the course has a Video component + Then when I view the video it has autoplay enabled diff --git a/lms/djangoapps/courseware/features/videoalpha.py b/lms/djangoapps/courseware/features/videoalpha.py new file mode 100644 index 0000000000..3131e477ed --- /dev/null +++ b/lms/djangoapps/courseware/features/videoalpha.py @@ -0,0 +1,34 @@ +#pylint: disable=C0111 + +from lettuce import world, step +from lettuce.django import django_url +from common import TEST_COURSE_NAME, TEST_SECTION_NAME, i_am_registered_for_the_course, section_location + +############### ACTIONS #################### + + +@step('when I view the video it has autoplay enabled') +def does_autoplay(step): + assert(world.css_find('.videoalpha')[0]['data-autoplay'] == 'True') + + +@step('the course has a Video component') +def view_videoalpha(step): + coursename = TEST_COURSE_NAME.replace(' ', '_') + i_am_registered_for_the_course(step, coursename) + + # Make sure we have a videoalpha + add_videoalpha_to_course(coursename) + chapter_name = TEST_SECTION_NAME.replace(" ", "_") + section_name = chapter_name + url = django_url('/courses/edx/Test_Course/Test_Course/courseware/%s/%s' % + (chapter_name, section_name)) + + world.browser.visit(url) + + +def add_videoalpha_to_course(course): + template_name = 'i4x://edx/templates/videoalpha/default' + world.ItemFactory.create(parent_location=section_location(course), + template=template_name, + display_name='Video Alpha 1') From 9f4dcbcd1bee40d70fa6715f1d7f15b175257f0f Mon Sep 17 00:00:00 2001 From: Alexander Kryklia Date: Tue, 11 Jun 2013 14:24:29 +0300 Subject: [PATCH 3/4] disables pylint warning for lettuce tests syntax --- lms/djangoapps/courseware/features/videoalpha.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lms/djangoapps/courseware/features/videoalpha.py b/lms/djangoapps/courseware/features/videoalpha.py index 3131e477ed..cabf8c681f 100644 --- a/lms/djangoapps/courseware/features/videoalpha.py +++ b/lms/djangoapps/courseware/features/videoalpha.py @@ -1,4 +1,6 @@ #pylint: disable=C0111 +#pylint: disable=W0613 +#pylint: disable=W0621 from lettuce import world, step from lettuce.django import django_url From 72d7c9ca97e65949620d908f761c7ff8ee522bf7 Mon Sep 17 00:00:00 2001 From: Valera Rozuvan Date: Wed, 12 Jun 2013 11:57:54 +0300 Subject: [PATCH 4/4] Moved the definition of autoplay attribute to videoalpha_module.py file. Changed double negative if statement for autoplay check to simple if. --- .../xmodule/js/src/videoalpha/display/video_player.coffee | 2 +- common/lib/xmodule/xmodule/videoalpha_module.py | 4 +++- lms/templates/videoalpha.html | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/common/lib/xmodule/xmodule/js/src/videoalpha/display/video_player.coffee b/common/lib/xmodule/xmodule/js/src/videoalpha/display/video_player.coffee index 9217784a26..13c7614483 100644 --- a/common/lib/xmodule/xmodule/js/src/videoalpha/display/video_player.coffee +++ b/common/lib/xmodule/xmodule/js/src/videoalpha/display/video_player.coffee @@ -99,7 +99,7 @@ class @VideoPlayerAlpha extends SubviewAlpha @video.log 'load_video' if @video.videoType is 'html5' @player.setPlaybackRate @video.speed - unless onTouchBasedDevice() or $('.video:first').data('autoplay') == 'False' + if not onTouchBasedDevice() and $('.video:first').data('autoplay') is 'True' $('.video-load-complete:first').data('video').player.play() onStateChange: (event) => diff --git a/common/lib/xmodule/xmodule/videoalpha_module.py b/common/lib/xmodule/xmodule/videoalpha_module.py index 92cd176af7..43de021799 100644 --- a/common/lib/xmodule/xmodule/videoalpha_module.py +++ b/common/lib/xmodule/xmodule/videoalpha_module.py @@ -5,6 +5,7 @@ from lxml import etree from pkg_resources import resource_string, resource_listdir from django.http import Http404 +from django.conf import settings from xmodule.x_module import XModule from xmodule.raw_module import RawDescriptor @@ -147,7 +148,8 @@ class VideoAlphaModule(VideoAlphaFields, XModule): 'caption_asset_path': caption_asset_path, 'show_captions': self.show_captions, 'start': self.start_time, - 'end': self.end_time + 'end': self.end_time, + 'autoplay': settings.MITX_FEATURES.get('AUTOPLAY_VIDEOS', True) }) diff --git a/lms/templates/videoalpha.html b/lms/templates/videoalpha.html index fff251de51..07c7dbee27 100644 --- a/lms/templates/videoalpha.html +++ b/lms/templates/videoalpha.html @@ -18,7 +18,7 @@ data-start="${start}" data-end="${end}" data-caption-asset-path="${caption_asset_path}" - data-autoplay="${settings.MITX_FEATURES['AUTOPLAY_VIDEOS']}" + data-autoplay="${autoplay}" >