Commit Graph

7928 Commits

Author SHA1 Message Date
DawoudSheraz
63d1b2bc9c modify URL generation in tinymce editor 2020-01-24 11:57:01 +05:00
David Ormsbee
0800f5f226 Merge pull request #22837 from open-craft/youtube-metadata-new-runtime
Add way to get YouTube metadata that doesn't require a session cookie
2020-01-17 11:02:05 -05:00
Braden MacDonald
c7d5efb796 Add way to get YouTube metadata that doesn't require a session cookie
The Video Player XBlock will sometimes make API calls to /couses/yt_video_metadata, a REST API endpoint that in turn loads video metadata from YouTube using the configured settings.YOUTUBE_API_KEY.

However, in the Blockstore-based XBlock runtime, we are running XBlocks in a secure sandbox, and the user's browser cannot pass session cookies when calling REST API endpoints. So currently, the video XBlock tries to request YouTube metadata from that API endpoint, but it fails if run within such a sandbox.

The existing API also doesn't work for anonymous users (users who are allowed to see video XBlocks but who have not logged in to an LMS user account).

This commit updates the Video XBlock so that it can use a handler to load the data from YouTube instead of a generic REST API. This works well in the new runtime, because it has code to support calling handlers within the sandbox, including by anonymous users.

I also fixed a bug where on a default devstack, the endpoint will try calling YouTube using PUT_YOUR_API_KEY_HERE as an API key, and get a "bad request" error from YouTube.

The code could be re-organized by moving things around, but I've left everything as-is for now to keep the diff as small as possible.
2020-01-16 13:25:16 -08:00
David Ormsbee
b3e2a8ef55 Merge pull request #22858 from open-craft/video-field-parsing-fix
Fix: KeyError: 'source' when parsing HTML5 videos
2020-01-15 14:32:44 -05:00
Braden MacDonald
d39421d947 Fix: KeyError: 'source' when parsing HTML5 videos
This fixes a bug that causes the video XBlock parsing to break in the new XBlock runtime if:
* the html5_sources field is set, and
* the download_video field is not set

The error is:

  File "/edx/app/edxapp/edx-platform/openedx/core/djangoapps/xblock/rest_api/views.py", line 52, in render_block_view
    block = load_block(usage_key, request.user)
  File "/edx/app/edxapp/edx-platform/openedx/core/djangoapps/xblock/api.py", line 84, in load_block
    return runtime.get_block(usage_key)
  File "/edx/app/edxapp/edx-platform/openedx/core/djangoapps/xblock/runtime/blockstore_runtime.py", line 70, in get_block
    block = block_class.parse_xml_new_runtime(xml_node, runtime=self, keys=keys)
  File "/edx/app/edxapp/edx-platform/common/lib/xmodule/xmodule/video_module/video_module.py", line 620, in parse_xml_new_runtime
    setattr(video_block, key, cls.fields[key].from_json(val))
  KeyError: 'source'

The reason for the error is that parse_video_xml() will sometimes return a 'source' attribute in its field_data return value, even though source is not a video field (anymore). This then causes an error when trying to look up cls.fields['source']

A workaround in the meantime is to add download_video="false" to the OLX.
2020-01-15 10:26:55 -08:00
Dave St.Germain
20235bcf56 Added subsection id to gated metadata. 2020-01-14 10:01:07 -05:00
Dave St.Germain
507b85ee3d Return sequence metadata from an ajax handler endpoint, to support the new courseware micro-frontend. 2020-01-13 11:26:02 -05:00
Christian Clauss
69f286c90c from xmodule.modulestore.exceptions import MultipleLibraryBlocksFound
Undefined name: __MultipleLibraryBlocksFound__ is raised on line 1096 but is never defined or imported.
2020-01-02 23:49:32 +01:00
David Ormsbee
2cb2265ffe Add request caching to reduce ORM queries
This adds request caching to the following places:
* course expiration wrapper (displayed in Units)
* offer banner generation (displayed in Units)
* get_enrollment
* user_by_anonymous_id
* youtube_disabled_for_course

On a sample course with edx-val enabled, this reduced the queries
for a large sequence from 450 to 155.
2019-12-30 16:19:25 -05:00
Feanil Patel
046feb0cf0 Merge pull request #22649 from edx/feanil/fix_pep8
Fix all E303 pep8 errors.
2019-12-30 13:32:26 -05:00
Feanil Patel
6e3fe00fff Fix all E303 pep8 errors. 2019-12-30 12:25:38 -05:00
Feanil Patel
2df8b8226b Merge pull request #22643 from edx/feanil/2to3_asserts
Run `2to3 -f asserts . -w` on edx-platform.
2019-12-30 12:13:42 -05:00
Feanil Patel
9cf2f9f298 Run 2to3 -f future . -w
This will remove imports from __future__ that are no longer needed.

https://docs.python.org/3.5/library/2to3.html#2to3fixer-future
2019-12-30 10:35:30 -05:00
Feanil Patel
70294b0ad2 Run 2to3 -f asserts . -w on edx-platform.
https://docs.python.org/3.5/library/2to3.html#2to3fixer-asserts
2019-12-30 10:22:19 -05:00
Jeremy Bowman
63574e12b8 Remove pytest version constraint (#22626)
Fix the issue that was preventing us from upgrading pytest.  pytest does some manipulation of test packages that prevents `pkg_resources` from loading resources from them, but used to contain a workaround for the problem.  That workaround was [removed](https://github.com/pytest-dev/pytest/issues/5392) in 4.6.0 as a performance enhancement when pytest switched from `pkg_resources` to `importlib-metadata` for its own entrypoint handling.  This tripped up one of our test modules which defined classes that loaded templates from inside a test package.  Moving these resources to the parent package fixes the problem.

More and more, `pkg_resources` is being abandoned in favor of `importlib-metadata` and `importlib_resources` as they have a simpler design with much better performance.  However, `importlib_resources` doesn't support loading files from any directory which isn't itself a Python package (and doesn't allow direct use of paths including directories within the package).  Jinja2 chose a [different approach](https://github.com/pallets/jinja/pull/1082) that we may want to emulate in our resource handling.

Also fixed usage of a removed `pytest.raises()` parameter and a bug in our configuration of the `common/lib` tests that became a problem after the upgrade.
2019-12-30 09:10:57 -05:00
Feanil Patel
f359c9cd8f Merge pull request #21197 from open-craft/giovanni/upgrade-pymongo
BB-1744: Bump pymongo version and fix course export issue
2019-12-26 11:16:15 -05:00
Andytr1
b1b5403041 Merge pull request #22559 from edx/andytr1/studio_teamsconfiguration_svc
EDUCATOR-4846 - added team config service for xblocks.
2019-12-20 10:46:04 -05:00
atesker
e0d57fe1a7 EDUCATOR-4846 - added team config service for xblocks.
Quality / encoding

Remove comments

remove debug

Changed service implementation to make unit testing easier

Corrected service

code style

unit test cleanup

Clean up imports
2019-12-20 09:57:30 -05:00
Braden MacDonald
f31dc19887 Support anonymous users in the Blockstore-based XBlock runtime
Implementation details:
* Anonymous users are assigned a unique ID (like 
  `anon42c08f9996194e2a9339`) which gets stored in the django session.
  `block.scope_ids.user_id` and `block.runtime.anonymous_student_id`
  will both return this value.
* User state for anonymous users is stored in the django cache and
  automatically expires as the cache gets pruned. Because user state is
  stored, anonymous users can use interactive blocks like capa problems.
* There is no mechanism for upgrading to a registered account and
  keeping user state since the user state store for anonymous users
  (EphemeralKeyValueStore) is completely different than the one for
  registered users (DjangoKeyValueStore/"CSM"), and has no "list all
  keys" functionality.
* "User State Summary" field values are shared among [recently active]
  anonymous users but are not shared with registered users.
* Anonymous users can only access the `public_view` of XBlocks, not the
  regular `student_view`.
2019-12-19 16:12:24 -08:00
David Ormsbee
a09c4e160b Merge pull request #22538 from open-craft/blockstore-video-transcripts
Support transcript files for video XBlocks in Blockstore
2019-12-19 11:24:27 -05:00
pkulkark
a1bb42b385 Enable auto start for HLS if autoadvance is set 2019-12-16 11:54:57 +05:30
Braden MacDonald
e4eac68e9f Support transcript files for video XBlocks in Blockstore 2019-12-15 12:35:03 -08:00
Diana Huang
217228dffc Standardize input into SubRipFile. 2019-12-13 13:28:27 -05:00
Jeremy Bowman
ca1265a679 Make XModuleDescriptor hashable again (#22501) 2019-12-11 14:37:07 -05:00
Jeremy Bowman
86186e2026 Fix graph traversal under Python 3 (#22484) 2019-12-10 15:52:26 -05:00
Jeremy Bowman
0e1881f525 Fixes for celery worker Python 3 bugs (#22479) 2019-12-10 14:07:27 -05:00
Giovanni Cimolin da Silva
a78c21db10 Fix course export issue 2019-12-10 09:39:27 -03:00
Giovanni Cimolin da Silva
ba4de2f933 Upgrade pymongo and fix issues
This commit upgrades the version of pymongo from 2.x to 3.x, removing usages to deprecated functions usage and fixing tests where necessary.

This version of pymongo supports MongoDB 2.x all the way up to 4.2, and this ensures that the platform will be able to run on a supported MongoDB version in the next release.
2019-12-09 15:43:56 -03:00
Feanil Patel
01b6b19f2e Merge pull request #22454 from edx/feanil/handle_pickling_failure
Feanil/handle pickling failure
2019-12-09 11:44:14 -05:00
Feanil Patel
bf482f4989 Respond to code review. 2019-12-06 15:02:22 -05:00
DawoudSheraz
99d694c86c log exception for further context 2019-12-06 15:06:19 +05:00
Feanil Patel
684f254a77 Add error handling in course structure cache.
When going between python 2 and python 3.5 we can get pickeld course
structires that are incompatible no matter what we do do to the bug
linked in the comment.  In this case, handle the error and delete the
corrupt data from the cache.

Making this fairly generic because if we have any bad data in cache we
don't want it to blow up the whole process.  Just delete the bad data
and try again.
2019-12-05 17:06:12 -05:00
saadyousafarbi
a59363432c handle section link bug for staff-only units for learners. 2019-11-27 15:52:39 +05:00
DawoudSheraz
e306bc74c0 avoid pretty printing of pre tags in course import 2019-11-12 13:57:25 +05:00
Dave St.Germain
0e4c04ed2e Merge pull request #21961 from edx/dcs/jumpnav
Improve navigation on Studio unit page
2019-11-08 10:32:43 -05:00
Feanil Patel
1a3f21080e The type of the attrib object wasn't actually a dict.
It was an internal class that we can't easily compare to. So I'm opting
to just make the xml output be more consistent and ordered.  I was
hoping to avoid this since the order shouldn't matter but the juggling
we have to do to validate the unorderd data is more complication than
it's worth.
2019-11-07 10:33:36 -05:00
Dave St.Germain
3e73ba3879 TNL-6929:
Improves navigation within Studio for Learning Sequences, speeding up authors who want to see how a learner progresses through content without needing to jump over to the LMS.

This adds a dropdown section navigator to the breadcrumbs on the unit page and copies the sequence navigator from LMS to the studio unit page.
2019-11-07 09:13:00 -05:00
Kyle McCormick
4f3262a40b Remove most references to old teams config scheme (#22238)
This is a follow up from MST-16, which was commited
in 3858036a4e.

Changes:
* Enrich course teams_configuration from a plain Dict
  to a custom XBlock field that uses the new TeamsConfig
  wrapper class.
* Remove teams_conf property from course, as the previous
  change made it redundant.
* Update teams_enabled implementation.
* Remove teams_max_size field from course, which is
  no longer semantically correct, as max team size
  is now defined on a teamset level.
* Remove teams_topics in order to discourage use of raw
  teams config dict.
* Add convenience properties teamsets and teamsets_by_id
  to course.
* Allow periods and spaces in teamset IDs to avoid breaking
  existing course teams.

Some parts of the code still use the old raw config data
(identifiable by searching "cleaned_data_old_format"),
which we expect to be slowly factored away as we build
new teams features. MST-40 has been created to remove any
remaining references if necessary.

MST-18

* fix: bokchoy test

* fix: remove pdb break
2019-11-06 20:43:32 -05:00
Feanil Patel
0078a6c1ca Parse transcripts json to compare logically.
This is to deal with a special issue in the video descriptor xml output.
The value of the transcript attribute of the video tag is a serialized
json string.  This can have comparison problems in python3 where the order
of the dictionary output is not gauranteed to be the same. So the strings
don't match equally.  We convert the parsed json instead so that the
comparison can be correct.
2019-11-06 11:37:06 -05:00
Manjinder Singh
cb186d94d3 Fixing test by using six.assertCountEqual (#22219)
* using six.assertCountEqual

* Fix type mismatches in css migrations
2019-11-04 09:29:32 -05:00
Awais Qureshi
076a2b5a7e BOM-998
Fixing decoding issue.
Fixing flaky unit test.
2019-11-01 15:54:23 +05:00
Awais Jibran
d891ae5522 Merge pull request #22192 from edx/aj/improve-logging-capa
Add error in logging
2019-11-01 11:25:28 +05:00
Feanil Patel
9f9d904592 Update code to use the new rounding method.
See the commit that added round_away_from_zero for details.

IN the case of dashboard_data.py:

We don't first cast to decimal here because in python 2 this didn't do
anything.  The python 2 rounding method would just cast things to float
before doing the rounding anyway so it just wastes cpu cycles.  In
python 3 this causes some typing issues so just removing it.
2019-10-31 14:29:57 -04:00
Awais Jibran
cb2a24711e Add error in logging 2019-10-31 09:48:58 +05:00
Awais Jibran
38f296fa93 Merge pull request #22182 from edx/aj/improve-logging-capa
Improve logging when a CAPA problem fails to display HTML
2019-10-30 14:54:26 +05:00
Awais Jibran
c0a26e932d Improve logging when a CAPA problem fails to display HTML 2019-10-30 14:23:50 +05:00
Awais Jibran
3ee5969f73 fixed language issue and added test #2 2019-10-30 14:02:50 +05:00
Awais Jibran
a27bd563b4 Merge pull request #22102 from edx/as/bug/tinymce-add-image
JavaScript Error when inserting second image in Studio
2019-10-30 12:59:56 +05:00
Awais Jibran
222c74e855 JavaScript Error when inserting second image in Studio 2019-10-30 12:21:40 +05:00
Kyle McCormick
3858036a4e Expand and refactor teams configuration on course. (#22168)
Wrap CourseModule.teams_configuration in TeamsConfig
class, centralizing parsing, validation, error handling,
etc. Wrapped object is exposed on 'teams_conf' field.

Old code still uses 'teams_configuration' dict;
we should change this in the future (MST-18).

MST-16
2019-10-29 16:10:19 -04:00