Commit Graph

59 Commits

Author SHA1 Message Date
Jawayria
df06d1312d refactor: Removed unused imports
Removed unused imports from openedx/core/djangoapps/{content_libraries, coursegraph,courseware_api, crawlers, credentials, credit}
2021-04-06 17:07:13 +05:00
Raul Gallegos
0d691623af fix: setting correct i18n_service to blockstore runtime
xblock information was not being translated correctly when using the blockstore runtime. This makes the i18n_service block-specific so it can look for additional i18n files that can be installed with the XBlock
2021-03-31 14:19:01 -05:00
M. Zulqarnain
5d2b0e8346 refactor: pyupgrade in content_libraries and contentserver apps (#26892) 2021-03-17 17:28:23 +05:00
Aarif
ba16e05899 replaced unittest assertions pytest assertions (#26564) 2021-02-19 16:04:32 +05:00
Fox Piacenti
c840e6f9bb Update Library v2 Indexes to work with ElasticSearch 7. Repair blockstore integration tests. (#26230) 2021-02-08 11:55:47 -05:00
M. Zulqarnain
047a5f5f19 BOM-2319 : Pylint amnesty in openedx content apps (#26347)
* pylint amnesty in openedx content apps

Co-authored-by: Jawayria <jawayriahashmi@gmail.com>
2021-02-08 15:51:22 +05:00
Kyle McCormick
d3ef43047e Fix KeyError in v2 Libraries API (#25753) 2020-12-03 09:49:27 -05:00
Kyle McCormick
4dda73d797 [BD-14] Migrate all environments to use database-backed organizations (#25153)
* Install `organizations` app into LMS and Studio non-optionally.
* Add toggle `ORGANIZATIONS_AUTOCREATE` to Studio.
* Remove the `FEATURES["ORGANIZATIONS_APP"]` toggle.
* Use the new `organizations.api.ensure_organization` function to
  either validate or get-or-create organizations, depending
  on the value of `ORGANIZATIONS_AUTOCREATE`,
  when creating course runs and V2 content libraries.
  We'll soon use it for V1 content libraries as well.
* Remove the `util.organizations_helpers` wrapper layer
  that had to exist because `organizations` was an optional app.
* Add `.get_library_keys()` method to the Split modulestore.
* Add Studio management command for backfilling organizations tables
  (`backfill_orgs_and_org_courses`).

For full details, see
https://github.com/edx/edx-organizations/blob/master/docs/decisions/0001-phase-in-db-backed-organizations-to-all.rst

TNL-7646
2020-12-02 13:58:40 -05:00
0x29a
c83a505635 Replace 'multi_db = True' with 'databases = {alias for alias in connections}'
Check this ticket for details: https://code.djangoproject.com/ticket/29513
2020-11-19 14:06:51 +01:00
Kyle McCormick
151bd13666 Use full names for common.djangoapps imports; warn when using old style (#25477)
* Generate common/djangoapps import shims for LMS
* Generate common/djangoapps import shims for Studio
* Stop appending project root to sys.path
* Stop appending common/djangoapps to sys.path
* Import from common.djangoapps.course_action_state instead of course_action_state
* Import from common.djangoapps.course_modes instead of course_modes
* Import from common.djangoapps.database_fixups instead of database_fixups
* Import from common.djangoapps.edxmako instead of edxmako
* Import from common.djangoapps.entitlements instead of entitlements
* Import from common.djangoapps.pipline_mako instead of pipeline_mako
* Import from common.djangoapps.static_replace instead of static_replace
* Import from common.djangoapps.student instead of student
* Import from common.djangoapps.terrain instead of terrain
* Import from common.djangoapps.third_party_auth instead of third_party_auth
* Import from common.djangoapps.track instead of track
* Import from common.djangoapps.util instead of util
* Import from common.djangoapps.xblock_django instead of xblock_django
* Add empty common/djangoapps/__init__.py to fix pytest collection
* Fix pylint formatting violations
* Exclude import_shims/ directory tree from linting
2020-11-10 07:02:01 -05:00
Fox Piacenti
c181ed57b1 Add ability to filter library blocks by type. Prevent changing types with unpublished changes. (#25368)
Adds the ability to filter v2 library blocks by block type. Also prevents switching the library type when there are unpublished changes/deletes, as this may cause consistency errors.
2020-10-23 10:50:28 -04:00
Fox Piacenti
73adc729d9 Add a license field to libraries. (#25007) 2020-10-05 11:45:36 -04:00
Robert Raposa
f65bf0ed9d Merge pull request #24794 from regisb/regisb/settings-docs
[BD-21] Document settings with annotations
2020-10-01 11:53:39 -04:00
Usman Khalid
571b1f4d17 Enable the i18n service for the Blockstore service. 2020-09-28 09:34:36 -07:00
Fox Piacenti
2c15bbba2d Add type field/constraint to to libraries v2. (#24861) 2020-09-28 10:58:27 -04:00
Régis Behmo
e555d8a571 [BD-21] Document settings with annotations
We introduce the documentation of django settings via code annotations.
This will allow us to produce a human-readable documentatio of all Open
edX settings.
2020-09-28 12:44:36 +02:00
Fox Piacenti
7bc10e0464 Adjustments to library user access API endpoints required by frontend needs. (#24919) 2020-09-25 09:33:32 -04:00
Sid Verma
72b4afe465 Add ADR for content library indexes 2020-09-18 10:25:59 -04:00
Sid Verma
67f3c0343f Simplify and optimize index searching 2020-09-18 10:25:59 -04:00
Sid Verma
f2ed54d72c Add filtering support for list_library_blocks API 2020-09-18 10:25:59 -04:00
Sid Verma
3233fa92d4 Index xblocks in elasticsearch 2020-09-18 10:25:59 -04:00
Sid Verma
735bc412d4 Add elasticsearch tests 2020-09-18 10:25:59 -04:00
Sid Verma
78045115ab Add filtering and search support to library APIs 2020-09-18 10:25:59 -04:00
Braden MacDonald
1c60d5477b Merge PR #24803: [BD-14] BlockLimitReachedError should returns a 400 response instead of 500
https://github.com/edx/edx-platform/pull/24803
2020-08-31 10:39:20 -07:00
Sid Verma
1170a17b5f BlockLimitReachedError should returns a 400 response instead of 500 2020-08-29 01:08:38 +05:30
Sid Verma
4198eba6c1 Add schema version in library indexes, improve reindexing command 2020-08-24 10:45:01 -04:00
Sid Verma
b56f3d601a Add tests for the case when indexing is disabled 2020-08-24 10:45:01 -04:00
Sid Verma
7a3930efe7 Fail to limited metadata if elastic is not available 2020-08-24 10:45:01 -04:00
Sid Verma
1d2fbcc4cc Optimize and paginate list_libraries API, add num_blocks and last_published fields 2020-08-24 10:45:01 -04:00
Sid Verma
8d33a5a3e1 Add indexing support for blockstore content libraries 2020-08-24 10:45:01 -04:00
Manjinder Singh
c76ed6ae45 Extracting plugin app from edx-platform (#24678)
* Moving plugins infrastructure to edx-django-utils
This PR extracts the code that enables plugins in edx-platform and puts it in edx-django-utils. This is done to allow other IDAS to add plugin functionality.
2020-08-12 07:48:53 -04:00
Sid Verma
04bc696661 Fix wrong field name in ManyRelation 2020-07-14 06:03:44 +05:30
Sid Verma
c609451d2e [BD-14] Limit number of blocks allowed in content libraries (#24276)
* Enforce limit on number of blocks allowed in library (blockstore)

* Enforce limit on number of blocks allowed in library (modulestore)

* Changes from review feedback
2020-07-13 15:49:47 -04:00
Aarif
27480cdd2f Removed deprecated future imports 2020-06-23 18:51:43 +05:00
Diana Huang
92b10b564c Update to handle new format of ManyRelation. 2020-05-29 15:01:09 -04:00
Ned Batchelder
ae657f09e0 Merge pull request #23814 from open-craft/toxinu/fix-anonymous-permission
Check contentlibrary permissions only if user is logged in
2020-05-13 14:19:21 -04:00
David Ormsbee
431fdb9009 Merge pull request #23233 from open-craft/blockstore-library-links
REST API for managing Content Library bundle links
2020-04-30 11:32:48 -04:00
toxinu
a68b603638 Can only check user specific permissions if logged in 2020-04-27 17:21:13 +09:00
Samuel Walladge
9f6b3a873f Make more metadata available via the new runtime's generic XBlock API
Without this PR, there is no [reasonable] way to get the following data
for any XBlocks in the new runtime; now there is :)

* index_dictionary: data about the block content, for search indexing
* student_view_data: data-only equivalent of student_view, for use in
  custom UIs/mobile
* children: list of child IDs
* editable_children: list of child IDs in the same bundle (use case:
  when showing an OLX editor you want to allow editing the OLX of
  children in the same bundle but not linked children)
2020-04-17 13:09:59 -07:00
Braden MacDonald
81b9453462 API to get/update a content library's blockstore bundle links
This adds some simple new python+REST APIs that can be used to create,
read, update, and delete "links" from a content library to other content
libraries.

One can use these links to import content (XBlocks) into a library
without copying the content.

Note that this feature was already fully supported by Blockstore and the
XBlock runtime; it's just that to use it prior to this required one to
use the (lower-level) Blockstore REST API directly to create the links.
Now there is a somewhat higher-level API built in to Studio, using
"content library" abstractions instead of Blockstore primitives.
2020-04-17 13:07:12 -07:00
Braden MacDonald
af6cab86c3 Enforce permissions for content libraries, add REST API to edit perms 2020-03-02 18:17:46 -08:00
Braden MacDonald
ac39692a8a Fix: don't store .children usage keys in definition data cache
I needed this change because I found a bug:

1. Create a block with children in a content library
2. Delete that content library
3. Create a new identical block with children in a new content library.
4. If the OLX is identical to the original block, this new block will not load in the LMS.

The reason for the bug is that the .children field contains usage keys (which encode the library, for example), but the values were being stored in BlockstoreFieldData which caches really aggressively and caches based on the hash of the OLX. Since the OLX is identical, it assumes the .children values should be identical as well.

The fix was to move children to a children-specific field data store, and only store the part of the child data that is encoded by the OLX (the <xblock-include> data) in BlockstoreFieldData. This is a better match for the way the caching works and cleaned up a hacky part of the runtime (at least it's slightly less hacky now).
2020-01-08 15:28:36 -08:00
Feanil Patel
61e1eda20d Merge pull request #22644 from edx/feanil/2to3_imports
Run `2to3 -f future . -w`
2019-12-30 11:21:05 -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
Awais Qureshi
928a84f969 BOM-1117
Specifying a namespace in django.conf.urls.include() without providing an app_name is deprecated.
Adding the app_name attribute in the included module.
2019-12-30 18:08:21 +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
Braden MacDonald
e4eac68e9f Support transcript files for video XBlocks in Blockstore 2019-12-15 12:35:03 -08:00
Braden MacDonald
1ea3c032d3 Fixes for the blockstore API client / XBlock runtime under python 3 2019-12-05 09:24:24 -08:00
Braden MacDonald
7dafda6168 Support for storing an XBlock's static asset files in Blockstore
This PR introduces some backend python + REST APIs for storing static
asset files along with an XBlock in a content library. It also updates
the new runtime to be able to load such static asset files.

Example use cases:
* Store an image file with an HTML block and then use the image inline
  in the HTML block.
* Store a PDF file with an HTML block and provide a link in the HTML for
  the learner to download the PDF.
* Store .srt files or even video .mp4 files that belong to a video
  XBlock.

Within the bundle, these static asset files are stored in a "static/"
subfolder of the folder that contains the OLX file. Extending an
existing LMS/Studio convention, a static asset file such as "image.png"
is referenced within the OLX as "/static/image.png" and the URL will be
rewritten by the runtime.
2019-11-06 10:19:42 -08:00
Braden MacDonald
5fc73468b3 Change completion API to work with any learning context 2019-10-22 14:04:31 -04:00