Commit Graph

14 Commits

Author SHA1 Message Date
M. Zulqarnain
e505d99237 pyupgrade on lms gating and grades apps (#26532) 2021-02-22 12:58:41 +05:00
M. Zulqarnain
0213fde968 BOM-2281 : Pylint amnesty for grades,gating and instructor app (#26343)
* pyint amnesty for grades,gating and instructor app
2021-02-03 18:14:35 +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
Feanil Patel
facd737ee4 Update code to use the new rounding method in course_grades.
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.
2019-10-31 14:29:57 -04:00
Ayub khan
5c47a3b425 BOM Project
Updated __unicode__ to __str__
2019-09-25 18:31:54 +05:00
Ayub khan
12cb1e93d1 INCR-438 python3 compatibility 2019-07-16 15:17:25 +05:00
Ammar Naqvi
fde830b73a Updated subsections grade percentage to start rounding
Changed subsection gating on course outline to consider rounded off grade instead of absolute grade to decide whether to show a subsection which has a prerequisite or not.
EDUCATOR-1676
2018-01-08 15:29:42 +05:00
Sanford Student
38db15cbe9 EDUCATOR-2055: resolving error causing upgrades to verified to fail 2018-01-04 11:14:47 -05:00
Sofiya Semenova
dd93e67b5d Force regrade on enrollment track change. 2017-12-22 12:03:04 -05:00
Nimisha Asthagiri
b5435e6f5a Course Grade reports: eliminate CSM calls, user-transformed structures
EDUCATOR-558
2017-10-05 01:12:49 -04:00
Nimisha Asthagiri
27229a1f9b Optimize grade reports for ZeroCourseGrades.
EDUCATOR-558
2017-10-03 11:35:32 -04:00
Nimisha Asthagiri
f8e3a3c461 Grades Cleanup
EDUCATOR-1405
EDUCATOR-1451
2017-10-02 19:03:26 -04:00
Nimisha Asthagiri
1febdbfac9 Grades cleanup: remove read_only param and create method
EDUCATOR-171
2017-09-28 07:48:25 -04:00
Nimisha Asthagiri
22edaf7d24 Grades: move out of temporary new folder
EDUCATOR-1400
2017-09-22 11:49:46 -04:00