Commit Graph

554 Commits

Author SHA1 Message Date
Justin Lapierre
f6f3a79a15 Revert "[BD-13] Deprecate ModuleSystem.render_template" 2021-11-16 15:16:08 -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
Jillian Vogel
bafc0cd91f refactor: removes calls to deprecated ModuleSystem attributes
Removes references to these deprecated attributes from the platform code:
* runtime.anonymous_student_id
* runtime.seed
* runtime.user_id
* runtime.user_is_staff

Related changes:

* Ensure that all platform XBlocks which use these attributes "need" the user service.
* ProblemBlock: Removes check for existence of runtime.seed attribute in preparation for removal of this attribute from ModuleSystem.
* edxnotes: Catches NoSuchServiceError just in case some XBlocks using notes don't have the user service.
* UserTagsService refactor: pass user and course_id on creation

(cherry picked from commit 753839276f)
2021-11-02 18:24:14 +10:30
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
David Ormsbee
deaf80f346 revert: "[BD-13] Let ModuleSystem use UserService" (#28857)
This caused a regression where anonymous_id values were not as expected.
Reverting for now, with investigation to follow.
2021-09-27 15:42:35 -04:00
David Ormsbee
3827f4c90d Merge pull request #28440 from open-craft/jill/BD-13-user-service
[BD-13] Let ModuleSystem use UserService
2021-09-24 09:26:43 -04:00
Usama Sadiq
023f4144ab fix: fix new pylint warnings (#28725) 2021-09-23 17:54:15 +05:00
Jillian Vogel
753839276f refactor: removes calls to deprecated ModuleSystem attributes
Removes references to these deprecated attributes from the platform code:
* runtime.anonymous_student_id
* runtime.seed
* runtime.user_id
* runtime.user_is_staff

Related changes:

* Ensure that all platform XBlocks which use these attributes "need" the user service.
* ProblemBlock: Removes check for existence of runtime.seed attribute in preparation for removal of this attribute from ModuleSystem.
* edxnotes: Catches NoSuchServiceError just in case some XBlocks using notes don't have the user service.
* UserTagsService refactor: pass user and course_id on creation
2021-09-23 11:46:43 +09:30
Jillian Vogel
c41e7fb93a 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.
2021-09-23 11:41:43 +09:30
Michael Terry
b90039b23d fix: the get_completion JS handler should not ignore FBE blocks
Because xblock handlers normally get a block tree that already has
inaccessible blocks stripped, they don't see FBE gated blocks at
all. So the get_completion handler would return True for FBE units
incorrectly. Leading to a visual bug as an audit user went through
their units in the courseware.

In order to let the handler know about the full tree, I've added a
new attribute you can set on your xblock handlers:
my_handler.will_recheck_access = True

This will tell the top-level handler code get the full tree for you.

As part of this, I've also changed the sequence xblock handler's
into proper xblock handlers (not old-style xmodule handlers).
This changes their URLs slightly. I've kept the old URLs for now
as well, but they'll be removed after Maple.

AA-409
2021-04-27 15:17:53 -04:00
Usama Sadiq
859df03049 refactor: ran pyupgrade on lms/djangoapps/courseware (#26737) 2021-03-12 12:15:58 +05:00
Usman Khalid
62ed654b31 Convert LTIModule into LTIBlock. (#25713) 2021-02-16 09:09:13 -05:00
Jawayria
03e6a874d0 Applied pylint-amnesty to courseware 2021-02-03 21:56:24 +05:00
Usman Khalid
9e38b17202 Convert ErrorModule and NonStaffErrorModule to XBlocks. (#25570) 2021-01-07 10:51:33 -05:00
Dillon Dumesnil
e17e691d54 AA-501: Use hidden blocks to determine past due status
Blocks that were hidden by access checks would not be used when
calculating past due status for a unit. This adds in a check to
still look at those blocks, but will maintain not rendering them
when being accessed via the MFE
2021-01-06 14:11:03 +00:00
Régis Behmo
d13a1fb5f5 Upgrade completion
This is required because edx-platform uses the waffle API from
completion, which itself depends on edx-toggles. So if we change
edx-toggles import paths, we also need to upgrade our usage of
completion here.
2020-12-03 16:06:15 +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
Matthew Piatetsky
2153057142 Add XBlock service for content type gating
This is used in this commit to check if a timed exam contains any problems that have been gated by content type gating
REV-1510
2020-10-14 08:02:51 -04:00
Tim McCormack
f29e418264 Revert "Revert "ARCHBOM-1494: Refer to custom attributes, not metrics, especially with edx-django-utils (#25010)" (#25025)" (#25055)
This reverts commit 986a448d9e.
2020-09-28 13:53:57 +00:00
Ahtisham Shahid
986a448d9e Revert "ARCHBOM-1494: Refer to custom attributes, not metrics, especially with edx-django-utils (#25010)" (#25025)
This reverts commit ba9ee4e151.

Fixed Style lint issue
2020-09-21 13:48:00 +05:00
Tim McCormack
ba9ee4e151 ARCHBOM-1494: Refer to custom attributes, not metrics, especially with edx-django-utils (#25010)
This uses the new names introduced in edx-django-utils
3.8.0 (edx/edx-django-utils#59), which we're already using, as
well as updating a few other locations where we incorrectly refer
to New Relic custom metrics instead of custom attributes.

Includes a couple of unrelated lint fixes in a file I modified.
2020-09-18 13:33:50 +00:00
mariajgrimaldi
c23071defc Fix DeprecationWarning: The 'warn' method is deprecated, use 'warning' instead (#23909)
I wanted to make a byte-sized contribution but there were no Jira tickets so we decided, thanks to a conversation with @jmbowman through the Open Edx Community #incr (Slack) channel, to collaborate in the elimination of warnings listed in the Warnings Report at https://build.testeng.edx.org/job/edx-platform-python-pipeline-master/warning_5freport_5fall_2ehtml/

This PR contributes to the elimination of deprecation warnings, specifically the one mentioned above and reported in the Warnings Report.

Changed logger.warn to logger.warning in the following files:

    lms/djangoapps/experiments/utils.py

    lms/djangoapps/lti_provider/outcomes.py

    lms/djangoapps/courseware/module_render.py

This warning occurs due to deprecation in python 3.4+: https://docs.python.org/3.5/library/logging.html#logging.Logger.warning
2020-05-08 12:15:59 -04:00
David Ormsbee
5ea71beeb1 Make XBlock views/handlers non-atomic requests.
We're seeing slow commits on production for courseware_studentmodule
updates. Based on the slow queries during those times, we think it
might be because multiple worker processes are trying to update the
same rows from within long-running transactions (since courseware
is relatively slow).

The risk with this is that since the whole view execution is no
longer wrapped in a big implicit transaction, it's possible that
XBlock state will update and things that key off of that (e.g.
completion progress information or pre-req milestones) will fail
in a way that will leave the database in an unplanned-for state,
though this is already the case for those actions that trigger
asynchronous tasks like grades recalculation.

The query counts for the index view test were adjusted down
because save points count towards the total and we're no longer
setting them at the top level around the view as a whole.
2020-03-31 21:22:58 -04:00
Manjinder Singh
d7bd80a100 Renamed OAuth2Authentication to BearerAuthentication (#23128)
* Renamed OAuth2Authentication to BearerAuthentication
* Added back OAuth2Authentication name
-there are libraries such as edx-enterprise that still import OAuth2Authentication.  The OAuth2Authentication class should be fully removed when everything is importing BearerAuthentication correctly
2020-02-18 13:29:29 -05:00
Manjinder Singh
cce8cdd661 Replacing OAuth2Auth (#23067)
- Removing deprecated auth classes
- Replacing OAuth2AuthenticationAllowInactiveUserDeprecated with OAuth2AuthenticationAllowInactiveUser
- the old class was a child class of a deprecated class that we are removing and replacing.
2020-02-11 10:38:13 -05:00
Manjinder Singh
cea795b02e Added new auth class (#23018)
* Added new auth class

- Created new class called OAuth2AuthenticationAllowInactiveUser, which replaces old class with same name
- Renames previous  OAuth2AuthenticationAllowInactiveUser to  OAuth2AuthenticationAllowInactiveUserDeprecated
- Replaced all imports of  OAuth2AuthenticationAllowInactiveUser to call deprecated class instead
- testing new class in discussion(added flag based on django setting)
2020-02-06 10:37:27 -05:00
Feanil Patel
6e3fe00fff Fix all E303 pep8 errors. 2019-12-30 12:25:38 -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
5f6b2db31b BOM-1111
Updating User.is_authenticated and User.is_anonymous as properties
2019-12-23 17:51:27 +05:00
DawoudSheraz
5178256f3c add user state service in module render 2019-12-16 11:20:55 +05:00
julianajlk
6e0914ad5d add FPD banner to courseware (#22113)
REV-980
2019-10-23 09:33:11 -04:00
Braden MacDonald
5fc73468b3 Change completion API to work with any learning context 2019-10-22 14:04:31 -04:00
julianajlk
98f907f23c Revert "add first purchase discount to courseware (#22058)"
This reverts commit 059b619794.
2019-10-21 13:57:18 -04:00
julianajlk
059b619794 add first purchase discount to courseware (#22058)
REV-980.
* moved get_first_purchase_offer_banner_fragment to Discounts utils.py
* added banner wrapper method
* updated banner with time limit
2019-10-21 13:56:38 -04:00
Ayub khan
b3c062be1b BOM-848 Different Hash Values
hashlib produces different md5 hash in python3 against same values as
compared to python2.
2019-10-21 14:02:49 +05:00
Ned Batchelder
efba6e45e8 Finally import courseware properly everywhere to get rid of a warning 2019-09-26 09:40:15 -04:00
Aarif
072f878b90 Merge pull request #21637 from edx/BOM-446
BOM-446
2019-09-13 14:40:36 +05:00
aarif
9301ec38f3 python 3 fixes 2019-09-12 17:29:34 +05:00
aarif
dba8a23144 python 3 fixes
test fixes

changes made as suggested

updated the variable name
2019-09-12 15:32:19 +05:00
Dave St.Germain
267be29ab7 Added edx-when's FieldData
EDUCATOR-4554
This fixes a bug where extended due dates were visible in the outline but not reflected on the courseware pages, resulting in problems not being submittable past the due date.
In order for edx-when to work on courseware pages, it has to be more careful about field inheritance, which version 0.2 achieves.
2019-08-12 11:05:44 -04:00
uzairr
9276aac8d2 Restrict grading endpoints in LMS
Cuurently, grading endpoints in capa module are vulnerable as they
are not restricted.To avoid it, changes have been made so that
they are available only for logged-in users.

LEARNER-3761
2019-07-24 19:20:13 +05:00
aarif
64bd86c12c ran python-modernize and isort on files mentioned in INCR-435 2019-07-12 15:29:19 +05:00
Calen Pennington
755a5c7db6 Augment content_type_gating tests to detect the failure case from the original REVMI-34 implementation 2019-05-16 15:17:33 -04:00
Calen Pennington
7eeff8bf9a Re-resolve REVMI-34 to allow any access error to put a message in the courseware 2019-05-15 11:29:00 -04:00
Calen Pennington
8c0ad119ec Revert "Revert "Merge pull request #20272 from cpennington/revmi-34-recheck-access""
This reverts commit b64664932d.
2019-05-15 11:29:00 -04:00
Nimisha Asthagiri
eb0791ec89 Inter-app API cleanup for Grades 2019-05-04 11:35:06 -04:00
David Ormsbee
50a8360b1a Merge pull request #20023 from open-craft/symbolist/capa-xblock-1
CapaModule to ProblemBlock [SE-397]
2019-05-01 12:18:50 -04:00
Usman Khalid
41c6236e0a Convert CapaModule to ProblemBlock.
* Minimum possible changes were made to merge CapaModule & CapaDescriptor into
  one ProblemBlock class.
* There are no known changes in behavior.
* CapaModule and CapaDescriptor inherited from a number of classes which inherit
  from XModule or XModuleDescriptor but did not depend on them. For all these
  classes the methods were moved to mixins which did not inherit from either and
  then these mixins were added to ProblemBlock in the order which maintains MRO.
2019-05-01 20:08:36 +05:00
Matthew Piatetsky
b64664932d Revert "Merge pull request #20272 from cpennington/revmi-34-recheck-access"
This reverts commit 5d99714aed, reversing
changes made to 5424155cd0.
2019-04-26 13:19:13 -04:00