Commit Graph

466 Commits

Author SHA1 Message Date
Taylor Payne
16d96565e3 refactor: move production defaults to common modules (#37045)
In the effort to simplify settings in edx-platform, as discussed in ADR 22 -
Settings Simplification, this PR brings some of the production defaults defined
in `lms/envs/production.py` and `cms/envs/production.py` up to
`openedx/envs/common.py` or `lms/envs/common.py` and `cms/envs/common.py` as
appropriate.

Bringing these defaults up from the `production.py` settings modules caused
changes in the rendered settings of the `test.py` modules, and so I have
settings to the `test.py` modules to bring the rendered settings back in line
with what is has been. I have not deeply looked at which settings are needed
for tests to pass or not, but just the differences between the rendered
settings between `master` and this branch.

ADR 22: https://github.com/openedx/edx-platform/blob/master/docs/decisions/0022-settings-simplification.rst
Fixes https://github.com/openedx/edx-platform/issues/36892.
2025-08-04 17:06:16 -04:00
Muhammad Qasim Gulzar
9bf923784f fix: Improve error for missing (Translate)CustomTagBlock template #35829 (#37013)
Fixes: https://github.com/openedx/edx-platform/issues/35829
2025-07-23 10:00:30 -04:00
Ram Chandra Bhavirisetty
c9912b2661 feat: remove mongodb_proxy in favor of MongoDB's built-in retryReads (#37011)
This PR removes the usage of the custom `mongodb_proxy` package from
edx-platform, replacing it with MongoDB's built-in retry functionality via
`retryReads=True`.

Changes:

* Removed all references to `mongodb_proxy.MongoProxy` from connection logic.
* Updated `connect_to_mongodb()` to always use `retryReads=True`.
* Uninstalled `openedx-mongodbproxy` from edx-platform requirements.

Fixes: https://github.com/openedx/edx-platform/issues/35210
2025-07-21 13:52:55 -04:00
Daniel Wong
89ae9e9571 fix: use import_string instead of get_storage_class to import the view class 2025-07-04 16:10:42 -06:00
Farhaan Bukhsh
2fe8b7a0c5 fix: Fixes auto_advance feature for video XBlock (#35200)
Signed-off-by: Farhaan Bukhsh <farhaan@opencraft.com>
2025-06-24 03:26:00 -07:00
Muhammad Faraz Maqsood
b2c9dddb84 feat: get language from request user's preferences and sort according to it 2025-06-19 14:43:31 +05:00
Muhammad Faraz Maqsood
f86ea5cb07 fix: bson size error due to mongo aggregate func
fix below bson_obj document size error due to mongo aggregate function by calculating the count and using find instead of aggregate.
```
raise OperationFailure(errmsg, code, response, max_wire_version)
pymongo.errors.OperationFailure: BSONObj size: 19117457 (0x123B591) is invalid. Size must be between 0 and 16793600(16MB) First element: _id: null, full error: {'ok': 0.0, 'errmsg': 'BSONObj size: 19117457 (0x123B591) is invalid. Size must be between 0 and 16793600(16MB) First element: _id: null', 'code': 10334, 'codeName': 'BSONObjectTooLarge', '$clusterTime': {'clusterTime': Timestamp(1750073176, 2), 'signature': {'hash': b'\xd7\xdd\xf4\x7f\xe4\xcea\xa1\xa7P\xba\xab\xcb\x12\x7f1A$(\xb4', 'keyId': 7471973240714297345}}, 'operationTime': Timestamp(1750073176, 2)}
```
2025-06-19 14:43:31 +05:00
Tim McCormack
447fd0b6cb feat: Upgrade to codejail 4.0.0 (#36916)
This brings an important security improvement -- codejail won't default to
running in unsafe mode, which can happen if certain configuration errors
are present.

Properly configured installations shouldn't be affected. We just need to
adjust some unit tests to opt into unsafe mode.

Changes:

- Update `edx-codejail` dependency to [version 4.0.0](https://github.com/openedx/codejail/blob/master/CHANGELOG.rst#400---2025-06-13)
- Define a `use_unsafe_codejail` decorator that allows running a unit test (or entire TestCase class) in unsafe mode
- Use that decorator as needed, based on which tests started failing
2025-06-17 09:33:52 -04:00
KEVYN SUAREZ
db8766d4aa fix: Include metadata for blocked sequence units to enable proper navigation (#36485)
The original issue was that when a sequence was locked due to prerequisites, the API returned an empty items array ([]). This prevented the frontend from knowing what units were inside the locked sequence, meaning it couldn't construct the URLs correctly for navigation so the next/previous buttons stop working.
2025-06-10 20:06:46 +02:00
Tony Busa
d30490e420 fix: Problem Bank view link incorrectly replacing embedded iframe (#36781) 2025-05-22 14:30:43 -07:00
Jansen Kantor
5b440b4b13 fix: video caption issue (#36768) 2025-05-21 17:11:27 -04:00
Tim McCormack
6740e75c0f Merge commit from fork
Allow overriding but prevent download by default.

Also, extract `PYTHON_LIB_FILENAME` Django setting as a shared function
and document the setting.
2025-05-21 14:14:51 -04:00
Jorg Are
10c74e1082 feat: update captions content (#36732) 2025-05-21 08:45:10 -04:00
Jansen Kantor
2eeccc7d25 feat: only show google attribution for google-translated transcripts (#36619)
* feat: only show google attribution for google-translated transcripts

* fixup! feat: only show google attribution for google-translated transcripts
2025-05-20 10:33:08 -04:00
Feanil Patel
ecdf774e75 Merge pull request #36699 from dwong2708/fix-depr-warnings
fix: use geom_type instead of type for Shapely objects
2025-05-19 12:55:56 -04:00
Daniel Wong
a51f87be43 test: removing unused tests related to masking 2025-05-14 09:42:43 -06:00
Daniel Wong
204a1eb438 test: test_capa_system helper function replaced by mock_capa_system 2025-05-13 14:45:57 -06:00
Daniel Wong
77eb6e8254 fix: use geom_type instead of type for Shapely objects 2025-05-13 14:45:57 -06:00
Tim McCormack
4c462918e8 fix: Pass limit overrides context to codejail execution in all places (#36685)
Some of the calls to `safe_exec` were missing the `limit_overrides_context`
parameter. This normally conveys the course key to codejail so that we can
give some courses different resource limits, but it's also valuable for
diagnosing codejail issues in logs and other telemetry.

I wasn't able to test all of these paths manually, but the utility function
`get_course_id_from_capa_block` will swallow errors, so the situation
should be no worse if the `LoncapaResponse.capa_block` field has something
unexpected.
2025-05-08 16:55:57 -04:00
Tim McCormack
d5a273ce2f feat!: Expand codejail darklaunch normalizers; append by default (#36682)
For darklaunch comparisons where the two sides have different Python
versions, we'll want a more comprehensive list of normalizers.

- Expand the default list to include patterns discovered during a Python
  3.8 vs. 3.12 comparison.
- Append the setting value by default, rather than replacing (but still
  allow replacing).
- Use default normalizers if custom ones can't be loaded.
- Add log message when loading normalizers fails.
- Validate the replacement pattern, not just the search pattern.
2025-05-08 13:43:53 -04:00
Tim McCormack
5bc05810dc feat: Improve codejail darklaunch logging (#36671)
This is intended to make logs more or less a standalone source for
analyzing mismatches.

- Only log mismatches or exceptions
- Merge local and remote log messages into one so they can be correlated
  more easily
- Different log messages for mismatch vs. unexpected exceptions
- Include course ID (as limit overrides context) in log message
2025-05-06 16:42:55 -04:00
Tim McCormack
9ff24774e1 test: Allow locale path test to pass when repo dir name different (#36648)
This test assumes edx-platform is checked out in a directory of that name.
2025-05-01 14:04:41 -04:00
Tim McCormack
c9ae3adc24 fix: Use correct default for unsafely param (#36638)
`unsafely` should be a boolean, not None. I believe this is what was
causing a 400 in remote codejail-service calls (during darklaunch) when
the `calculate_problem_responses_csv.v2` instructor task ran:
https://github.com/edx/edx-arch-experiments/issues/1028

There are also places in the code where this member appears to be a scalar
property instead of a method, or possibly that's just buggy code that
doesn't run. I decided not to touch that in this PR (we're probably going
to DEPR the entire unsafe mechanism anyhow) but if this PR doesn't work,
that's the next place to look -- because higher up in this file there's
a `can_execute_unsafe_code=None` that we could try changing.
2025-04-30 16:23:13 -04:00
Tim McCormack
ca335b3c3a feat: Fix character range for codejail darklaunch tmpdir normalization (#36615)
Python's tempfile naming also includes underscore:
https://github.com/python/cpython/blob/3.12/Lib/tempfile.py#L140

This omission would cause normalization to fail about 1/6 of the time.

Also expand test to exercise more of character range.
2025-04-28 12:35:41 -04:00
Navin Karkera
1cd73d1b96 feat: support for syncing units from libraries to courses (#36553)
* feat: library unit sync
* feat: create component link only for component xblocks
* feat: container link model
* feat: update downstream api views
* feat: delete extra components in container on sync (not working)
* fix: duplicate definitions of LibraryXBlockMetadata
* test: add a new integration test suite for syncing
* feat: partially implement container+child syncing
* fix: blockserializer wasn't always serializing all HTML block fields
* feat: handle reorder, addition and deletion of components in sync

Updates children components of unit in course based on upstream unit,
deletes removed component, adds new ones and updates order as per
upstream.

* feat: return unit upstreamInfo and disallow edits to units in courses that are sourced from a library (#773)
* feat: Add upstream_info to unit
* feat: disallow edits to units in courses that are sourced from a library (#774)

---------

Co-authored-by: Jillian Vogel <jill@opencraft.com>
Co-authored-by: Rômulo Penido <romulo.penido@gmail.com>

* docs: capitalization of XBlock

Co-authored-by: David Ormsbee <dave@axim.org>

* refactor: (minor) change python property name to reflect type better

* fix: lots of "Tried to inspect a missing...upstream link" warnings

when viewing a unit in Studio

* docs: mention potential REST API for future refactor

* fix: check if upstream actually exists before making unit read-only

* chore: fix camel-case var

* fix: test failure when mocked XBlock doesn't have UpstreamSyncMixin

---------

Co-authored-by: Braden MacDonald <braden@opencraft.com>
Co-authored-by: Chris Chávez <xnpiochv@gmail.com>
Co-authored-by: Jillian Vogel <jill@opencraft.com>
Co-authored-by: Rômulo Penido <romulo.penido@gmail.com>
Co-authored-by: Braden MacDonald <mail@bradenm.com>
Co-authored-by: David Ormsbee <dave@axim.org>
2025-04-24 11:41:47 -07:00
Asad Ali
797438e91b fix: save video asides during XML course import 2025-04-22 23:59:55 +05:00
Tim McCormack
3a9b4367e6 fix: Call json_safe on globals in codejail remote_exec (#36542)
We need to make globals JSON-friendly before sending them across the
network.

Addresses https://github.com/edx/edx-arch-experiments/issues/1016
2025-04-18 11:22:43 -04:00
Tim McCormack
a960cdff8d fix: Add much more codejail darklaunch info; fix remote error bug (#36534)
- Fix bug where we were overwriting `remote_emsg` with None, and add test
  that would have caught it.
- Suppress differences due solely to the codejail sandbox directory name
  differing (in stack traces), and add test for this. Configurable because
  we'll need to add an additional search/replace pair for the sandbox venv
  paths.
- Add a variety of custom attributes, replacing existing ones. The attrs
  now have a prefixed naming scheme to simplify searching.
- Add slug to log output so we can more readily correlate traces and logs,
  as well as logs across services.
- Fix typo in error message.
- Fix existing import sort order lint.
2025-04-17 15:39:47 -04:00
Tim McCormack
bf2f8c3705 fix: Don't let local codejail exec pollute darklaunched remote globals
We were running local exec before making the copy of globals_dict for
remote_exec, so remote exec has been getting a polluted version of the
globals.
2025-04-15 15:50:12 -04:00
Tim McCormack
fd66048a49 test: Improve codejail darklaunch tests
- Separate test for misconfiguration
- Add helper method for generic dark launch testing
- Test two darklaunch scenarios: Globals interference, and error that would
  previously have caused the remote side not to run
- Rename mocks to have our usual `mock_` prefix
2025-04-15 15:50:12 -04:00
Tim McCormack
3f2271ab69 feat: Catch all exceptions from codejail dark launch
- Catch all exceptions, not just Exception, to better prevent errors from
  interfering with mainline responses.
- Introduce a separate try block around the monitoring code so that bugs
  there don't cause issues.
- Print exception information as well for both sides (but only if not a
  SafeExecException, which is redundant with emsg).

Some formatting changes to log messages as well.

Example outputs:

For `1/0`:

```
2025-04-14 17:26:34,239 INFO 10232 [xmodule.capa.safe_exec.safe_exec] [user 3] [ip 172.18.0.1] safe_exec.py:240 - Remote execution in darklaunch mode produces globals={'expect': None, 'ans': '1/0'}, emsg=None, exception=None
2025-04-14 17:26:34,239 INFO 10232 [xmodule.capa.safe_exec.safe_exec] [user 3] [ip 172.18.0.1] safe_exec.py:245 - Local execution in darklaunch mode produces globals={'expect': None, 'ans': '1/0'}, emsg='ZeroDivisionError: division by zero', exception=None
```

For `raise BaseException("hi")`:

```
2025-04-14 17:26:13,359 INFO 10232 [xmodule.capa.safe_exec.safe_exec] [user 3] [ip 172.18.0.1] safe_exec.py:240 - Remote execution in darklaunch mode produces globals={'expect': None, 'ans': 'raise BaseException("hi")'}, emsg=None, exception=None
2025-04-14 17:26:13,359 INFO 10232 [xmodule.capa.safe_exec.safe_exec] [user 3] [ip 172.18.0.1] safe_exec.py:245 - Local execution in darklaunch mode produces globals={'expect': None, 'ans': 'raise BaseException("hi")'}, emsg='hi', exception=BaseException('hi')
```

With codejail-service down, and `out = 1 + 2`:

```
2025-04-14 17:30:28,597 INFO 12484 [xmodule.capa.safe_exec.safe_exec] [user 3] [ip 172.18.0.1] safe_exec.py:241 - Remote execution in darklaunch mode produces globals={'expect': None, 'ans': 'out = 1 + 2', 'out': 3, 'cfn_return': {'input_list': [{'ok': True, 'msg': 'Output:\n3', 'grade_decimal': 1}]}}, emsg=None, exception=CodejailServiceUnavailable('Codejail API Service is unavailable. Please try again in a few minutes.')
2025-04-14 17:30:28,597 INFO 12484 [xmodule.capa.safe_exec.safe_exec] [user 3] [ip 172.18.0.1] safe_exec.py:246 - Local execution in darklaunch mode produces globals={'expect': None, 'ans': 'out = 1 + 2', 'out': 3, 'cfn_return': {'input_list': [{'ok': True, 'msg': 'Output:\n3', 'grade_decimal': 1}]}}, emsg=None, exception=None
```
2025-04-15 15:50:12 -04:00
Tim McCormack
45a96e2430 feat: Run remote codejail even if unexpected exception in local safe_exec
During dark launch of remote codejail, we want to ensure we always run both
local and remote execution -- otherwise we're missing data for the remote
side in an important situation.

This will help answer the question of whether the unexpected exception
happens on both sides, even though it may not look exactly the same due to
differences in how unexpected errors are handled.

An example input that provokes this in unsafe execution mode is
`raise BaseException("hi")`; in safe execution mode, printing to
`sys.__stdout__` should also produce an appropriate error.
2025-04-15 15:50:12 -04:00
gabrielC1409
db27ab6166 feat: Send xqueue submissions to edx-submission
fix: Restructuring to send course_id and score to edx submission

fix: Refactoring of sending information to sent_to_submission

fix: Elimination of unnecessary functions

fix: Added usage comment to ProblemBlock in XqueueInterface constructor

fix: update doc ADR

fix: setting for Quality Others test (ubuntu-24.04, 3.11, 20)

fix: Deprecation for django-trans-escape-filter-parse-error

test: Add @pytest.mark.django_db decorator to test functions

test: Fix for pylint being disabled

fix: updated changes for pylint disable

fix: update error from docs ADR-0005

update: xmodule/docs/decisions/0005-send-data-to-edx-submission.rst

Co-authored-by: Sarina Canelake <sarina@axim.org>

update: xmodule/docs/decisions/0005-send-data-to-edx-submission.rst

Co-authored-by: Sarina Canelake <sarina@axim.org>

fix: Adjusted correction

fix: update date for docs ADR

Revert "fix: update date for docs ADR"

This reverts commit 0b4229c51c4937f95cb407872645dd448df45418.

fix: replace call created_submission to create_external_grader_detail

fix: update test xqueue_submission

fix: add docstring in test_xqueue_submission

fix: update date doc ADR

fix: update version edx-submission 3.8.6

fix: add @pytest.mark.xfail

fix: add 20 chances in test_capa_block:

fix: increase retry attempts for seed generation in ProblemBlockTest

fix: change version to edx-submission lib

fix: new version edx-submission in testings

fix: replace parameter file to files

fix: update variable grader_file_name and points_possible

fix: Adjustment in the is_flag_active function to always take the last record edited in the waffle

fix: wrap large line of code

fix: update function is_flag_active

fix: code style adjustment

fix: changes for 60 retry

feat: use CourseWaffleFlag to determine xqueue callback path

fix: Code style adjustment

fix: remove deprecated xqueue callback route and simplify callback type logic

fix: Deleting a comment in the ADR document

fix: add log in self.block is None

fix: Code style adjustment in log
2025-04-15 11:59:32 -04:00
Muhammad Anas
2930214067 feat: add markdown editor waffle flag (#36512)
This PR adds contentstore.use_react_markdown_editor course waffle flag in cms.
This flag helps in enabling the markdown editor in the authoring mfe.

This PR also adds the markdown_edited field in the Problem Xblock to persist the
user's choice of switching to the markdown editor on the authoring MFE.

More details in the authoring MFE PR: openedx/frontend-app-authoring#1805
2025-04-15 11:28:19 -04:00
Irtaza Akram
de75c37047 fix: duplicate rendering of instructions in annotatable xblock (#36445)
In the Annotatable XBlock, the <instructions> element was appearing
twice in the student view:

* Once in "annotatable-instructions" (where it should be).
* Again in "annotatable-content" (where annotations and other content are rendered).

The _render_content method processed and rendered the entire XML
data, including <instructions>, without removing it. The
_extract_instructions method, which is responsible for removing
<instructions>, was not called in _render_content, leading to
duplication.

This fix will:

* Prevents duplicate instructions in the student view.
* Maintains the expected behavior of showing instructions only in
  "annotatable-instructions".
* No impact on existing annotation functionality.
2025-04-10 11:01:38 -04:00
sarina
1e3074a3f9 docs: Update edx.rtd.io links to docs.openedx.org 2025-04-02 12:10:56 -04:00
Tim McCormack
1303965a29 feat: Also set MPLCONFIGDIR to make matplotlib complain less (#36456)
Example output from running `import matplotlib; 1/0`, before and after the change:

```diff
--- tmp/before	2025-03-28 03:34:06.633689552 +0000
+++ tmp/after	2025-03-28 03:34:37.268688891 +0000
@@ -1,6 +1,5 @@
-Matplotlib created a temporary cache directory at /tmp/codejail-hveq16ah/tmp/matplotlib-tv0c_vzt because the default path (/home/sandbox/.config/matplotlib) is not a writable directory; it is highly recommended to set the MPLCONFIGDIR environment variable to a writable directory, in particular to speed up the import of Matplotlib and to better support multiprocessing.
 Traceback (most recent call last):
   File "jailed_code", line 19, in <module>
     exec(code, g_dict)
   File "<string>", line 1, in <module>
 ZeroDivisionError: division by zero
```
2025-03-28 07:31:50 -04:00
Jansen Kantor
5e61a1d959 feat: allow transcripts to work with more than two-letter language codes (#36419)
* feat: allow transcripts to work with more than two-letter language codes

* style: quality

* fixup! Merge branch 'master' into jkantor/video-transcript-codes

* fix: s/LANGUAGES_DICT/LANGUAGE_DICT/
2025-03-27 11:30:44 -04:00
Rodrigo Martin
bf53eaa9bb fix: video transcript links wrapping up (#36428) 2025-03-25 10:56:23 -03:00
Tim McCormack
2009e8972c feat: Set TMPDIR for codejail executions (#36412)
This makes it easier to run matplotlib in codejail, and should prevent a
number of other issues in the future with other packages that need to
create tempfiles.

No change is required for existing codejail installations, but after this
change operators may be able to tighten their apparmor configuration to
prevent write access to global temp or cache dirs.

Manual testing instructions: Create a codejail problem that runs
`import matplotlib` and confirm that it runs without error. (Unit tests
aren't feasible here because this requires a fully configured codejail in
order for the tmp subdirectory to exist.)

Also: Add comment for `OPENBLAS_NUM_THREADS` and numpy support.
2025-03-20 15:41:43 -04:00
Robert Raposa
399be67fc4 style: remove eslint with frontend code removal ADR
- Add ADR for frontend code removal
- Drop eslint, as explained in the ADR
2025-03-20 11:03:41 -04:00
Rodrigo Martin
8d00b093c3 fix: video transcript links wrapping up (#36392) 2025-03-19 14:39:03 -03:00
Muhammad Umar Khan
4195186b04 chore: skip data caching for blockstructure content more than or equal to 2MB (#36397)
Co-authored-by: M Umar Khan <umar.khan@A006-01609.local>
2025-03-18 14:05:10 +05:00
Hina Khadim
ee7fd497a7 fix: add target='_blank' for videos hosted outside edx (#36361) 2025-03-17 11:10:49 +05:00
Bryann Valderrama
f90e59e52a docs: add event_type inline code annotation for open edX events (#36355) 2025-03-14 09:55:50 +01:00
Muhammad Umar Khan
c443acddd8 chore: skip data caching for content more than or equal to 2MB (#36359)
Co-authored-by: M Umar Khan <umar.khan@A006-01609.local>
2025-03-12 17:46:31 +05:00
Diana Huang
8935af7ab4 feat: Add observability to codejail darklaunch.
Sets up tracing in code jail calls to track remote
and local execution, and adds custom attributes
to track error messages from the calls.

https://github.com/edx/edx-arch-experiments/issues/895
2025-03-07 11:19:40 -05:00
Navin Karkera
2613c8ef4e feat: preserve image alt text while converting html to text (#36333)
Replace image with its alt text while converting html to plain text for indexing.
2025-03-06 16:55:45 +00:00
Jillian
cc56e41d0c fix: allow LTI blocks to be loaded in a Library v2 context [FC-0076] (#36265)
Fixes errors thrown when previewing/editing (built-in) LTI blocks in a Libraries v2 context.

These fixes allow Library Authors to store LTI blocks in their content libraries.
2025-03-06 16:28:26 +00:00
Diana Huang
ef49090c31 feat: Add codejail darklaunch toggle.
This adds a toggle for running codejail in both remote
and local configurations for testing purposes.

https://github.com/edx/edx-arch-experiments/issues/895
2025-03-05 17:56:40 -05:00