Commit Graph

700 Commits

Author SHA1 Message Date
Irtaza Akram
ec2a698604 cleanup references of python 2 & <3.11 (#35799)
* chore: cleanup of old python references
2024-11-15 16:58:20 +05:00
Tim McCormack
22b9ced6c0 feat: Make celery task protocol configurable via Django setting (#35789)
This will allow us to test protocol 2 in a stage environment before
removing the override to make 2 the default.

We may have seen a bug where something in celery (or an
associated library) was adding headers to a v1 message as
if it were a v2 message, which caused a bug in ddtrace; such
things may become more likely over time as code is written
with the assumption of v2 messages. Moving to v2 will avoid
those issues.

See https://github.com/edx/edx-arch-experiments/issues/800 for further details.
2024-11-06 15:54:24 -05:00
David Ormsbee
d25e651145 Support static assets when copy/pasting between courses and libraries (#35668)
The biggest challenge is dealing with the mismatch between how Libraries store
assets (per-Component) and how Courses store assets (global Files and Uploads
space). To bridge this, we're going to kludge a component-local namespace in
Files and Uploads by making use of the obscure feature that you can create
folders there at an API level, even if no such UI exists.

In this commit:
* Assets work when copy-pasting between library components.
* Assets work when copy-pasting from a library to a course, with the convention
  being to put that file in a subdirectory of the form:
  components/{block_type}/{block_id}/file.
  Note that the Studio course Files page still just shows the filename.
* Assets work when copy-pasting from a course to a library.
  Top level assets are put into a static folder in the Component, per Learning
  Core conventions.

Limitations:
* Roundtrips don't work properly.
* There's no normalized form, so directories will start nesting if you copy
  from library and paste into course, then copy the pasted thing and paste back
  into library, etc. This was deemed acceptable for Sumac.

Low level stuff:
* XBlockSerializerForLearningCore has been removed, with the url_name stripping
  functionality added as an optional param to XBlockSerializer (the other stuff
  was for children and "vertical" -> "unit" conversion, neither of which are
  relevant now).
* url_name is now stripped out of anything added to the clipboard, so that we
  don't end up writing it in block.xml when it is redundant (and would be
  stripped out with the next write anyway).

For the Libraries Relaunch Beta. This should not affect any site which
has kept New Libraries disabled.

Issue: https://github.com/openedx/frontend-app-authoring/issues/1170
2024-10-23 09:21:27 -04:00
David Ormsbee
451012460d feat: versioned asset support for Learning Core XBlock runtime
Add support for displaying static assets in the Learing Core XBlock
runtime via "/static/asset-name" style substitutions in the OLX. This is
currently used for new Content Library components.

Static asset display is version-aware, so viewing older versions of the
XBlock content via the embed view will show the appropriate assets for
that version.
2024-10-17 13:57:09 -04:00
Kyle McCormick
2bbd8ecd18 feat!: Remove outdated Libraries Relaunch cruft (#35644)
The V2 libraries project had a few past iterations which were never
launched. This commit cleans up pieces from those which we don't need
for the real Libraries Relaunch MVP in Sumac:

* Remove ENABLE_LIBRARY_AUTHORING_MICROFRONTEND,
  LIBRARY_AUTHORING_FRONTEND_URL, and
  REDIRECT_TO_LIBRARY_AUTHORING_MICROFRONTEND, all of which are obsolete
  now that library authoring has been merged into
  https://github.com/openedx/frontend-app-authoring.
  More details on the new Content Libraries configuration settings are
  here: https://github.com/openedx/frontend-app-authoring/issues/1334

* Remove dangling support for syncing V2 (learning core-backed) library
  content using the LibraryContentBlock. This code was all based on an
  older understanding of V2 Content Libraries, where the libraries were
  smaller and versioned as a whole rather then versioned by-item.
  Reference to V2 libraries will be done on a per-block basis using
  the upstream/downstream system, described here:
  https://github.com/openedx/edx-platform/blob/master/docs/decisions/0020-upstream-downstream.rst
  It's important that we remove this support now so that OLX course
  authors don't stuble upon it and use it, which would be buggy and
  complicate future migrations.

* Remove the "mode" parameter from LibraryContentBlock. The only
  supported mode was and is "random". We will not be adding any further
  modes. Going forward for V2, we will have an ItemBank block for
  randomizing items (regardless of source), which can be synthesized
  with upstream referenced as described above. Existing
  LibraryContentBlocks will be migrated.

* Finally, some renamings:

  * LibraryContentBlock -> LegacyLibraryContentBlock
  * LibraryToolsService -> LegacyLibraryToolsService
  * LibrarySummary -> LegacyLibrarySummary

  Module names and the old OLX tag (library_content) are unchanged.

Closes: https://github.com/openedx/frontend-app-authoring/issues/1115
2024-10-15 11:32:01 -04:00
Kyle McCormick
f65403975a fix: don't wrap HTML data with newlines when serializing for LC (#35532)
When serializing to OLX, the Learning Core runtime wraps HTML content in
CDATA to avoid having to escape every individual `<`, `>`, and `&`. The
runtime also puts newlines around the content within the CDATA,
So, given HTML content `...`, we get `<![CDATA[\n...\n]]>`.

The problem is that every time you serialize an HTML block to OLX, it
adds another pair of newlines. These newlines aren't visible to the end
users, but they do make it so that importing and exporting content never
reached a stable, aka "canonical" form. It also makes unit testing
difficult, because the value of `html_block.data` becomes a moving
target.

We do not believe these newlines are necessary, so we have removed them
from the `CDATA` block, and added a unit test to ensure that HTML blocks
having a canonical serialization.

Closes: https://github.com/openedx/edx-platform/issues/35525
2024-09-25 14:32:25 +00:00
Emad Rad
c27d55a253 chore: typos fixed 2024-05-25 18:05:28 +03:30
Maria Grimaldi
9431e96d3c fix: add in-line docs correct namespace for content_groups_for_teams (#34783) 2024-05-20 14:50:17 -04:00
Yusuf Musleh
e8d07cf747 test: Update tagged openassessment test 2024-05-14 10:37:38 +03:00
Kyle McCormick
15caa9746f refactor: Completely remove Blockstore (#34739)
Blockstore and all of its (experimental) functionality has been replaced with
openedx-learning, aka "Learning Core". This commit uninstalls the now-unused
openedx-blockstore package and removes all dangling references to it.

Note: This also removes the `copy_library_from_v1_to_v2` management command,
which has been broken ever since we switched from Blockstore to Learning Core.

Part of this DEPR: https://github.com/openedx/public-engineering/issues/238
2024-05-13 09:48:18 -04:00
connorhaugh
674c3edaab Revert "Revert "Revert "temp: trace celery tasks in dd"" (#34563)" (#34578)
This reverts commit ebe36a2957.
2024-04-29 13:09:43 -04:00
Maria Grimaldi
809ffc3743 feat: connect teams with content groups using dynamic partition generator (#33788)
Implements the connection from the teams feature to the content groups feature. This implementation uses the dynamic partition generator extension point to associate content groups with the users that belong to a Team.

This implementation was heavily inspired by the enrollment tracks dynamic partitions.
2024-04-25 13:02:49 -04:00
Diana Huang
ebe36a2957 Revert "Revert "temp: trace celery tasks in dd"" (#34563)
* Revert "Revert "temp: trace celery tasks in dd (#34537)" (#34553)"

This reverts commit a7b441690d.

* docs: Update removal date on temporary celery flag.
2024-04-22 11:05:50 -04:00
connorhaugh
a7b441690d Revert "temp: trace celery tasks in dd (#34537)" (#34553)
This reverts commit f866545bb9.
2024-04-19 12:50:33 -07:00
Feanil Patel
6ea63da969 fix: Don't use the deprecated location for Hashable
The Hashable object was moved in python 3.3 and support for the old
location is dropped in python 3.10 the new location is available in
python 3.8 so we can just update this and it should work with both
python 3.8 and 3.11

https://docs.python.org/3.8/library/collections.html
2024-04-18 13:28:30 -04:00
Feanil Patel
b20ac9c515 fix: Be able to clear the process_cache manually in Python 3.11
Given code like the following

```
class Foo:
    @process_cached
    def bar(self):
        pass
```

In Python 3.8 referencing `bar` would not call its `__get__` method.

```
x = Foo().bar
```

However in Python 3.11, making the same call would call the `__get__`
method, permanently replacing the underlying `process_cached` object
with the partial function that references it.

This meant that code to clear the cache would work in Python 3.8 but
would break in 3.11

```
Foo().bar.cache.clear()  # Works in 3.8 but not in 3.11
```

In 3.11 this results in the following error:
```
E       AttributeError: 'functools.partial' object has no attribute 'cache'
```

To make this compatible in both version, we just add the cache as an
accessible attribute on the partial we generate for our wrapped
function.
2024-04-18 13:28:30 -04:00
connorhaugh
f866545bb9 temp: trace celery tasks in dd (#34537) 2024-04-18 13:08:25 -04:00
Jillian
7ad225658f feat: don't use OLX for tags when copying/duplicating blocks (#34386) 2024-04-02 09:59:57 -07:00
Rômulo Penido
cb6801dbfd feat: paste tags when pasting xblocks with tag data (#34270) 2024-03-08 12:03:43 -08:00
Kshitij Sobti
c3c0adf978 feat: add support for zip files to course and library import code (#34191)
Co-authored-by: Rodrigo Ferreira de Souza <rodfersou@gmail.com>
2024-03-08 18:51:35 +01:00
David Ormsbee
86f1e5e8aa feat!: Switch v2 libraries to Learning Core data models (#34066)
This moves the Content Libraries V2 backend from Blockstore [1] over to
Learning Core [2] For high-level overview and rationale of this move, see
the Blockstore DEPR [3]. There are several follow-up tasks [4], most notably
adding support for static assets in libraries.

BREAKING CHANGE: Existing V2 libraries, backed by Blockstore, will stop
working. They will continue to be listed in Studio, but their content
will be unavailable. They need to be deleted (via Django admin) or manually
migrated to Learning Core. We do not expect production sites to be in
this situation, as the feature has never left "experimental" status.

[1] https://github.com/openedx-unsupported/blockstore
[2] https://github.com/openedx/openedx-learning/
[3] https://github.com/openedx/public-engineering/issues/238
[4] https://github.com/openedx/edx-platform/issues/34283
2024-02-22 16:38:05 +00:00
Yusuf Musleh
6e0bc66a77 feat: Serialize tag data in OLX for blocks (#34145) 2024-02-14 10:30:23 -08:00
Cristhian Garcia
5a36fa9163 feat: add open_managed team type (#33672)
Ref: https://openedx.atlassian.net/wiki/spaces/COMM/pages/3885760525/Open+Managed+Group+Type
2024-02-14 11:30:19 -04:00
Priyanshu
81611a7a8e fix: change deprecated defusedxml.lxml to defusedxml.common (#34177) 2024-02-08 08:41:42 +10:30
Deborah Kaplan
bde84117c3 feat: linting error
* unused import
* format

FIXES: APER-3146
2024-01-30 16:36:14 +00:00
Deborah Kaplan
ae3ce9c498 feat: fix exception handling in program cert revocation
To determine whether or not we need to  revoke any program certificates, we first run get_revokable_program_uuids. This calls get_certified_programs, which calls get_credentials, which uses the OpenEdx Core  utility method get_api_data. get_api_data makes the API call inside a try block, does raise_for_status  also inside the try block, and then catches the exception, logs it, and returns an empty result to the caller.

This means that on a failure to call the credentials API, get_credentials can’t  tell the difference between a failure to hit the API (because credentials is, as it sometimes is during a notify_programs run, overloaded), or a learner with no program certificates. In this particular case, this is absolute failure, incorrect behavior.

* Adds a new flag, `raise_on_error`  which will make `get_api_data` log the exception and then re-raise the HTTPError,  defaulting to false in order to avoid changing the behavior on any other callers
* Also: my editor reformatted all of the touched files to our modern code standards, and it seemed appropriate to let it do that.
* Also: added type hints in some cases, because they helped me write the code and debug. Our test suite definitely  reports mypy  results on type errors so we are verifying that hints are correct.

FIXES: APER-3146
2024-01-26 22:20:30 +00:00
Kyle McCormick
27803f51c8 feat!: assume & remove BLOCKSTORE_USE_BLOCKSTORE_APP_API (#33765)
Originally, Blockstore was an independent micro-service, accessed via a REST API.
Then, we changed Blockstore so it could be installed as an in-process Django app.

To support both modes, there existed a blockstore_api wrapper library in edx-platform,
with toggles controlling whether the wrapper called out to the micro-service's REST API versus the
Django app's Python API. Now that the micro-service Blockstore implementation is deprecated,
though, this wrapper library and toggles are just unnecessary complexity.

As a first step towards cleanup, we:

* remove several toggles and settings (details below);
* remove the blocokstore_api wrapper methods which called the REST API and
  marshalled them back into Python objects; and
* remove all test cases which relied on the Blockstore micro-service (and were skippped in CI).

In the future, we will remove the content libraries indexer, 
clean up the remaining bits of blockstore_api, and flatten out all
the Blockstore-related test class hierarchies which are no longer nceessary.

BREAKING CHANGE:
* These Django settings are removed:
  * BLOCKSTORE_PUBLIC_URL_ROOT
  * BLOCKSTORE_API_URL
  * BLOCKSTORE_API_AUTH_TOKEN
  * BLOCKSTORE_USE_BLOCKSTORE_APP_API
* The blockstore.use_blockstore_app_api Waffle switch is removed.
* edx-platform will act as it did when the DJango setting BLOCKSTORE_USE_BLOCKSTORE_APP_API
  or the Waffle switch blockstore.use_blockstore_app_api were enabled. That is, any running Blockstore
  micro-service instance will be ignored, and the Blockstore package which is installed into edx-platform
  will be used instead.

Ref: https://github.com/openedx/blockstore/issues/296
2023-12-06 15:15:18 +00:00
Tim McCormack
94441861e0 feat!: Remove legacy-ip code and Waffle switch (#33735)
This switch has been kept disabled in edx.org for well over a year with no
trouble, and the migration to `CLOSEST_CLIENT_IP_FROM_HEADERS`
was introduced in Nutmeg.

DEPR issue: https://github.com/openedx/edx-platform/issues/33733
2023-12-01 14:44:59 +00:00
Kyle McCormick
e800ae7622 feat: provisionally support V2 libraries in LibraryContentBlock (randomized only) (#33263)
Refactors and reworks the LibraryContentBlock so that its
sync-from-library operations are asynchronous and work with
V2 content libraries. This also required us to make
library_content block duplication asynchronous, as that
involves syncing from the source library.

For the sake of clarity, this PR includes two major method renames:

* update_children(...) -> sync_from_library(...)
* refresh_library(...) -> sync_from_library(upgrade_to_latest=True, ...)

an an XBlock HTTP handler rename:

  /refresh_children -> /upgrade_and_sync

There are still a couple issues with import or duplication
of library_content blocks referencing V2 libraries other than
latest. These will be resolved in an upcoming PR.

Part of: https://openedx.atlassian.net/wiki/spaces/COMM/pages/3820617729/Spec+Memo+Content+Library+Authoring+Experience+V2
Follow-up work: https://github.com/openedx/edx-platform/issues/33640

Co-authored-by: Connor Haugh <chaugh@2u.com>
Co-authored-by: Eugene Dyudyunov <evgen.dyudyunov@raccoongang.com>
2023-11-20 15:58:10 +00:00
Phillip Shiu
94658f5890 feat: add ip_chain.safest_client_ip to emitted XForwardedForMiddleware metrics (#33720)
This commit adds the result of get_safest_client_ip() to the emitted metrics of
XForwardedForMiddleware.
2023-11-15 22:13:32 +00:00
Piotr Surowiec
2cf4d73a98 Merge pull request #33601 from DanielVZ96/dvz/clean-warnings
chore: clean and fix console warnings
2023-11-06 16:50:37 +01:00
Rebecca Graber
ddabba458b feat: remove manual sends of events (#33642) 2023-11-03 10:36:50 -04:00
Feanil Patel
ac2cc158f8 test: Update tests to the new return code.
When including `JwtAuthentication`, the auth_header becomes `JWT
realm="api"`. Without it, it is `None`. This changes the behavior of the
code in DRF and returns a slightly different auth response.

Relevant Code: 56946fac8f/rest_framework/views.py (L456C3-L456C3)
2023-11-01 11:03:03 -04:00
Daniel Valenzuela
398c84e1bc chore: ignore 'etree' is deprecated
Related issue: https://github.com/openedx/edx-platform/issues/32888
2023-11-01 00:18:40 -03:00
Daniel Valenzuela
9752da2b03 chore: ignore warning from pkg_resources.declare_namespace
Related issue: https://github.com/openedx/edx-platform/issues/33592
2023-11-01 00:18:40 -03:00
Daniel Valenzuela
ef0a9c00af chore: ignore import ABCs from 'collections' warning
related issue: https://github.com/openedx/edx-platform/issues/33584

note: this warning is from a third party library (libsass)
2023-11-01 00:18:40 -03:00
Daniel Valenzuela
d2f427a672 chore: ignore HTTPResponse.getheaders() deprecation warning
related issue: https://github.com/openedx/edx-platform/issues/33584

note: this warning is rased from a third party library (elasticsearch)
2023-11-01 00:18:40 -03:00
Daniel Valenzuela
66c5be8c02 chore: ignore default_app_config warning
related issue: https://github.com/openedx/edx-platform/issues/33572
2023-11-01 00:18:40 -03:00
Rebecca Graber
80a25bc368 feat: use new event_bus_producer_config (#33458) 2023-10-16 14:07:10 -04:00
Yagnesh Nayi
d9af2dfb36 feat!: DEPR expected error part of EXPECTED_ERRORS (#33184)
Removes expected part of EXPECTED_ERRORS with a variety of changes.
- In many placed in the code, "expected" was used to mean
  "ignored and expected", and all such instances are renamed to "ignored".
- The setting ``EXPECTED_ERRORS`` is renamed to ``IGNORED_ERRORS``,
  which better matches how it was being used in the first place.
- The setting ``EXPECTED_ERRORS[REASON_EXPECTED]`` is renamed to ``IGNORED_ERRORS[REASON_IGNORED]``.
- The setting toggle ``EXPECTED_ERRORS[IS_IGNORED]`` is removed,
  because it will now always be True.
- The how-to will is renamed to how_tos/logging-and-monitoring-ignored-errors.rst.

See 0002-logging-and-monitoring-expected-errors-removed.rst for more details.

Implements DEPR: https://github.com/openedx/edx-platform/issues/32405

**BREAKING CHANGE:** The rename of the setting ``EXPECTED_ERRORS`` to
  ``IGNORED_ERRORS``, and ``REASON_EXPECTED`` to ``REASON_IGNORED``,
  was implemented without backward compatibility. Simply copy the old settings
  with the new name as an expand phase before deleting the old names in the 
  contract phase.
2023-10-04 10:03:41 -04:00
Yusuf Musleh
0d15ca7240 fix: Escape CDATA special char on xblock serialize (#33239)
This fixes a bug in xblock serialization when trying to copy a
unit/component that contains an HTML xblock with the characters "]]>"
which is a special character in CDATA.
2023-09-15 08:58:23 -07:00
Kyle McCormick
265701c01d feat!: remove library_sourced block (#33257)
Originally, we planned to add support for V2 libraries and for static
(hand-selected) library block reference via new block type: library_sourced.

We have since decided that it would be better to add those capabilities
in-place to the existing library_content block. This will ease V1->V2
library migration and make adoption of the new features easier for current
library users. It will also avoid duplication of logic between two block types,
we we fear would be error-prone. For details, see this ADR:
 https://github.com/openedx/edx-platform/pull/33231

So, we are removing the library_sourced block.
This block has existed in edx-platform for a few years now, but was not
enabled by default and never officially supported. It was only usable via the
experimental V2 content library feature. Operators who added library_sourced
blocks to their course will now see them render as `HiddenBlock` instances, i.e.:

> ERROR: "library_sourced" is an unknown component type...

This should not impact other component types in such courses and should not
impact import/export.
2023-09-15 10:04:38 -04:00
Yusuf Musleh
ee1b6b8a6d fix: Copy/Paste unit with python_lib.zip (#33164)
This fixes the issue when pasting a copied unit that contains
python_lib.zip file into another course. The python_lib.zip file was not
being correctly copied over to the new course's Files & Uploads page.
2023-09-13 12:22:55 -07:00
Usama Sadiq
7710e60328 fix: fix middleware get_response parameter deprecation warning (#33067) 2023-08-22 15:52:30 +05:00
Usama Sadiq
852246db8c fix: replace ugettext with gettext (#33022) 2023-08-16 17:07:23 +05:00
Muhammad Soban Javed
2732934e74 fix: re-enable Django deprecation warnings (#32277)
* fix: re-enable Django deprecation warnings
---------

Co-authored-by: UsamaSadiq <usama7274@gmail.com>
2023-08-07 22:08:00 +05:00
Yusuf Musleh
b97007e182 feat: Handle JSInput extra files when copying/pasting (#32847)
This takes into account the extra files that are usually required when
copying problems containing JSInputs. Static files such as additional
CSS and JS files needed to interact and style the problem.
2023-07-31 11:12:10 -07:00
Diego Velasquez
547e5b1f7b chore: remove warnings from defusedxml package (#32652)
Co-authored-by: Diego Velásquez <diego@emptor.io>
2023-07-26 12:20:56 -04:00
Ken Clary
d6f824db40 feat: basic get/post endpoint for v2 xblocks. TNL-10873 2023-07-20 16:03:32 -04:00
Braden MacDonald
162175f0c4 chore: get rid of edx_six - not needed anymore (#32555)
* chore: get rid of edx_six - not needed anymore
* chore: remove reference to TODO that was completed.
2023-07-10 11:16:57 -07:00