Since code-annotations==0.7.0, incremental_release, launch_date,
monitored_rollout, graceful_degradation, beta_testing are all considered
as "temporary" use cases.
Instead of going up the stacktrace to find the module names of waffle
flags and switches, we manually pass the module __name__ whenever the
flag is created. This is similar to `logging.getLogger(__name__)`
standard behaviour.
As the waffle classes are used outside of edx-platform, we make the new
module_name argument an optional keyword argument. This will change once
we pull waffle_utils outside of edx-platform.
Note that the module name is normally only required to view the list of
existing waffle flags and switches. The module name should not be
necessary to verify if a flag is enabled. Thus, maybe it would make
sense to create a `add` class methor similar to:
class WaffleFlag:
@classmethod
def add(cls, namespace, flag, module):
instance = cls(namespace, flag)
cls._class_instances.add((instance, module))
* Moving plugins infrastructure to edx-django-utils
This PR extracts the code that enables plugins in edx-platform and puts it in edx-django-utils. This is done to allow other IDAS to add plugin functionality.
This is a helpful class when running an experiment, to help
bucket users and keep track of which enrollments to consider
as part of the experiment.
AA-53
* 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
- 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.
* 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)
This adds request caching to the following places:
* course expiration wrapper (displayed in Units)
* offer banner generation (displayed in Units)
* get_enrollment
* user_by_anonymous_id
* youtube_disabled_for_course
On a sample course with edx-val enabled, this reduced the queries
for a large sequence from 450 to 155.
So making this code change took a few hours. But then deciding that it
was the right one of the many options available took the next 3 days.
When changing to the new rounding function, we had a test that started
failing. It appears as if our new rounding function is not the same in
some way as the one built into python 2.
```
>>> round(.0045*100 + .05)/100
0.0
>>> round_away_from_zero(.0045*100 + .05)/100
0.01
```
Doing the math by hand we see that the new function is actually correct
but the old one is clearly rounding incorrectly in this case. Looking
closer at this I discovered that it was due to a floating point issue
where .0045*100 is represented as 0.44999999999999996 so when we add
0.05 to this number we get 0.49999999999999994. This is all because of
the limitations of floating point arithmetic.
See https://docs.python.org/3/tutorial/floatingpoint.html#tut-fp-issues
for more on that.
Because python does its rounding at the bit level in C code. It treats
the .4999... as below the .5 cutoff and rounds down. Whereas our code
does more simple arithmetic which causes the number to correct itself
before we round and so correctly rounds up to 0.01
The result of this change is that previously, the rounding threshold used to
be that any number > .0045 would ronud to 0.01 and now any number that
is >= .0045 rounds to 0.01
Note that if we only care about the two most significant digits of
number between 0 and 1, this error only manifests itself in such a way
that other than the case of going from 0.00 to 0.01 eg. from 0% to 1%
none of the other cases where we would now round up cause the 2 most
significant digits to change. Given this level of impact, we're fine
with this change.
In our tests we see this for one case, where an incomplete turns into an
F in a test. I'm updating the test here to be more correct.
As we were looking at it we speculated as to why we were adding the .05
to the number. Could it be to counteract this floating point issue? It
turns out not.
Looking at this commit(a1286b1c7d) we see that it
looks like this was intended to always round up to the nearest
percentage point. However, there's a typo here. If you wanted to
ensure that we always rounded up to the nearest percentage point you
would have the math be `round(final_grade_percent*100 + 0.5)/ 100` or a
simpler way to do this would be
`math.ceil(final_grade_percent*100)/100`. However, that is not what
happened and 7 years later, there have been a lot of people graded with
the wrong rounding where essentialy anyone with a grade of 89.45 gets a
90 when the intended impact was supposed to be that anyone with a grade
above an 89.0 would get a grade of 90.
Changing it now requires a lot of conversation and wolud have a large
impact on existing learners. So we are not going to change it as a part
of the python 2 -> python 3 upgrade. I have created
https://openedx.atlassian.net/browse/TNL-6972 to capture this issue if
we want to address it in the future.
* Fix type mismatches in the course_modes migrations
* Fix type mismatches in the course_action_state migrations
* Fix type mismatches in the schedules migrations
* Fix type mismatches in grades migrations
* Fix type mismatches in video_pipeline
* Fix type mismatches in api_admin
* Fix mismatches in credential migrations
More generally, makes it so we don't ever pull in the user to whom
we're attributing overrides from the request, but always use the one
passed in via method parameters
Also pass through comments, if they're provided via this method
JIRA:EDUCATOR-4641