Details
-
Type:
Bug
-
Status: Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 3.9.3, 3.10
-
Component/s: Course
-
Labels:
-
Testing Instructions:
-
Affected Branches:MOODLE_310_STABLE, MOODLE_39_STABLE
-
Fixed Branches:MOODLE_310_STABLE, MOODLE_39_STABLE
-
Pull from Repository:
-
Pull 3.9 Branch:
MDL-70261-39 -
Pull 3.9 Diff URL:
-
Pull 3.10 Branch:
MDL-70261-310 -
Pull 3.10 Diff URL:
-
Pull 3.11 Branch:
MDL-70261-311 -
Pull 3.11 Diff URL:
-
Pull Master Branch:
MDL-70261-master -
Pull Master Diff URL:
-
Sprint:Moppies Kanban
Description
Steps to reproduce:
- Visit /course/customfield.php. Create a new custom field.
- Edit the custom field, set "Locked" = "Yes".
- Visit /admin/tool/uploadcourse/index.php
- Upload a simple course CSV, e.g:
-
shortname,fullname,category
test1,Test 1,1
- Click "Preview". You should get an error: "Coding error detected, it must be fixed by a programmer: Only course or course category context expected"
This error is caused by incorrect assumptions in /course/classes/customfield/course_handler.php, in the can_edit function:
return (!$field->get_configdata_property('locked') || guess_if_creator_will_have_course_capability('moodle/course:changelockedcustomfields', $context)); |
|
When uploading a course, $context will always be an instance of context_system, because the caller passes $instanceid = 0. The function guess_if_creator_will_have_course_capability does not allow $context to be a context_system instance. So if the field in question is locked, that function is called with a context_system instance and a coding error is thrown.