Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.8.5, 1.9
-
Fix Version/s: 1.9.1
-
Component/s: Database activity module
-
Labels:None
-
Database:MySQL
-
Affected Branches:MOODLE_18_STABLE, MOODLE_19_STABLE
-
Fixed Branches:MOODLE_19_STABLE
Description
When a preset.zip is imported, values from its preset.xml's <settings></settings> section will be written into the DB table mdl_data. One of these imported settings is the ID number of the field that should act as default sort key. Let's call this ID "PRESETSORTID". It is specified as
<defaultsort>PRESETSORTID</defaultsort>.
The smallest value of the id field of the appropriate mdl_data_fields SQL table is the ID number of the first field, let's call it FIRSTID. If you create a new database activity using a preset and completely delete that activity and re-create it, FIRSTID changes (increases).
The defaultsort field of the appropriate mdl_data SQL table should be filled with
DEFAULTSORTID = FIRSTID + PRESETSORTID -1, however it just gets filled with
DEFAULTSORTID = PRESETSORTID.
This prevents us setting the default sort field using a preset.zip. This is bad because there is currently no other way than using a preset. We only can set the default sort direction (<defaultsortdir>0=ascending or 1=descending</defaultsortdir>), but the default sort field currently is always the Date entered. This does not make sense in many cases.
The attached patch against MOODLE_19_STABLE fixes this bug. It would be nice to see it committed.
It allows to use
<defaultsort>1</defaultsort>
within a "preset.xml" packed into a "preset.zip" for getting the first field (field number 1) the default sort field. If the second field should be the default sort field, specify
<defaultsort>2</defaultsort>
and so on. The field numbers are counted as they appear in "preset.xml".
I'm very happy with that now