core_course_get_categories query returns records 'like' parameter

core_course_get_categories query returns records 'like' parameter

by Robert Duncan -
Number of replies: 0
Hi,

 I am using the Web service API to create courses and categories - I first need to create the 'categories' and then I need to query Moodle to find out what the auto_increment 'id' of the parent category. I am using Powershell to build some test queries and its working well. One issue that I have had to put in a work around for is; the API seems to return all records that partially match the query string.

e.g.


criteria[0][key]=  'idnumber'

criteria[0][value'= 'DDM'


Returns all categories with a category ID that begins with DDM - for  subcategories  or categories with idnumbers like DDM1, DDM2, there records will be returned also. (in other words it doesn't seem to be an = operator under the covers).

Any pointers on how to return a single category would be greatly appreciated.



I also want to point out that when we want to create a subcategory we must give the 'parent' - this is an auto_increment Moodle counter. It would be far easier if we could create subcategories by defining the parent categories 'idnumber' i.e. data which we already know about.

Consider I have a 'category' and 'sub category' or more formally a 'course' and 'course instances'  the relational logic for these entities should not be based an arbitrary moodle 'parent' integer.  I know this will be required for links etc. but it should be abstracted away from Moodle integrations.

Further, If we consider that an institution can have many schools, courses, instances, locations and modes of study - then this schema becomes very difficult to reflect the same segregation/hierarchy 

we can only depict a basic relationship of nested elements

-> Category (parent 0, id 5)

   -->Sub Catecory (parent 5, id 6)

        --->Sub, Sub Category (parent 6, id 7)

+-------------------+--------------+------+-----+---------+----------------+
| Field             | Type         | Null | Key | Default | Extra          |
+-------------------+--------------+------+-----+---------+----------------+
| id                | bigint(10)   | NO   | PRI | NULL    | auto_increment |
| name              | varchar(255) | NO   |     |         |                |
| idnumber          | varchar(100) | YES  |     | NULL    |                |
| description       | longtext     | YES  |     | NULL    |                |
| descriptionformat | tinyint(2)   | NO   |     | 0       |                |
| parent            | bigint(10)   | NO   | MUL | 0       |                |
| sortorder         | bigint(10)   | NO   |     | 0       |                |
| coursecount       | bigint(10)   | NO   |     | 0       |                |
| visible           | tinyint(1)   | NO   |     | 1       |                |
| visibleold        | tinyint(1)   | NO   |     | 1       |                |
| timemodified      | bigint(10)   | NO   |     | 0       |                |
| depth             | bigint(10)   | NO   |     | 0       |                |
| path              | varchar(255) | NO   |     |         |                |
| theme             | varchar(50)  | YES  |     | NULL    |                |
+-------------------+--------------+------+-----+---------+----------------+
14 rows in set (0.00 sec)
Average of ratings: -