Commit Graph

304 Commits

Author SHA1 Message Date
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
Braden MacDonald
6c85668099 feat: write split modulestore's course indexes to Django/MySQL
Split modulestore persists data in three MongoDB "collections": course_index (list of courses and the current version of each), structure (outline of the courses, and some XBlock fields), and definition (other XBlock fields). While "structure" and "definition" data can get very large, which is one of the reasons MongoDB was chosen for modulestore, the course index data is very small.

This commit starts writing course indexes (active_versions) to both MySQL and Mongo, but continues to read from MongoDB only.

By moving course index data to MySQL / a django model, we get these advantages:
* Full history of changes to the course index data is now preserved
* Includes a django admin view to inspect the list of courses and libraries
* It's much easier to "reset" a corrupted course to a known working state, by using the simple-history revert tools from the django admin.
* The remaining MongoDB collections (structure and definition) are essentially just used as key-value stores of large JSON data structures. This paves the way for future changes that allow migrating courses one at a time from MongoDB to S3, and thus eliminating any use of MongoDB by split modulestore, simplifying the stack.
2021-10-26 10:06:52 -07:00
Dillon Dumesnil
78fbd28f41 chore: AA-1058: Update edx-when version
Updates query counts for the additional query to look up the Schedule
in edx-when
2021-10-22 09:36:04 -04:00
Kyle McCormick
9bf266f717 fix: add missing __init__.py files 2021-10-21 09:54:22 -04:00
Usama Sadiq
9ee8df0980 fix: Remove pylint constraint and fix warnings (#28646) 2021-10-20 23:00:13 +05:00
David Ormsbee
ae124bd554 Revert "feat: store split modulestore's course indexes in Django/MySQL"
This reverts commit 96e5ff8dce.
2021-10-07 15:07:42 -04:00
Braden MacDonald
96e5ff8dce feat: store split modulestore's course indexes in Django/MySQL
Split modulestore persists data in three MongoDB "collections": course_index (list of courses and the current version of each), structure (outline of the courses, and some XBlock fields), and definition (other XBlock fields). While "structure" and "definition" data can get very large, which is one of the reasons MongoDB was chosen for modulestore, the course index data is very small.

By moving course index data to MySQL / a django model, we get these advantages:
* Full history of changes to the course index data is now preserved
* Includes a django admin view to inspect the list of courses and libraries
* It's much easier to "reset" a corrupted course to a known working state, by using the simple-history revert tools from the django admin.
* The remaining MongoDB collections (structure and definition) are essentially just used as key-value stores of large JSON data structures. This paves the way for future changes that allow migrating courses one at a time from MongoDB to S3, and thus eliminating any use of MongoDB by split modulestore, simplifying the stack.
2021-10-07 10:59:47 -04:00
Matthew Piatetsky
be5241a96d Merge pull request #28865 from edx/AA-905b
[AA-905] Refactor flag for recording user activity
2021-09-30 08:51:30 -04:00
Matthew Piatetsky
ae618151a9 fix: Remove debugging flag that is no longer necessary and refactor 2021-09-29 15:05:14 -04:00
Julia Eskew
cc3747add6 feat: Optimize the querying of course block dates when querying dates for use in a
course outline, which don't need block dates below the subsection level of a course.
Pass the course's published version to all the appropriate places where edx-when's API
is called - to allow edx-when to more efficiently cache queried/processed results.

TNL-8061
2021-09-27 12:02:59 -04:00
Usama Sadiq
023f4144ab fix: fix new pylint warnings (#28725) 2021-09-23 17:54:15 +05:00
Matthew Piatetsky
3200851563 start addressing comments 2021-09-20 13:08:12 -04:00
Matthew Piatetsky
bf6e135762 feat: Populate the course goals user activity table when a user visits course-specific pages 2021-09-16 12:30:36 -04:00
David Ormsbee
309cadc973 Revert "Use new version of edx-when." (#28684)
Reverting because of errors seen in proctoring. The error from splunk:

 File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/edx_proctoring/views.py", line 590, in get
    data['onboarding_release_date'] = effective_start.isoformat()
AttributeError: 'NoneType' object has no attribute 'isoformat'

The effective date is coming from learning_sequences, which ultimately
comes from edx-when.
2021-09-08 11:05:35 -04:00
J. Victor Martins
6adf45df2f feat: Add permissions filter to list courses API
The new filter, called `permissions`, allows callers to filter courses
per access granted to the specified username.  Callers can now filter
courses per roles, actions, etc.
2021-09-07 14:41:50 -07:00
Julia Eskew
a4ba37b882 feat: Optimize the querying of course block dates when querying dates for use in a
course outline, which don't need block dates below the subsection level of a course.
Pass the course's published version to all the appropriate places where edx-when's API
is called - to allow edx-when to more efficiently cache queried/processed results.

TNL-8061
2021-09-02 17:45:13 -04:00
Azan Bin Zahid
1cce2e952d feat: add pact verification method 2021-08-24 14:59:46 +05:00
Ahtisham Shahid
20d631ff70 fix: added access for data researcher in courseware (#27935)
fix: fixed data researcher permissions on instructor dashboard
2021-06-17 10:57:46 +05:00
Shimul Chowdhury
2a8a58ae6b feat: add Course Membership API
The get_course_members API returns a dict of users associated with a course.
This is a potentially expensive operation on a large course, so there is a
control in place to limit its cost.  If a course has more than
settings.COURSE_MEMBER_API_ENROLLMENT_LIMIT enrollments, then the function
raises an OverEnrollmentLimitException.

This API was added to help implement the LTI 1.3 Names and Roles Provisioning
service.

Jira references: [BD-24] [BB-2726] [TNL-7330] 
Pull request: #25843
Co-authored-by: Giovanni Cimolin da Silva <giovannicimolin@gmail.com>
2021-06-03 09:38:13 -04:00
jawad khan
15f33dc1b2 revert: show empty container blocks from the course blocks api when called by mobile (#27707)
REVE-52 is merged and mobile
traffic from older app versions is < 5% of the mobile traffic.
Therefore we dont need changes from this PR 325fbe4eb2 (diff-c061bf405edf96531766b26cc2bcc2bb3639d851e5d9f844612c2ea57c35e56e)

LEARNER-8377
2021-05-25 20:30:26 +05:00
Dillon Dumesnil
6f773d1eca feat: AA-802: Update the BlockCompletionTransformer
We discovered a subsection that contained a unit without any content
inside, but because of our logic requiring children, it would never be
marked complete (meaning the subsection, section, and course could thus
never be marked complete). This fixes that by removing the children
check from setting completion, but first gating that code path on the
xblock being an aggregator (to prevent leaves from marking as true
simply because there are no children).

Test fixes include adding a test for the empty aggregator case as
well as some changes to not have an entire course marked complete
because they are all empty aggregators.
2021-05-14 11:22:07 -04:00
Michael Terry
12e9763446 Merge pull request #27487 from edx/mikix/fix-gated-content-check
fix: properly set contains_gated_content field on xblocks again
2021-05-03 11:50:40 -04:00
Michael Terry
6e52aafc8c fix: properly set contains_gated_content field on xblocks again
This has been broken for a couple months, preventing proper display
of verified-only assignments on the dates tab and elsewhere.

AA-780
2021-05-03 10:17:17 -04:00
Usama Sadiq
60f49d4048 refactor: pyupgrade second iteration (#27442) 2021-05-03 17:13:15 +05:00
Dillon Dumesnil
3a89ed4275 Merge pull request #27262 from edx/ddumesnil/switch-relative-dates-to-course-waffle-aa-677
refactor: AA-677: Switch relative dates to CourseWaffleFlag
2021-04-14 06:17:08 -07:00
Dillon Dumesnil
c9197d3cfc refactor: AA-677: Switch relative dates to CourseWaffleFlag
We have been bucketing all users into the relative dates experiment
since May 18, 2020. We no longer need to keep this as an
ExperimentWaffleFlag and can convert to a CourseWaffleFlag (so it
continues to support exemptions).
2021-04-08 10:12:54 -04:00
Kyle McCormick
a69567b18b feat: default staff to courseware MFE if active (via jump_to)
The /jump_to/ LMS endpoint is used in a number of places
to direct users to courseware. It currently only redirects to
Legacy courseware URLs, which then conditionally may
redirect to the Learning MFE.

Two issues with this:
1. Performance Impact: In most cases, going to Legacy first
   is just an extra redirect.
2. Confusion for Privileged Users: Neither course nor global
   staff are auto-redirected from the Legacy experience to the
   MFE. Thus, these priviliged users confusingly never see the
   MFE by default; they must always manually click into it.

This commit makes it so that /jump_to/ directs
users to whatever the default courseware experience is
for them. For staff of courses active in the new experience,
this will impact (at a minimum) the "View Live"
links in Studio, all links on the old and new LMS
course outline, and the "Resume" links on the course
dashboard. Learners should see no difference other than
a performance improvement when following courseware links
from the LMS.

This also adds an optional 'experience=[legacy|new]'
query param to /jump_to/, allowing us to specifically
generate Legacy courseware URLs for the
"View in Legacy Experience" tool.

TNL-7796
2021-04-07 10:24:58 -04:00
Robert Raposa
96be45f1bd Merge pull request #27222 from edx/robrap/ARCHBOM-1721-toggle-doc-cleanup
ARCHBOM-1721: docs: update toggle docs
2021-04-05 10:47:55 -04:00
Feanil Patel
8e7144ae2e revert: "test: Update query counts."
This reverts commit c2eabf6cca.

We are changing this from a waffle setting to a django setting so we can
undo this query count bump.
2021-04-02 14:42:55 -04:00
Robert Raposa
8ef8b35a54 docs: update toggle docs
A variety of updates were made to improve the toggle documentation:
* Added comments to help ensure that the waffle(), waffle_switches(),
  waffle_flags() anti-pattern won't be contagious (copied).
* Some minor toggle_description updates.
* Removed empty toggle_target_removal_date annotations for
  non-temporary toggles.
* Removed empty optional toggle_warnings annotations.
* Removed empty optional toggle_tickets annotations.
* Removed deprecated toggle_category, toggle_status,
  and toggle_expiration_date annotations.
* Fixed some indents, use cases, and implementations.

ARCHBOM-1721
2021-04-01 21:58:29 -04:00
Feanil Patel
c2eabf6cca test: Update query counts.
The new WaffleFlag.is_enabled check in middleware increased query counts
for multiple tests.
2021-03-25 12:14:53 -04:00
Agrendalath
e571693455 Support EXCLUDED blocks in Block Completion Transformer
For now only the discussion blocks were supported. If we had a custom XBlock that specified `completion_mode = XBlockCompletionMode.EXCLUDED`, then it could never be marked as completed on the course outline page, despite being marked as such inside the learning sequence.
2021-03-22 16:21:43 +01:00
Agrendalath
5a27b5df39 Calculate completion for custom blocks on the Course Outline page
This adds support for displaying completion on the course outline page, to remove the discrepancies between this view and the learning sequence. It also simplifies course outline page by reusing existing APIs for determining completion state and finding the "Resume block"'s target.
2021-03-22 16:21:32 +01:00
Usama Sadiq
afa102e125 refactor: ran pyupgrade on lms/djangoapps/course_api (#26735) 2021-03-09 12:54:42 +05:00
Kyle McCormick
9aefd6f986 style: django-not-configured is not a sensible lint-amnesty value (#26862)
django-not-configured is an error raised by pylint (with
the pylint-django plugin) when it's not correctly configured.

We should not be applying lint amnesty for such a violation.
2021-03-05 08:11:58 -05:00
Jawayria
2b943d93eb Merge pull request #26537 from edx/jawayria/bom-2352-2
BOM-2352: Removed unused imports from lms/djangoapps/{certificates, c…
2021-03-04 20:40:36 +05:00
jawad khan
787649ba81 LEARNER-8158 - Fixed descendants typo and added tests
LEARNER-8158 
Fixed descendants typo and added tests
2021-03-03 11:38:34 +05:00
jawad khan
137a271fd2 LEARNER-8158 - Fixed completion param issue (#26678)
* LEARNER-8158
Fixed completion param issue
- There is a case where we are sending requested_fields in params as comma separated list
e.g. requested_fields=children,show_gated_sections,graded,special_exam_info,completion.
- We didn't test for this case in first place and test cases were sending requested_fields as list.
- Now we can also handle this comma separated completion field which was getting ignored before.
2021-02-26 14:02:09 +05:00
Jawayria
b3b0b083d2 BOM-2352: Removed unused imports from lms/djangoapps/{certificates, commerce, course_api} 2021-02-23 19:38:25 +05:00
Aarif
a332aac1f6 replaced unittest assertions pytest assertions (#26541) 2021-02-19 12:27:11 +05:00
Michael Terry
1b9119859e AA-614: Add initial effort estimation block transformer 2021-02-18 08:31:19 -05:00
Jawayria
959aed9841 Resolved pep8 issues 2021-02-04 14:07:47 +05:00
Jawayria
e9b167e1fd Applied pylint-amnesty to course_api 2021-02-04 13:22:45 +05:00
jawad khan
8529e433b8 Added completion from root to child blocks api and increased version
* Added completion from root to child blocks api and increased version
Learner-8158
2021-02-02 19:51:14 +05:00
Régis Behmo
3a29cff016 Get rid of calls to set_request_cache_with_short_name
This method from the toggle legacy classes should not actually be
exposed to all. So we get rid of it by manually setting the cached
value. While we are at it, we convert the STORAGE_BACKING_FOR_CACHE
legacy waffle switch to its modern version. As the flag is not being
used elsewhere, this should not break anything.

We take the opportunity to modernize waffle switches from
block_structure.config: to do so we convert the INVALIDATE_CACHE_ON_PUBLISH and
RAISE_ERROR_WHEN_NOT_FOUND waffle switches from legacy classes to their modern
equivalents. These switches are not used outside of edx-platform, so this
change should not trigger any error.
2021-01-12 16:52:08 +01:00
Carla Duarte
03846e229d AA-545: Include has_scheduled_content in StartDateTransformer 2021-01-05 15:06:24 -05:00
Kyle McCormick
54d5f7f394 Course Blocks API: Fix handling of incorrectly-cased course keys (#25911)
Commit 7f59688 attempted to solve this using
`CourseOverview.course_exists`, but that check is case-
insensitive. This commit instead does a small refactor
to `lms.djangoapps.courseware.get_course` so that we can
handle a failed course lookup without broadly catching
a `ValueError`.
2020-12-18 11:26:29 -05:00
Kyle McCormick
7f59688f9b Course Blocks API: Return 403 instead of 500 for unknown courses (#25906)
Anonymous users (like crawlers) requesting non-existent courses
should get 403, just like logged-in users do. They instead raised
a ValueError.
2020-12-17 18:13:51 -05:00
Régis Behmo
a16cd71046 Start waffle namespace deprecation
By explicitly importing the legacy namespace classes, we make it clear
that we are using soon-to-be-deprecated classes. We will then be able to
start removing the legacy classes, one module at a time.
2020-12-03 16:06:14 +01:00
Diana Huang
afeea75d9e Add changes to support ES7 and edx-search 2.0 back into the tree. 2020-11-17 13:23:13 -05:00