Skip to content

Commit e4bfbb6

Browse files
committed
feat: Update the shifted Video XBlock code to make it run
1 parent adda59b commit e4bfbb6

24 files changed

Lines changed: 3878 additions & 506 deletions

‎.gitignore‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,7 @@ stats.json
120120
# Karma
121121
.karma/
122122
**/.karma/
123+
124+
# Bundled/generated JS (video XBlock)
125+
xblocks_contrib/video/public/js/video-xblock.js
126+
xblocks_contrib/video/public/js/video-xblock.js.map

‎requirements/base.in‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
-c constraints.txt
33

44
django-statici18n
5+
edx-django-utils
56
edx-i18n-tools
67
edx-opaque-keys
8+
edxval
79
nh3
810
oauthlib
911
openedx-django-pyfs
12+
wrapt
1013
XBlock

‎requirements/base.txt‎

Lines changed: 105 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,87 @@ botocore==1.42.49
1414
# via
1515
# boto3
1616
# s3transfer
17+
cachetools==7.0.0
18+
# via edxval
19+
certifi==2026.1.4
20+
# via requests
21+
cffi==2.0.0
22+
# via
23+
# cryptography
24+
# pynacl
25+
chardet==5.2.0
26+
# via pysrt
27+
charset-normalizer==3.4.4
28+
# via requests
29+
click==8.3.1
30+
# via
31+
# code-annotations
32+
# edx-django-utils
33+
code-annotations==2.3.0
34+
# via edx-toggles
35+
cryptography==46.0.4
36+
# via pyjwt
1737
django==5.2.11
1838
# via
1939
# -c https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt
2040
# django-appconf
41+
# django-crum
42+
# django-model-utils
2143
# django-statici18n
44+
# django-storages
45+
# django-waffle
46+
# djangorestframework
47+
# drf-jwt
48+
# edx-django-release-util
49+
# edx-django-utils
50+
# edx-drf-extensions
2251
# edx-i18n-tools
52+
# edx-toggles
53+
# edxval
2354
# openedx-django-pyfs
2455
django-appconf==1.2.0
2556
# via django-statici18n
57+
django-crum==0.7.9
58+
# via
59+
# edx-django-utils
60+
# edx-toggles
61+
django-model-utils==5.0.0
62+
# via edxval
2663
django-statici18n==2.6.0
2764
# via -r requirements/base.in
65+
django-storages==1.14.6
66+
# via edxval
67+
django-waffle==5.0.0
68+
# via
69+
# edx-django-utils
70+
# edx-drf-extensions
71+
# edx-toggles
72+
djangorestframework==3.16.1
73+
# via
74+
# drf-jwt
75+
# edx-drf-extensions
2876
dnspython==2.8.0
2977
# via pymongo
78+
drf-jwt==1.19.2
79+
# via edx-drf-extensions
80+
edx-django-release-util==1.5.0
81+
# via edxval
82+
edx-django-utils==8.0.1
83+
# via
84+
# -r requirements/base.in
85+
# edx-drf-extensions
86+
# edx-toggles
87+
edx-drf-extensions==10.6.0
88+
# via edxval
3089
edx-i18n-tools==1.9.0
3190
# via -r requirements/base.in
3291
edx-opaque-keys==3.0.0
92+
# via
93+
# -r requirements/base.in
94+
# edx-drf-extensions
95+
edx-toggles==5.4.1
96+
# via edxval
97+
edxval==3.2.0
3398
# via -r requirements/base.in
3499
fs==2.4.16
35100
# via
@@ -38,13 +103,18 @@ fs==2.4.16
38103
# xblock
39104
fs-s3fs==1.1.1
40105
# via openedx-django-pyfs
106+
idna==3.11
107+
# via requests
108+
jinja2==3.1.6
109+
# via code-annotations
41110
jmespath==1.1.0
42111
# via
43112
# boto3
44113
# botocore
45114
lxml[html-clean]==6.0.2
46115
# via
47116
# edx-i18n-tools
117+
# edxval
48118
# lxml-html-clean
49119
# xblock
50120
lxml-html-clean==0.4.3
@@ -53,6 +123,7 @@ mako==1.3.10
53123
# via xblock
54124
markupsafe==3.0.3
55125
# via
126+
# jinja2
56127
# mako
57128
# xblock
58129
nh3==0.3.3
@@ -63,41 +134,73 @@ openedx-django-pyfs==3.8.0
63134
# via -r requirements/base.in
64135
path==16.16.0
65136
# via edx-i18n-tools
137+
pillow==12.1.0
138+
# via edxval
66139
polib==1.2.0
67140
# via edx-i18n-tools
141+
psutil==7.2.2
142+
# via edx-django-utils
143+
pycparser==3.0
144+
# via cffi
145+
pyjwt[crypto]==2.11.0
146+
# via
147+
# drf-jwt
148+
# edx-drf-extensions
68149
pymongo==4.16.0
69150
# via edx-opaque-keys
151+
pynacl==1.6.2
152+
# via edx-django-utils
153+
pysrt==1.1.2
154+
# via edxval
70155
python-dateutil==2.9.0.post0
71156
# via
72157
# botocore
73158
# xblock
159+
python-slugify==8.0.4
160+
# via code-annotations
74161
pytz==2025.2
75162
# via xblock
76163
pyyaml==6.0.3
77164
# via
165+
# code-annotations
166+
# edx-django-release-util
78167
# edx-i18n-tools
79168
# xblock
169+
requests==2.32.5
170+
# via edx-drf-extensions
80171
s3transfer==0.16.0
81172
# via boto3
173+
semantic-version==2.10.0
174+
# via edx-drf-extensions
82175
simplejson==3.20.2
83176
# via xblock
84177
six==1.17.0
85178
# via
179+
# edx-django-release-util
86180
# fs
87181
# fs-s3fs
88182
# python-dateutil
89183
sqlparse==0.5.5
90184
# via django
91185
stevedore==5.6.0
92-
# via edx-opaque-keys
186+
# via
187+
# code-annotations
188+
# edx-django-utils
189+
# edx-opaque-keys
190+
text-unidecode==1.3
191+
# via python-slugify
93192
typing-extensions==4.15.0
94193
# via edx-opaque-keys
95194
urllib3==2.6.3
96-
# via botocore
195+
# via
196+
# botocore
197+
# requests
97198
web-fragments==3.1.0
98199
# via xblock
99200
webob==1.8.9
100201
# via xblock
202+
wrapt==2.1.1
203+
# via -r requirements/base.in
101204
xblock==5.3.0
102205
# via -r requirements/base.in
103206

‎xblocks_contrib/common/utils.py‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
"""
2+
Common utility functions for XBlocks.
3+
"""
4+
5+
from django.conf import settings
6+
7+
8+
9+
def get_resource_url(xblock, path, package_scope=None):
10+
"""
11+
Return the runtime URL for a static resource in this XBlock's package.
12+
13+
When the Django pipeline is enabled or REQUIRE_DEBUG is False, uses the
14+
pipeline path (e.g. {package_scope}/public/{path}). Otherwise uses the
15+
dev path (e.g. public/{path}). See platform's xblock_local_resource_url() in:
16+
openedx/core/lib/xblock_utils/__init__.py
17+
18+
Arguments:
19+
xblock: The XBlock instance (for runtime.local_resource_url).
20+
path (str): Relative path within the package, e.g. "css/video.css".
21+
package_scope (str): Package name prefix, e.g. "video". If None,
22+
both paths are "public/{path}"; otherwise pipeline adds the prefix.
23+
24+
Returns:
25+
str: URL from xblock.runtime.local_resource_url() for the resource.
26+
"""
27+
pipeline_path = dev_path = f"public/{path}"
28+
if package_scope:
29+
pipeline_path = f"{package_scope}/{pipeline_path}"
30+
pipeline = getattr(settings, 'PIPELINE', {})
31+
if pipeline.get('PIPELINE_ENABLED', True) or not getattr(settings, 'REQUIRE_DEBUG', False):
32+
resource_path = pipeline_path
33+
else:
34+
resource_path = dev_path
35+
return xblock.runtime.local_resource_url(xblock, resource_path)

‎xblocks_contrib/video/ajax_handler_mixin.py‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
1-
# NOTE: Code has been copied from the following source file
2-
# https://github.com/openedx/edx-platform/blob/master/xmodule/x_module.py#L739
1+
""" Mixin that provides AJAX handling for Video XBlock """
2+
from webob import Response
3+
from webob.multidict import MultiDict
4+
from xblock.core import XBlock
35

4-
class XModuleToXBlockMixin:
6+
7+
class AjaxHandlerMixin:
58
"""
6-
Common code needed by XModule and XBlocks converted from XModules.
9+
Mixin that provides AJAX handling for Video XBlock
710
"""
811
@property
912
def ajax_url(self):
1013
"""
1114
Returns the URL for the ajax handler.
1215
"""
13-
return self.runtime.handler_url(self, 'xmodule_handler', '', '').rstrip('/?')
16+
return self.runtime.handler_url(self, 'ajax_handler', '', '').rstrip('/?')
1417

1518
@XBlock.handler
16-
def xmodule_handler(self, request, suffix=None):
19+
def ajax_handler(self, request, suffix=None):
1720
"""
18-
XBlock handler that wraps `handle_ajax`
21+
XBlock handler that wraps `ajax_handler`
1922
"""
2023
class FileObjForWebobFiles:
2124
"""

‎xblocks_contrib/video/bumper_utils.py‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# NOTE: Code has been copied from the following source files
2-
# https://github.com/openedx/edx-platform/blob/master/xmodule/video_block/bumper_utils.py
31
"""
42
Utils for video bumper
53
"""

‎xblocks_contrib/video/cache_utils.py‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
1-
# NOTE: Code has been copied from the following source files
2-
# https://github.com/openedx/edx-platform/blob/master/openedx/core/lib/cache_utils.py
3-
"""
4-
Utilities related to caching.
5-
"""
6-
7-
1+
""" Cache Utils for Video Block """
82
import itertools
93

104
import wrapt
115
from django.utils.encoding import force_str
12-
136
from edx_django_utils.cache import RequestCache
147

158

‎xblocks_contrib/video/constants.py‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"""
2+
Constants used by DjangoXBlockUserService
3+
"""
4+
5+
# This is the view that will be rendered to display the XBlock in the LMS.
6+
# It will also be used to render the block in "preview" mode in Studio, unless
7+
# the XBlock also implements author_view.
8+
STUDENT_VIEW = 'student_view'
9+
10+
# This is the view that will be rendered to display the XBlock in the LMS for unenrolled learners.
11+
# Implementations of this view should assume that a user and user data are not available.
12+
PUBLIC_VIEW = 'public_view'
13+
14+
# The personally identifiable user ID.
15+
ATTR_KEY_USER_ID = 'edx-platform.user_id'
16+
# The country code determined from the user's request IP address.
17+
ATTR_KEY_REQUEST_COUNTRY_CODE = 'edx-platform.request_country_code'

‎xblocks_contrib/video/content.py‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
# NOTE: Original code has been copied from the following file:
2-
# https://github.com/openedx/edx-platform/blob/farhan/extract-video-xblock/xmodule/contentstore/content.py#L28
1+
""" Video Block Static Content, class copied from StaticContent class in edx-platform/xmodule/contentstore/content.py """
2+
from opaque_keys import InvalidKeyError
3+
from opaque_keys.edx.keys import AssetKey
4+
from opaque_keys.edx.locator import AssetLocator
35

4-
5-
class StaticContent: # lint-amnesty, pylint: disable=missing-class-docstring
6+
class VideoBlockStaticContent: # lint-amnesty, pylint: disable=missing-class-docstring
67
def __init__(self, loc, name, content_type, data, last_modified_at=None, thumbnail_location=None, import_path=None,
78
length=None, locked=False, content_digest=None):
89
self.location = loc

‎xblocks_contrib/video/mixin.py‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
# NOTE: Code has been copied from the following source files
2-
# https://github.com/openedx/edx-platform/blob/master/openedx/core/lib/license/mixin.py
31
"""
4-
License mixin for XBlocks and XModules
2+
License mixin for XBlocks
53
"""
64

75
from xblock.core import XBlockMixin

0 commit comments

Comments
 (0)