mysql - How to create a new course category in the moodle? -


I need to make some moodle intents directly in the database.

I have a query to insert a new Rule of Moodle course and course reference (in mdl_context ) and it works well. INSERT (category, full name, shortname) value (1, 'newcourse', 'c1')

in addition to mdl_course plus a new Moodle category, is required to insert, but in this case a simple insert query does not work

I do not know how to mdl_context

 < Code> INSERT 'unasus_ava` .`mdl_course_categories` (`name`,` idnumber`, values ​​(' new category ',' ',' and lieutenant; p & gt; some text & lt; / p & gt; ' 1, 50000, 'Description', `Description Format`,` Sort Order ',' Timemodified ',' Hrai ',' Path '), 1392726085, 1' / 5 ');  

Regarding the parameters, in a context, what is the class in terms of path , and depth '2' from to categories and '3' to courses . But I have no idea about reference level

  INSERT 'unasus_ava' 'Mdl_context` (`contextual`,` instanceid`, `path`,' depth '] value (40, 3,' / 1/20 ', 2);  

Resolve my problem using the Moodle Rest API

I was scripted based on the examples found here

  $ token = 'my_auth_token'; $ Domainname = 'http: // localhost / moodle'; $ Functionname = 'core_course_create_categories'; $ Restformat = 'json'; $ Category = new stud class (); $ Range-> Name = 'example'; $ Range-> Parents = 0; $ Range-> Details = '& lt; P & gt; Text & lt; / P & gt; '; $ Range-> Description = 1; $ Ranges = array ($ range); $ Params = Array ('categories' = & gt; $ ranges); /// Fresh call headers ('content-type: text / plain'); $ Serverurl = $ domain name '/webservice/rest/server.php'. '? Wstoken = '$ Tokens' & Amp; Wsfunction = '$ functionName Need_once ('./crl.php'); $ Curls = new curls; // If the rest of the format == 'xml', then we do not add ultimate for backward compatibility with Moodle; 2.2 $ Format of the rest = ($ refresh == 'Jason')? 'And MoodleWestMet ='. $ Restformat: ''; $ Resp = $ curl- & gt; Post ($ serverurl. $ Restformat, $ params); Print_r ($ resp);  

This method automatically creates references


Comments