Commit Graph

4989 Commits

Author SHA1 Message Date
Awais Jibran
72ec00cbb7 fix: include pii sharing values in the API (#29385) 2021-11-24 17:44:28 +05:00
Kshitij Sobti
c8bd924e23 feat: Add support for using the discussions MFE UI instead of existing UI [BD-38] [TNL-9228] (#29285)
* feat: Add support for using the discussions MFE UI instead of existing UI

Adds a new course waffle flag that when set along with the discussions MFE URL shows the discussions MFE UI instead of the regular UI.

* test: add tests

* squash!: more consistent url name
2021-11-23 14:56:25 +05:00
Tim McCormack
4efd2d161a fix: Correctly create origin from URL in CORS CSRF middleware (#29366)
Deleting all instances of the path from the URL meant that referers like
`https://learning.edx.org/` were turned into `https:learning.edx.org`. The
solution here is to use `urlunparse` to put the URL back together, but only
with the desired components (scheme and authority/netloc).

This relates to our previous upgrade to django-cors-headers 3.x, which
changed to use origins instead of domains in its whitelist setting:

36df86d829 (diff-811d60a3e1d60ff694eace0242e77d6b810d8e9c63c36d7b3c2591a08ebbb94bR58)

Added regression test (fails on master, passes on branch.)

Also:

- Replace word "domain" with "origin" in few places to use the correct
  term. (We should probably change this more broadly in names and comments
  in this module as some point.)
- Simplify logging to just output what we know, and not try to recapitulate
  the logic too much.

ref: BOM-2961
2021-11-22 17:49:57 +00:00
uzairr
f02fe4c203 feat: allow login if email opt-in is enabled
allow login to in-active users if email opt-in is enabled

Fixes: VAN-768
2021-11-22 10:53:33 +05:00
Awais Jibran
5c2f8b23d4 fix: edx provider data in the api (#29331)
* fix: edx provider data in the api

* refactor: remove comments in the code

* test: update the test cases

* fix: quality changes
2021-11-19 18:58:28 +05:00
Adeel Ehsan
66654b2edb feat: don't allow account creation for secondary emails (#28880)
VAN-726
2021-11-19 17:06:24 +05:00
Justin Lapierre
f6f3a79a15 Revert "[BD-13] Deprecate ModuleSystem.render_template" 2021-11-16 15:16:08 -05:00
Kshitij Sobti
28a2af7a2a fix!: Removes the openedx provider temporarily [BD-38] [TNL-9269] (#29314)
* fix!: Removes the openedx provider temporarily

UI changes to support the new provider are in progress. Once they are ready we
can add back this provider.

* feat: add support for hiding providers from the API response
2021-11-15 21:06:16 +05:00
Matthew Piatetsky
22cb639919 feat: Update ace email header to match braze email header (#29310) 2021-11-15 10:44:41 -05:00
Tim McCormack
0bef57591d feat: Add feature toggle to allow broader safe-sessions user checking (#29306)
Contingent on new feature toggle `VERIFY_USER_CHANGE_UNCONDITIONAL`, check
for request/response user mismatches on all requests, not just those
setting a session cookie on the response.

This is intended to *restore* an older behavior. I believe that almost all
requests used to set a new session cookie, and for some reason no longer
do, so this is really just an attempt to return to that previous behavior
no matter whether a new session cookie will be set. (Previously, the
cookie-to-be-deleted check would still have been in effect, so this is
actually a slight change from the earlier behavior -- the logout response
will now be included, and then quickly ignored due to a later check.)

The off-by-default switch moves several lines of code out of a try block,
but also out from under an if guard that checks for certain cookie
conditions. The movement out of the try block should be irrelevant, since
neither of the relocated lines should be raising a SafeCookieError.
However, there is some chance that they could raise other exceptions when
called from their new location (and new situations), hence the use of a
feature toggle -- we'll want to make it easy to switch the new behavior off
quickly if we start seeing an increase in errors.

Once the change is well-exercised, we can remove the toggle and the old
call locations.

I'm not entirely sure about the change to the `verify_error` utility
function in the unit tests, but it seems like even unauthenticated requests
in Django end up with a user and session on the request object, so this is
probably a close-enough way to mock that out.

I duplicated a couple of tests to test with feature toggle on/off.

ref: ARCHBOM-1952
2021-11-15 15:28:59 +00:00
Waheed Ahmed
29608af616 fix: user info cookie (#29313)
This PR is an update on https://github.com/edx/edx-platform/pull/29280
2021-11-15 12:56:47 +05:00
Gábor Boros
230795fb07 feat: add optional-exposed extra field type to registration form
This defines optional extra fields that are not hidden under the toggle on the 
registration page.
2021-11-12 15:24:59 +01:00
Kshitij Sobti
285e2c4f29 feat: Adds a new discussion topic configuration mechanism [BD-38] [TNL-8623] [BB-4968] (#29082)
* feat: Adds a new discussion topic configuration mechanism

The new discussion configuration system links discussion topics directly to the course structure. This change adds a new task that sends a discussion update signal if there are any changes to the course. This signal includes all the context needed to update the configuration of the course.

The handler for this new event will create a new entry for each unit that needs a topic in the database. In the future this will be used to see the topics in the course.

* fix: add support for marking a provider as supporting LTI

* fix: review feedback
2021-11-12 19:08:43 +05:00
Waheed Ahmed
6ffdeab974 fix: remove hardcoded edx user info cookie name (#29280)
Removed hardcoded edx user info cookie name and used settings variable.
2021-11-12 11:33:00 +05:00
Matthew Piatetsky
5dbfae83fc fix: Miscellaneous styling fixes for mobile (#29294)
* fix: Miscellaneous styling fixes for mobile

* fix: Add px fallback since outlook doesn't support rem
2021-11-10 16:47:55 -05:00
Ned Batchelder
d9dd10dc97 style: code cleanups from Steven Burch (#29292)
* chore: update deprecated import from collections

* chore: remove outdated imports from markdown library

as it hasn't been supported since 2.0.3 and we're on 3.x.
This was deprecated at least as early as 2012!

* docs: add docstring and remove lint-amnesty to markdown plugin

* chore: remove deprecated etree import

* style: remove unnecessary-comprehension for sets

* style: resolve a number of amnestied pylint complaints

Co-authored-by: stvn <stvn@mit.edu>
2021-11-10 07:11:57 -08:00
Mehak Nasir
f0b9fde997 fix: ed-discussion configuration message added (#29295) 2021-11-10 19:35:26 +05:00
Matthew Piatetsky
4822faccc4 [AA-910] Miscellaneous UI fixes and fixed unsubscribe link (#29288)
* fix: use pngs for the goal reminder email banner and remove redundant unsubscribe link

* fix: update

* fix: Miscellaneous UI fixes and fixed unsubscribe link
2021-11-09 13:56:12 -05:00
David Ormsbee
2d60224125 Merge pull request #28571 from open-craft/jill/bd-13-render_template
feat!: [BD-13] Deprecate ModuleSystem.render_template
2021-11-09 12:20:59 -05:00
Matthew Piatetsky
3c0d824701 fix: use pngs for the goal reminder email banner and remove redundant unsubscribe link from the email (#29215)
* fix: use pngs for the goal reminder email banner and remove redundant unsubscribe link

* fix: update
2021-11-09 09:24:58 -05:00
Jillian Vogel
8d62d337f5 refactor: use MakoService.render_template to remove deprecation warnings
from block code.
2021-11-09 14:03:54 +10:30
Jillian Vogel
457f959356 refactor: deprecates ModuleSystem.render_template
in favor of the added MakoSystem render_template method.

Related changes:
* Adds the MakoService to the StudioEditModuleRuntime,
  PreviewModuleSystem, LmsModuleSystem, and XBlockRuntime
* MakoService constructor takes a `namespace_prefix` string, so that the
  CMS PreviewModuleSystem can render to LMS templates, without needing
  the special render_from_lms helper method.
* ModuleSystem.render_template becomes a read-only property, so the
  constructor calls and test module systems are updated accordingly.
* Adds tests for the MakoService and module system shims.
2021-11-09 14:03:50 +10:30
Tim McCormack
8a764cca10 refactor: Safer, more readable user-mismatch detection code in safe-sessions (#29226)
- Add early exit for readability. Less indentation here may make the control flow easier to read.
- Wrap debug info generation in error-suppressing try-except block.

Co-authored-by: Robert Raposa <rraposa@edx.org>
2021-11-08 16:13:39 +00:00
Bianca Severino
c362507b5d Merge pull request #29267 from edx/bseverino/integrity-signature-flag
[MST-1150] Add integrity signature flag to courseware api
2021-11-08 09:30:18 -05:00
David Ormsbee
15eca3ba59 Merge pull request #29190 from open-craft/jill/BD-13-user-service-fix
[FAL-2457] Let ModuleSystem use UserService
2021-11-08 09:18:10 -05:00
Uzair Rasheed
4b0d450d73 Merge pull request #29265 from edx/refactor_hibp_call
refactor: hibp call to celery task
2021-11-08 17:55:53 +05:00
Awais Jibran
1668d74abb feat: gate proctoring card in course apps (#29263)
* feat: gate proctoring card in course apps

* refactor: quality fix

* refactor: quality fix
2021-11-08 16:12:30 +05:00
Bianca Severino
9f2dc8606b fix: add integrity signature flag to courseware api 2021-11-05 15:35:04 -04:00
uzairr
0f3b3d2763 refactor: hibp call to celery task
Uses is_staff flag to figure out whether the user is internal or not.

Fixes: VAN-664
2021-11-05 18:19:49 +05:00
Waheed Ahmed
100752419e chore: update register identify call traits (#29264)
Updated identify call traits and only include the email_subscribe attribute
if the feature is enabled.
2021-11-05 15:43:15 +05:00
Tim McCormack
fdd27a1f71 feat: Log session ID from various sources after safe-session mismatch (#29185)
Add logging in case a safe-session user mismatch is related to wrong
session being retrieved from cache. This additional logging should
reveal any such mismatch (without revealing the actual session ID in
logs).

Send to metrics as custom attributes as well.

Also:

- Compute "session_id_changed" based on all three session IDs (and
  send as custom attribute)
- Put all _verify_user logs into one (multiline) log line
- Accordingly, change logging assertion to only require a substring,
  at-least-once match rather than a full-and-only match.

ref: ARCHBOM-1939
2021-11-04 19:34:44 +00:00
Jillian Vogel
cf1064616c refactor: deprecate ModuleSystem user attributes in favor of user service
The following ModuleSystem attributes are deprecated by this change, and should be pulled directly from the user service instead:

* anonymous_student_id
* seed
* user_id
* user_is_staff

Related changes:

* Removes the `user` and `anonymous_student_id` parameters from the ModuleService constructor.
* Stores anonymous_user_id in XBlockDjangoUserService's opt_attr
* Pulls out constants used by DjangoXBlockUserService opt_attr so they can be used in the platform code.
* LmsModuleSystem uses the user service created in wrapper function for runtime.publish to avoid requiring the user
  service to be "needed" by all XBlocks.
* LmsModuleSystem no longer checks for instances of XModuleDescriptor when deciding what kind of anonymous_user_id to
  provide:  all XModules are XBlocks, so this check is unnecessary.
* XBlockRuntime returns a user service when requested
* Adds tests for deprecated ModuleSystem attributes and changes to XBlockDjangoUserService.

(cherry picked from commit c41e7fb93a)
2021-11-02 18:24:06 +10:30
michaelroytman
bb299c9521 feat: Remove Use of VERIFIED_NAME_FLAG Waffle Flag and is_verified_enabled Utility
The VERIFIED_NAME_FLAG, the VerifiedNameEnabledView, and the verified_name_enabled key removed from responses for both VerifiedNameView view and VerifiedNameHistoryView
were removed as part https://github.com/edx/edx-name-affirmation/pull/12. This was released in version 2.0.0 of the edx-name-affirmation PyPI package. Please see below for additional context for the removal, copied from the name-affirmation commit message.

The VERIFIED_NAME_FLAG was added as part https://github.com/edx/edx-name-affirmation/pull/12, [MST-801](https://openedx.atlassian.net/browse/MST-801) in order to control the release of the Verified Name project. It was used for a phased roll out by percentage of users.

The release reached a percentage of 50% before it was observed that, due to the way percentage roll out works in django-waffle, the code to create or update VerifiedName records was not working properly. The code was written such that any change to a SoftwareSecurePhotoVerification model instance sent a signal, which was received and handled by the Name Affirmation application. If the VERIFIED_NAME_FLAG was on for the requesting user, a Celery task was launched from the Name Affirmation application to perform the creation of or update to the appropriate VerifiedName model instances based on the verify_student application signal. However, we observed that when SoftwareSecurePhotoVerification records were moved into the "created" or "ready" status, a Celery task in Name Affirmation was created, but when SoftwareSecurePhotoVerification records were moved into the "submitted" status, the corresponding Celery task in Name Affirmation was not created. This caused VerifiedName records to stay in the "pending" state.

The django-waffle waffle flag used by the edx-toggle library implements percentage rollout by setting a cookie in a learner's browser session to assign them to the enabled or disabled group.
It turns out that the code that submits a SoftwareSecurePhotoVerification record, which moves it into the "submitted" state, happens as part of a Celery task in the verify_student application in the edx-platform. Therefore, we believe that because there is no request object in a Celery task, the edx-toggle code is defaulting to the case where there is no request object. In this case, the code checks whether the flag is enabled for everyone when determining whether the flag is enabled. Because of the percentage rollout (i.e. waffle flag not enabled for everyone), the Celery task in Name Affirmation is not created. This behavior was confirmed by logging added as part of https://github.com/edx/edx-name-affirmation/pull/62.

We have determined that we do not need the waffle flag, as we are comfortable that enabling the waffle flag for everyone will fix the issue and are comfortable releasing the feature to all users. For this reason, we are removing references to the flag.

[MST-1130](https://openedx.atlassian.net/browse/MST-1130)
2021-11-01 13:33:55 -04:00
Kshitij Sobti
ff61434893 feat: Add a new way to enable/disable teams [BD-38] [TNL-9175] [BB-5066] (#29099)
* feat: Add a new way to enable/disable teams

Adds a new mechanism for enabling/disabling the team feature in a course using an 'enabled' field to the teams config.
If this field is set to true, teams is enabled (team sets/groups) still need to be defined. If this is set to false then teams is disabled whether or not team sets are defined.

* fix: review feedback
2021-11-01 17:12:06 +05:00
Tim McCormack
18c273f150 feat: Add debug info to safe-sessions: Multiple cookies, response cookies (#29168)
Also:

- Normalize response of a helper function to always be a boolean
- Make unit test accepting of unrelated custom attr calls

ref: ARCHBOM-1939, ARCHBOM-1941
2021-10-29 17:11:23 +00:00
Manjinder Singh
0ba74be102 docs: improve docs (#29158) 2021-10-29 10:58:26 -04:00
Matthew Piatetsky
0c4f45a98b fix: don't introduce integrity errors when updating LastSeenCoursewareTimezone (#29162) 2021-10-29 10:39:11 -04:00
Awais Qureshi
3b12e11e48 temp: Adding logs for debugging purpose. (#29165)
* temp: Adding logs for debugging purpose.

BOM-2961

* temp: Adding logs for debugging purpose.

BOM-2961
2021-10-29 19:08:00 +05:00
AsadAzam
2b14c3157b Revert "Revert "feat: Add support for returning thread counts for all topics in a course [BD-38] [TNL-8724] [BB-4927] (#29062)" (#29087)" (#29152)
This reverts commit ed74db1daf.
2021-10-29 16:20:48 +05:00
Robert Raposa
91ac846e71 fix: safe session code cleanup (#29139)
1. Minor code change to get user_id more consistently.
2. Remove outdated comments.
2021-10-28 10:06:50 -04:00
Robert Raposa
b82144bb83 feat!: remove misleading JWT monitoring (#29142)
BREAKING CHANGE: Removed unused and misleading custom attributes
  used for monitoring:
* `jwt_expires_in`: Removed because it is constant for all requests
  and just repeating the setting value. It was also misleading.
* `jwt_is_asymmetric`: Removed because multiple JWTs might be created,
  and only the last would be reported, which is misleading. This was
  meant to help with a future project to get everyone on to asymmetric
  JWTs, but can be added when needed, and probably should ONLY monitor
  deprecated (symmetric) usage that needs to be fixed. That can be left
  for another day.
2021-10-28 10:06:13 -04:00
Robert Raposa
b6a943c392 fix: errors with anonymous user (#29042)
There are several errors that appear in monitoring when calls
are made with an anonymous user. This resolves one (or more).
2021-10-28 10:05:48 -04:00
M. Zulqarnain
834dabb399 feat: New codemods on OpenedX 2 (#28777) 2021-10-28 16:45:53 +05:00
Adeel Ehsan
2aa220094c feat: Remove el option from education levels (#29150)
If COPPA flag is set to true then remove el options from education levels

VAN-760
2021-10-28 15:50:47 +05:00
Awais Jibran
5f97bc60cf test: adds discussion API permissions test cases (#29135) 2021-10-28 14:54:32 +05:00
Waheed Ahmed
d5ab616ca8 feat: COPPA - remove primary/elementary option from education (#29147)
Remove `primary/elementary` option from education field if COPPA compliance
feature flag is enabled. Also, renamed the flag.

VAN-762
2021-10-28 14:12:53 +05:00
Kshitij Sobti
79cd0b1ef8 feat: Adds discussions settings for new discusions experience [BD-38] [TNL-8621] [BB-4854] (#29131)
* feat: Adds discussions settings for new discusions experience
This commit adds new discussions settings for the new discussions experience. These are stored in the course so they can be a part of course import/export flow.
These are also added to the discussions configuraiton API to allow MFEs to update the settings.
The discussions API is currently available via LMS, however that means it cannot save changes to the modulestore. This also adds the API to the studio config so it can now also be accessed from studio and be used to save course settings.

* fix: tests
2021-10-28 11:56:17 +05:00
connorhaugh
b01e773d2b feat: cache course index queries (#29107)
* feat: store split modulestore's course indexes in Django/MySQL

Course outline generation is calling active_versions hundreds or even thousands of times on course_publish. In practice, the handling of a block requires a fetch of the course index. That requires a call to the active_versions table for each touching of a block. In larger courses, that can mean 1000s of calls to the db to retrieve them. A quick solution to this problem is to use a request cache, so we don't have to query the slow db every time and memoize the relevant data
[An example run can be seen here.](https://one.newrelic.com/launcher/nr1-core.explorer?platform[filters]=IihuYW1lIGxpa2UgJ3Byb2QtZWR4LWVkeGFwcCcgb3IgaWQgPSAncHJvZC1lZHgtZWR4YXBwJyBvciBkb21haW5JZCA9ICdwcm9kLWVkeC1lZHhhcHAnKSBhbmQgKG5hbWUgbGlrZSAnbG1zJyBvciBpZCA9ICdsbXMnIG9yIGRvbWFpbklkID0gJ2xtcycpIg==&platform[accountId]=88178&platform[timeRange][begin_time]=1626715880701&platform[timeRange][end_time]=1627320680701&pane=eyJuZXJkbGV0SWQiOiJhcG0tbmVyZGxldHMudHJhbnNhY3Rpb25zIiwiZW50aXR5R3VpZCI6Ik9EZ3hOemg4UVZCTmZFRlFVRXhKUTBGVVNVOU9mRFk1TVRNM05EUTROQSIsInNlbGVjdGVkU2VyaWVzIjoiZjAzYjNmNzY5OTQ0MjlmOTFhYWQ4MDBkNTEwZTU5MDM5OWNjMzNhMSIsImRyaWxsZG93biI6eyJ0cmFuc2FjdGlvbk5hbWUiOiJPdGhlclRyYW5zYWN0aW9uL0NlbGVyeS9jbXMuZGphbmdvYXBwcy5jb250ZW50c3RvcmUudGFza3MudXBkYXRlX291dGxpbmVfZnJvbV9tb2R1bGVzdG9yZV90YXNrIn19&cards[0]=eyJuZXJkbGV0SWQiOiJhcG0tbmVyZGxldHMudHJhbnNhY3Rpb24tdHJhY2UiLCJ0cmFjZUlkIjoiY2I2OGNkMDktZWI5Yi0xMWViLWJkY2QtMDI0MmFjMTEwMDBlXzI1MjU0MV8zMTgzMTMiLCJlbnRpdHlHdWlkIjoiT0RneE56aDhRVkJOZkVGUVVFeEpRMEZVU1U5T2ZEWTVNVE0zTkRRNE5BIn0=&sidebars[0]=eyJuZXJkbGV0SWQiOiJucjEtY29yZS5hY3Rpb25zIiwic2VsZWN0ZWROZXJkbGV0Ijp7Im5lcmRsZXRJZCI6ImFwbS1uZXJkbGV0cy50cmFuc2FjdGlvbnMifSwiZW50aXR5R3VpZCI6Ik9EZ3hOemg4UVZCTmZFRlFVRXhKUTBGVVNVOU9mRFk1TVRNM05EUTROQSJ9&state=d9946155-ea53-cb11-c1c0-cc873d6c7d39)

Useful information to include:
In theory, this should provide a minor performance boost to authors and learners, and be noticeable in the above function trace, once live on prod. Note, that in several places the cache must be invalidated, as to prevent a stale cache.


Co-authored-by: Braden MacDonald <braden@opencraft.com>
2021-10-27 13:53:10 -04:00
Agrendalath
e633cc9c24 feat: support adding custom editors to Studio
This:
1. Introduces a variable for the Course Outline view in Studio.
   A custom theme can override it to add new editors.
2. Exports a function for creating new editor modals.
   A custom theme can use it to create editors without adding boilerplate code.
3. Adds a pluggable override for XBlock fields that are passed to the Studio.
   Without this, custom editors in Studio cannot retrieve values of XBlock fields.
2021-10-27 13:35:19 -04:00
Manjinder Singh
bd7653aefc feat: removing toggle (#29132)
The toggle was meant to be temporary and its been off for week and
nothing seems to have gone wrong.
2021-10-27 13:31:25 -04:00