-
Bug
-
Resolution: Fixed
-
Major
-
2.3.6
-
MOODLE_23_STABLE
-
MOODLE_23_STABLE, MOODLE_24_STABLE
-
MDL-39000-master -
This is not trivial bug to reproduce, but it actually happened and caused a lot of unrest between students complaining about blocked access to course sections that they should have available.
----------------
How to reproduce:
1. Enable conditional access in Advanced functions.
2. Create 2 courses A and B, inside each course section 1 create Lesson A and B respectively.
3. In Course A section 2 create Book A.
4. Set Course A section 2 available when grade from Lesson A is above 50% and set to display availablity conditions.
5. In Course B set section 2 available when grade from Lesson B is above 50%and set to display availablity conditions.
6. Import Book A from Course A to Course B. It gets imported with section 2 condition reference to Lesson A from Course A!
7. Sign test Student into both Course A and Course B as student
—
8. Log out or in another browser log in as Student and go to Course A. Complete Lesson A and you should have grade for Lesson A.
9. Check that you have avalable section 2 with Book A.
10. Log out to clear your session.
11. Log in as Student and go directly to Course B. The conditional logic will try to evaluate your access to Course B section 2 and will set both your Lesson B and Lesson A to "false" in $SESSION->gradescorecache.
11. Go to Course A and check that you do not have secton 2 with Book A available despite that you should have (Student still have proper grade in database, but it is ignored while it is set in session cache).
---------------
Location of the bug:
lib/conditionlib.php condition_info_base->get_cached_grade_score()
lines 1144-1150:
// And if it's still not set, well it doesn't exist (eg
// maybe the user set it as a condition, then deleted the
// grade item) so we call it false
if (!array_key_exists($gradeitemid, $SESSION->gradescorecache))
This doesn't account for grade items existing in other courses with conditional references to them imported to the current course. Or maybe the problem is to allow conditional references to non-existent modules with selective import.