From 6794b73d99ea57f003d086ff87e26a585db5e2e5 Mon Sep 17 00:00:00 2001 From: Valera Rozuvan Date: Thu, 21 Mar 2013 16:28:39 +0200 Subject: [PATCH 1/8] Added videoalpha version 1 to the advanced components in studio. --- .../xmodule/xmodule/templates/videoalpha/default.yaml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/common/lib/xmodule/xmodule/templates/videoalpha/default.yaml b/common/lib/xmodule/xmodule/templates/videoalpha/default.yaml index 69ed22cc1e..6fe7b2b0e1 100644 --- a/common/lib/xmodule/xmodule/templates/videoalpha/default.yaml +++ b/common/lib/xmodule/xmodule/templates/videoalpha/default.yaml @@ -1,7 +1,13 @@ --- metadata: - display_name: default + display_name: Video Alpha 1 data_dir: a_made_up_name + is_graded: False + version: 1 data: | - + + + + + children: [] From 53f80d39915168a44c229735843a41c2ec9787a6 Mon Sep 17 00:00:00 2001 From: Lyla Fischer Date: Mon, 29 Apr 2013 12:08:31 -0400 Subject: [PATCH 2/8] standard video introduction --- .../lib/xmodule/xmodule/templates/videoalpha/default.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/common/lib/xmodule/xmodule/templates/videoalpha/default.yaml b/common/lib/xmodule/xmodule/templates/videoalpha/default.yaml index 6fe7b2b0e1..a0d215c64f 100644 --- a/common/lib/xmodule/xmodule/templates/videoalpha/default.yaml +++ b/common/lib/xmodule/xmodule/templates/videoalpha/default.yaml @@ -5,9 +5,9 @@ metadata: is_graded: False version: 1 data: | - - - - + + + + children: [] From c238f76fe856df23226c875a3cbfab80b0b3144b Mon Sep 17 00:00:00 2001 From: Lyla Fischer Date: Mon, 29 Apr 2013 13:01:38 -0400 Subject: [PATCH 3/8] different default section --- common/lib/xmodule/xmodule/templates/videoalpha/default.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/lib/xmodule/xmodule/templates/videoalpha/default.yaml b/common/lib/xmodule/xmodule/templates/videoalpha/default.yaml index a0d215c64f..a87a2a571c 100644 --- a/common/lib/xmodule/xmodule/templates/videoalpha/default.yaml +++ b/common/lib/xmodule/xmodule/templates/videoalpha/default.yaml @@ -5,7 +5,7 @@ metadata: is_graded: False version: 1 data: | - + From d68162f9fae3fd6b136bea6f23dd5d0e8c2e96b8 Mon Sep 17 00:00:00 2001 From: Lyla Fischer Date: Thu, 9 May 2013 09:08:22 -0400 Subject: [PATCH 4/8] removed from and to labels --- common/lib/xmodule/xmodule/templates/videoalpha/default.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/lib/xmodule/xmodule/templates/videoalpha/default.yaml b/common/lib/xmodule/xmodule/templates/videoalpha/default.yaml index a87a2a571c..d655c26d37 100644 --- a/common/lib/xmodule/xmodule/templates/videoalpha/default.yaml +++ b/common/lib/xmodule/xmodule/templates/videoalpha/default.yaml @@ -5,7 +5,7 @@ metadata: is_graded: False version: 1 data: | - + From 56f60e06e4aed12d6ce48713dfaa296d3833a888 Mon Sep 17 00:00:00 2001 From: Lyla Fischer Date: Mon, 13 May 2013 08:14:54 -0400 Subject: [PATCH 5/8] changed 'from' and 'to' to 'start_time' and 'end_time' --- common/lib/xmodule/xmodule/videoalpha_module.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/lib/xmodule/xmodule/videoalpha_module.py b/common/lib/xmodule/xmodule/videoalpha_module.py index 6754f8f664..83d0b4badd 100644 --- a/common/lib/xmodule/xmodule/videoalpha_module.py +++ b/common/lib/xmodule/xmodule/videoalpha_module.py @@ -93,7 +93,7 @@ class VideoAlphaModule(VideoAlphaFields, XModule): return result def _get_timeframe(self, xmltree): - """ Converts 'from' and 'to' parameters in video tag to seconds. + """ Converts 'start_time' and 'end_time' parameters in video tag to seconds. If there are no parameters, returns empty string. """ def parse_time(s): @@ -107,7 +107,7 @@ class VideoAlphaModule(VideoAlphaFields, XModule): minutes=x.tm_min, seconds=x.tm_sec).total_seconds() - return parse_time(xmltree.get('from')), parse_time(xmltree.get('to')) + return parse_time(xmltree.get('start_time')), parse_time(xmltree.get('end_time')) def handle_ajax(self, dispatch, get): """Handle ajax calls to this video. From aaeb3a862dca331f9a5d9169802f3c151232f989 Mon Sep 17 00:00:00 2001 From: Valera Rozuvan Date: Fri, 17 May 2013 12:48:34 +0300 Subject: [PATCH 6/8] Added Python tests for start_time and end_time parameters. --- .../lib/xmodule/xmodule/tests/test_logic.py | 34 ++++++++++++++++++- .../lib/xmodule/xmodule/videoalpha_module.py | 8 +++-- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/common/lib/xmodule/xmodule/tests/test_logic.py b/common/lib/xmodule/xmodule/tests/test_logic.py index 6cd46a26ee..e60af63921 100644 --- a/common/lib/xmodule/xmodule/tests/test_logic.py +++ b/common/lib/xmodule/xmodule/tests/test_logic.py @@ -4,10 +4,12 @@ import json import unittest +from lxml import etree + from xmodule.poll_module import PollDescriptor from xmodule.conditional_module import ConditionalDescriptor from xmodule.word_cloud_module import WordCloudDescriptor - +from xmodule.videoalpha_module import VideoAlphaDescriptor class PostData: """Class which emulate postdata.""" @@ -117,3 +119,33 @@ class WordCloudModuleTest(LogicTest): ) self.assertEqual(100.0, sum(i['percent'] for i in response['top_words']) ) + + +class VideoAlphaModuleTest(LogicTest): + descriptor_class = VideoAlphaDescriptor + + raw_model_data = { + 'data': '' + } + + def test_get_timeframe_no_parameters(self): + xmltree = etree.fromstring('test') + output = self.xmodule._get_timeframe(xmltree) + self.assertEqual(output, ('', '')) + + def test_get_timeframe_with_one_parameter(self): + xmltree = etree.fromstring( + 'test' + ) + output = self.xmodule._get_timeframe(xmltree) + self.assertEqual(output, (247, '')) + + def test_get_timeframe_with_two_parameters(self): + xmltree = etree.fromstring( + '''test''' + ) + output = self.xmodule._get_timeframe(xmltree) + self.assertEqual(output, (247, 47079)) diff --git a/common/lib/xmodule/xmodule/videoalpha_module.py b/common/lib/xmodule/xmodule/videoalpha_module.py index 83d0b4badd..16230480a7 100644 --- a/common/lib/xmodule/xmodule/videoalpha_module.py +++ b/common/lib/xmodule/xmodule/videoalpha_module.py @@ -103,9 +103,11 @@ class VideoAlphaModule(VideoAlphaFields, XModule): return '' else: x = time.strptime(s, '%H:%M:%S') - return datetime.timedelta(hours=x.tm_hour, - minutes=x.tm_min, - seconds=x.tm_sec).total_seconds() + return datetime.timedelta( + hours=x.tm_hour, + minutes=x.tm_min, + seconds=x.tm_sec + ).total_seconds() return parse_time(xmltree.get('start_time')), parse_time(xmltree.get('end_time')) From 1e8c4e9edfd74dc292d1cf1e58b0f22fd6a10a73 Mon Sep 17 00:00:00 2001 From: Valera Rozuvan Date: Thu, 23 May 2013 11:59:12 +0300 Subject: [PATCH 7/8] Rebase + updated videoalpha template. Now no data_dir attribute and is_graded set to false. --- common/lib/xmodule/xmodule/templates/videoalpha/default.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/common/lib/xmodule/xmodule/templates/videoalpha/default.yaml b/common/lib/xmodule/xmodule/templates/videoalpha/default.yaml index d655c26d37..5ff3a8f004 100644 --- a/common/lib/xmodule/xmodule/templates/videoalpha/default.yaml +++ b/common/lib/xmodule/xmodule/templates/videoalpha/default.yaml @@ -1,7 +1,6 @@ --- metadata: display_name: Video Alpha 1 - data_dir: a_made_up_name is_graded: False version: 1 data: | From 587ac0ecf0d44046aa0cd0e913a50b516c67bda7 Mon Sep 17 00:00:00 2001 From: Valera Rozuvan Date: Thu, 23 May 2013 13:24:06 +0300 Subject: [PATCH 8/8] Removed is_graded attribute. In HTML yaml it is not used, and that is not graded. --- common/lib/xmodule/xmodule/templates/videoalpha/default.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/common/lib/xmodule/xmodule/templates/videoalpha/default.yaml b/common/lib/xmodule/xmodule/templates/videoalpha/default.yaml index 5ff3a8f004..dba8bbd0b4 100644 --- a/common/lib/xmodule/xmodule/templates/videoalpha/default.yaml +++ b/common/lib/xmodule/xmodule/templates/videoalpha/default.yaml @@ -1,7 +1,6 @@ --- metadata: display_name: Video Alpha 1 - is_graded: False version: 1 data: |