Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ These are notable changes in edx-platform. This is a rolling list of changes,
in roughly chronological order, most recent first. Add your entries at or near
the top. Include a label indicating the component affected.

Blades: Persist student progress in video. BLD-385.

Blades: Fix for the list metadata editor that gets into a bad state where "Add"
is disabled. BLD-821.

Expand Down
51 changes: 51 additions & 0 deletions cms/djangoapps/contentstore/features/video.feature
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,54 @@ Feature: CMS.Video Component
And I save changes
And I click video button "play"
Then I see a range on slider

# 12
Scenario: Check that position is stored on page refresh, position within start-end range
Given I have created a Video component with subtitles
And Make sure captions are closed
And I edit the component
And I open tab "Advanced"
And I set value "00:00:12" to the field "Start Time"
And I set value "00:00:24" to the field "End Time"
And I save changes
And I click video button "play"
Then I see a range on slider
Then I seek video to "16" seconds
And I click video button "pause"
And I reload the page
And I click video button "play"
Then I see video starts playing from "0:16" position

# 13
Scenario: Check that position is stored on page refresh, position before start-end range
Given I have created a Video component with subtitles
And Make sure captions are closed
And I edit the component
And I open tab "Advanced"
And I set value "00:00:12" to the field "Start Time"
And I set value "00:00:24" to the field "End Time"
And I save changes
And I click video button "play"
Then I see a range on slider
Then I seek video to "5" seconds
And I click video button "pause"
And I reload the page
And I click video button "play"
Then I see video starts playing from "0:12" position

# 14
Scenario: Check that position is stored on page refresh, position after start-end range
Given I have created a Video component with subtitles
And Make sure captions are closed
And I edit the component
And I open tab "Advanced"
And I set value "00:00:12" to the field "Start Time"
And I set value "00:00:24" to the field "End Time"
And I save changes
And I click video button "play"
Then I see a range on slider
Then I seek video to "30" seconds
And I click video button "pause"
And I reload the page
And I click video button "play"
Then I see video starts playing from "0:12" position
14 changes: 14 additions & 0 deletions cms/djangoapps/contentstore/features/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,17 @@ def click_button_video(_step, button_type):
button = button_type.strip()
world.css_click(VIDEO_BUTTONS[button])


@step('I seek video to "([^"]*)" seconds$')
def seek_video_to_n_seconds(_step, seconds):
time = float(seconds.strip())
jsCode = "$('.video').data('video-player-state').videoPlayer.onSlideSeek({{time: {0:f}}})".format(time)
world.browser.execute_script(jsCode)


@step('I see video starts playing from "([^"]*)" position$')
def start_playing_video_from_n_seconds(_step, position):
world.wait_for(
func=lambda _: world.css_html('.vidtime')[:4] == position.strip(),
timeout=5
)
5 changes: 3 additions & 2 deletions common/lib/xmodule/xmodule/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ class RelativeTime(Field):
# Timedeltas are immutable, see http://docs.python.org/2/library/datetime.html#available-types
MUTABLE = False

def _isotime_to_timedelta(self, value):
@classmethod
def isotime_to_timedelta(cls, value):
"""
Validate that value in "HH:MM:SS" format and convert to timedelta.

Expand Down Expand Up @@ -175,7 +176,7 @@ def from_json(self, value):
return datetime.timedelta(seconds=value)

if isinstance(value, basestring):
return self._isotime_to_timedelta(value)
return self.isotime_to_timedelta(value)

msg = "RelativeTime Field {0} has bad value '{1!r}'".format(self._name, value)
raise TypeError(msg)
Expand Down
1 change: 1 addition & 0 deletions common/lib/xmodule/xmodule/js/fixtures/video.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
data-speed="1.5"
data-start=""
data-end=""
data-saved-video-position="0"
data-caption-asset-path="/static/subs/"
data-autoplay="False"
data-yt-test-timeout="1500"
Expand Down
1 change: 1 addition & 0 deletions common/lib/xmodule/xmodule/js/fixtures/video_all.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
data-speed="1.5"
data-start=""
data-end=""
data-saved-video-position="0"
data-caption-asset-path="/static/subs/"
data-sub="Z5KLxerq05Y"
data-mp4-source="xmodule/include/fixtures/test.mp4"
Expand Down
1 change: 1 addition & 0 deletions common/lib/xmodule/xmodule/js/fixtures/video_html5.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
data-speed="1.5"
data-start=""
data-end=""
data-saved-video-position="0"
data-caption-asset-path="/static/subs/"
data-sub="Z5KLxerq05Y"
data-mp4-source="xmodule/include/fixtures/test.mp4"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
data-speed="1.5"
data-start=""
data-end=""
data-saved-video-position="0"
data-caption-asset-path="/static/subs/"
data-autoplay="False"
data-yt-test-timeout="1500"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
data-speed="1.5"
data-start=""
data-end=""
data-saved-video-position="0"
data-caption-asset-path="/static/subs/"
data-autoplay="False"
data-yt-test-timeout="1500"
Expand Down
11 changes: 5 additions & 6 deletions common/lib/xmodule/xmodule/js/spec/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,18 +207,17 @@
beforeEach(function () {
this.addMatchers({
toHaveAttrs: function (attrs) {
var element = this.actual,
result = true;
var element;

if ($.isEmptyObject(attrs)) {
return false;
}

$.each(attrs, function (name, value) {
return result = result && element.attr(name) === value;
});
element = this.actual;

return result;
return _.every(attrs, function (value, name) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

return element.attr(name) === value;
});
},
toBeInRange: function (min, max) {
return min <= this.actual && this.actual <= max;
Expand Down
149 changes: 0 additions & 149 deletions common/lib/xmodule/xmodule/js/spec/video/cookie_storage_spec.js

This file was deleted.

1 change: 1 addition & 0 deletions common/lib/xmodule/xmodule/js/spec/video/events_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
afterEach(function () {
$('source').remove();
window.onTouchBasedDevice = oldOTBD;
state.storage.clear();
});

it('initialize', function () {
Expand Down
17 changes: 13 additions & 4 deletions common/lib/xmodule/xmodule/js/spec/video/general_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

afterEach(function () {
$('source').remove();
window.VideoState = {};
window.VideoState.id = {};
});

describe('constructor', function () {
Expand Down Expand Up @@ -80,7 +82,7 @@
'0.75': sub,
'1.0': sub,
'1.25': sub,
'1.5': sub
'1.50': sub
});
});

Expand All @@ -97,7 +99,7 @@
'0.75': sub,
'1.0': sub,
'1.25': sub,
'1.5': sub
'1.50': sub
});
});

Expand Down Expand Up @@ -227,10 +229,17 @@
expect(state.videoPlayer.skipOnEndedStartEndReset).toBe(true);
});

it('when position is not 0: cue is called with stored position value', function () {
state.config.savedVideoPosition = 15;

state.videoPlayer.updatePlayTime(10);
expect(state.videoPlayer.player.cueVideoById).toHaveBeenCalledWith('cogebirgzzM', 15);
});

it('Handling cue state', function () {
spyOn(state.videoPlayer, 'play');

state.videoPlayer.startTime = 10;
state.videoPlayer.seekToTimeOnCued = 10;
state.videoPlayer.onStateChange({data: 5});

expect(state.videoPlayer.player.seekTo).toHaveBeenCalledWith(10, true);
Expand Down Expand Up @@ -397,7 +406,7 @@
it('save setting for new speed', function () {

expect(state.storage.getItem('general_speed')).toBe('0.75');
expect(state.storage.getItem('video_speed_' + state.id)).toBe('0.75');
expect(state.storage.getItem('speed', true)).toBe('0.75');
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
});

afterEach(function () {
state = undefined;
state.storage.clear();
$.fn.scrollTo.reset();
$('.subtitles').remove();
$('source').remove();
Expand Down
Loading