upgrade.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. <?php
  2. /**
  3. * This file keeps track of upgrades to the lams module.
  4. *
  5. * Sometimes, changes between versions involve
  6. * alterations to database structures and other
  7. * major things that may break installations.
  8. * The upgrade function in this file will attempt
  9. * to perform all the necessary actions to upgrade
  10. * your older installtion to the current version.
  11. * If there's something it cannot do itself, it
  12. * will tell you what you need to do.
  13. * The commands in here will all be database-neutral,
  14. * using the functions defined in lib/ddllib.php
  15. *
  16. * - v 1.4 2013/09/19
  17. * + Insert general fields for iassign statement (grade, timeavaliable, timedue, preventlate, test, max_experiment).
  18. * + Change index field 'name' in 'iassign_ilm' table to index field 'name,version'.
  19. * - v 1.2 2013/08/30
  20. * + Change 'filearea' for new concept for files.
  21. * + Change path file for ilm, consider version in pathname.
  22. *
  23. * @author Patricia Alves Rodrigues
  24. * @author Leônidas O. Brandão
  25. * @author Luciano Oliveira Borges
  26. * @version v 1.4 2013/09/19
  27. * @package mod_iassign_db
  28. * @since 2010/12/21
  29. * @copyright iMatica (<a href="http://www.matematica.br">iMath</a>) - Computer Science Dep. of IME-USP (Brazil)
  30. *
  31. * <b>License</b>
  32. * - http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  33. *
  34. * @param $oldversion Number of the old version.
  35. */
  36. require_once ($CFG->dirroot . '/mod/iassign/locallib.php');
  37. function xmldb_iassign_upgrade ($oldversion) {
  38. global $CFG, $DB, $USER;
  39. $dbman = $DB->get_manager();
  40. if ($oldversion < 2014012100) {
  41. // Define field and index in iLM table to be added
  42. $table = new xmldb_table('iassign_ilm');
  43. $index_name = new xmldb_index('name');
  44. $index_name->set_attributes(XMLDB_INDEX_UNIQUE, array('name'));
  45. if ($dbman->index_exists($table, $index_name)) {
  46. $dbman->drop_index($table, $index_name, $continue = true, $feedback = true);
  47. }
  48. $index_name_version = new xmldb_index('name_version');
  49. $index_name_version->set_attributes(XMLDB_INDEX_UNIQUE, array('name', 'version'));
  50. if (!$dbman->index_exists($table, $index_name_version)) {
  51. $dbman->add_index($table, $index_name_version, $continue = true, $feedback = true);
  52. }
  53. // Fix field name in ilm table to be added.
  54. $table = new xmldb_table('iassign_ilm');
  55. $field_height = new xmldb_field('heigth', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '600', 'width');
  56. if ($dbman->field_exists($table, $field_height))
  57. $dbman->rename_field($table, $field_height, 'height');
  58. // Define fields in iassign table to be added.
  59. $table = new xmldb_table('iassign');
  60. $field_intro = new xmldb_field('intro', XMLDB_TYPE_TEXT, 'medium', null, null, null, null, 'name');
  61. if (!$dbman->field_exists($table, $field_intro))
  62. $dbman->add_field($table, $field_intro);
  63. $field_introformat = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '0', 'intro');
  64. if (!$dbman->field_exists($table, $field_introformat))
  65. $dbman->add_field($table, $field_introformat);
  66. $field_grade = new xmldb_field('grade', XMLDB_TYPE_INTEGER, '11', null, XMLDB_NOTNULL, null, '0', 'activity_group');
  67. if (!$dbman->field_exists($table, $field_grade))
  68. $dbman->add_field($table, $field_grade);
  69. $field_timeavailable = new xmldb_field('timeavailable', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'grade');
  70. if (!$dbman->field_exists($table, $field_timeavailable))
  71. $dbman->add_field($table, $field_timeavailable);
  72. $field_timedue = new xmldb_field('timedue', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'timeavailable');
  73. if (!$dbman->field_exists($table, $field_timedue))
  74. $dbman->add_field($table, $field_timedue);
  75. $field_preventlate = new xmldb_field('preventlate', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, null, null, '1', 'timedue');
  76. if (!$dbman->field_exists($table, $field_preventlate))
  77. $dbman->add_field($table, $field_preventlate);
  78. $field_test = new xmldb_field('test', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, '0', 'preventlate');
  79. if (!$dbman->field_exists($table, $field_test))
  80. $dbman->add_field($table, $field_test);
  81. $field_max_experiment = new xmldb_field('max_experiment', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'test');
  82. if (!$dbman->field_exists($table, $field_max_experiment))
  83. $dbman->add_field($table, $field_max_experiment);
  84. if (!$dbman->table_exists($table)) {
  85. $field_id = new xmldb_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE);
  86. $field_time = new xmldb_field('time', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'id');
  87. $field_userid = new xmldb_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'time');
  88. $field_ip = new xmldb_field('ip', XMLDB_TYPE_CHAR, '255', null, null, null, null, 'userid');
  89. $field_course = new xmldb_field('course', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'ip');
  90. $field_cmid = new xmldb_field('cmid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'course');
  91. $field_ilmid = new xmldb_field('ilmid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'cmid');
  92. $field_action = new xmldb_field('action', XMLDB_TYPE_CHAR, '255', null, null, null, null, 'ilmid');
  93. $field_info = new xmldb_field('info', XMLDB_TYPE_TEXT, 'medium', null, null, null, null, 'action');
  94. $field_language = new xmldb_field('language', XMLDB_TYPE_CHAR, '10', null, null, null, null, 'info');
  95. $field_user_agent = new xmldb_field('user_agent', XMLDB_TYPE_TEXT, 'medium', null, null, null, null, 'language');
  96. $field_javascript = new xmldb_field('javascript', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'user_agent');
  97. $field_java = new xmldb_field('java', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'javascript');
  98. $key = new xmldb_key('primary');
  99. $key->set_attributes(XMLDB_KEY_PRIMARY, array('id'), null, null);
  100. $index = new xmldb_index('course');
  101. $index->set_attributes(XMLDB_INDEX_NOTUNIQUE, array('course'));
  102. $table->addField($field_id);
  103. $table->addField($field_time);
  104. $table->addField($field_userid);
  105. $table->addField($field_ip);
  106. $table->addField($field_course);
  107. $table->addField($field_cmid);
  108. $table->addField($field_ilmid);
  109. $table->addField($field_action);
  110. $table->addField($field_info);
  111. $table->addField($field_language);
  112. $table->addField($field_user_agent);
  113. $table->addField($field_javascript);
  114. $table->addField($field_java);
  115. $table->addKey($key);
  116. $table->addIndex($index);
  117. $status = $dbman->create_table($table);
  118. } // if (!$dbman->table_exists($table))
  119. // Now update Moodle table '*_files' related to the iAssign: insert new field 'filearea'
  120. $fs = get_file_storage();
  121. $is_delete = true;
  122. $ilm_path = $CFG->dirroot . "/mod/iassign/ilm/";
  123. // All iAssign 'exercises' must get the label 'exercise'
  124. $exercise_files = $DB->get_records('files', array("component" => "mod_iassign", "filearea" => "activity"));
  125. foreach ($exercise_files as $exercise_file) {
  126. $exercise_file->filearea = "exercise";
  127. $DB->update_record('files', $exercise_file);
  128. }
  129. // All iAssign iLM (usually 'JAR package') must get the label 'activity'
  130. $activity_files = $DB->get_records('files', array("component" => "mod_iassign", "filearea" => "ilm"));
  131. foreach ($activity_files as $activity_file) {
  132. $activity_file->filearea = "activity";
  133. $DB->update_record('files', $activity_file);
  134. }
  135. // iAssign savepoint reached
  136. upgrade_mod_savepoint(true, 2014012100, 'iassign');
  137. } // if ($oldversion < 2014012100)
  138. if ($oldversion < 2017021900) { // update to migrate from 2016021300 to 2017021900 (2.2.00)
  139. // iassign_ilm : id; name; version; description; url; extension; parent; file_jar; file_class; width; height; enable; timemodified; author; timecreated; evaluate
  140. $count_iassign_ilm = $DB->count_records_sql('SELECT COUNT(id) FROM {iassign_ilm}'); // count the number of existing iLM in table '*_iassign_ilm'
  141. if ($count_iassign_ilm>0) { // Insert new iLM: iVProgH5 (package in HTML5 technology)
  142. // Insert an entry in the Moodle table '*_files'
  143. $context = context_system::instance();
  144. $file_ilm = array(
  145. 'userid' => $USER->id, // ID of context
  146. 'contextid' => $context->id, // ID of context
  147. 'component' => 'mod_iassign', // usually = table name
  148. 'filearea' => 'ilm', // in table '*_files' all iAssign exercises will have 'filearea="exercise"' and all iLM must be 'ilm'
  149. 'itemid' => 0,
  150. 'filepath' => '/iassign/ilm/', // any path beginning and ending in /
  151. 'filename' => "ivprog-html/main.html"); // any filename: use the starting point of iVProgH5
  152. // Now update Moodle table '*_files' related to the iAssign: insert new field 'filearea'
  153. $fs = get_file_storage();
  154. $is_delete = true;
  155. $ilm_path = $CFG->dirroot . "/mod/iassign/ilm/";
  156. //TODO iLM_HTML5 : What model to implement to HTML5?
  157. //TODO 1. The first version of iLM HTML5 in '/var/www/html/moodle/mod/iassign/ilm/ilm-nome' and others in '/var/moodledata/filedir/'?
  158. //TODO 2. Inserting new iLM HTML5 by ZIP file => explode it and register in '/var/moodledata/filedir/'?
  159. // Create file using the content: the file information is inserted in the Moodle table '*_files'
  160. // The real file will be registered in Moodle data (default '/var/moodledata/filedir/xx/yy' - 'xxyy' is the first 4 char in '*_files.contenthash')
  161. //TODO Keep this even change the model to not insert iLM HTML5 (need this object to connect with '*_iassign_ilm' bellow)
  162. $file_ilm = $fs->create_file_from_string($file_ilm, file_get_contents($ilm_path . "ivprog-html/main.html"));
  163. if ($file_ilm)
  164. $is_delete &= @unlink($ilm_path . "ivprog-html");
  165. // Insert an entry in iAssign table '*_iassign_ilm'
  166. $newentry = new stdClass();
  167. $newentry->name = 'iVProgH5';
  168. $newentry->url = 'http://www.matematica.br/ivprogh5';
  169. $newentry->version = '0.1.0';
  170. $newentry->description = '{"en":"Visual Interactive Programming on the Internet HTML5","pt_br":"Programação visual interativa na Internet"}';
  171. $newentry->extension = 'ivph';
  172. $newentry->file_jar = 'iVProgH5'; // to JAR this is the '*_files.id' correponding to the iLM storaged in '/var/moodledata/filedir/'
  173. $newentry->file_class = 'ivprog-html/main.html';
  174. $newentry->width = 800;
  175. $newentry->height = 700;
  176. $newentry->enable = 1;
  177. $newentry->timemodified = time();
  178. $newentry->author = $USER->id;
  179. $newentry->timecreated = time();
  180. $newentry->evaluate = 1;
  181. // $DB->insert_records('iassign_ilm', $newentry);
  182. $newentry->id = $DB->insert_record("iassign_ilm", $newentry);
  183. // iAssign savepoint reached
  184. upgrade_mod_savepoint(true, 2017021900, 'iassign');
  185. } // if ($count_iassign_ilm>0)
  186. } // if ($oldversion < 2017021900)
  187. if ($oldversion < 2017120100) { // last one: 2017042800 from 2017/02/19
  188. // Create new field 'type', putting 'Java' if JAR and 'HTML5' if HTML5
  189. // Update fields 'file_jar, file_class' of iLM iVProgH5 (from 'iVProgH5, ivprog-html/main.html' to 'ilm/ivprog-html/, main.html'
  190. //---
  191. // Define new field in iassign table to be added: type varchar(20) in { 'Java' 'HTML5' }
  192. $table = new xmldb_table('iassign_ilm');
  193. $new_field_type = new xmldb_field('type', XMLDB_TYPE_CHAR, '20', null, null, null, null, 'version'); // after field 'version'
  194. if (!$dbman->field_exists($table, $new_field_type))
  195. $dbman->add_field($table, $new_field_type);
  196. //---
  197. // All iAssign iLM (usually 'JAR package') must get the type 'Java'
  198. $list_of_ilm_installed = $DB->get_records('iassign_ilm');
  199. foreach ($list_of_ilm_installed as $ilm_installed) {
  200. $ilm_name = strtolower($ilm_installed->name);
  201. //D echo $ilm_name . " : " . $ilm_installed->file_jar . " : " . $ilm_installed->file_class . " : " . $ilm_installed->extension . "<br/>\n";
  202. if ($ilm_name=="ivprogh5" || $ilm_name=="ifractions" || $ilm_name=="fractions") { // if it is 'iVProgH5' (perhaps 'iFractions' already installed?)
  203. $ilm_installed->type = "HTML5"; // it is HTML5
  204. $file_jar = strtolower($ilm_installed->file_jar);
  205. if ($ilm_name=="ivprogh5" && $file_jar=="ivprogh5") { // fields 'file_jar' and 'file_class' must have: 'ilm/ivprog-html/' and 'main.html'
  206. $ilm_installed->file_jar = "ilm/ivprog-html/"; // iVProgH5 ivprog-html/main.html
  207. $ilm_installed->file_class = "main.html";
  208. }
  209. }
  210. else
  211. $ilm_installed->type = "Java"; // otherwise it is Java
  212. $DB->update_record('iassign_ilm', $ilm_installed);
  213. } // foreach
  214. //---
  215. // Insert in talbe '{iassign_ilm}' the new iLM iFractions version 0.1.2017.11.22
  216. // Table 'iassign_ilm' : id name version type description url extension parent file_jar file_class width height enable timemodified author timecreated evaluate
  217. /*$new_ilm_ifractions['name'] = 'iFractions';
  218. $new_ilm_ifractions['version'] = '0.1.2017.11.22';
  219. $new_ilm_ifractions['type'] = 'HTML5';
  220. $new_ilm_ifractions['description'] = '{"en":"Visual Interactive Fractions Learning","pt_br":"Aprendizagem visual interativa de frações"}';
  221. $new_ilm_ifractions['url'] = 'http://www.matematica.br/ifractions';
  222. $new_ilm_ifractions['extension'] = 'frc';
  223. $new_ilm_ifractions['parent'] = '0';
  224. $new_ilm_ifractions['file_jar'] = 'ilm/ifractions/';
  225. $new_ilm_ifractions['file_class'] = 'index.html';
  226. $new_ilm_ifractions['width'] = '900';
  227. $new_ilm_ifractions['height'] = '600';
  228. $new_ilm_ifractions['enable'] = '1';
  229. $new_ilm_ifractions['timemodified'] = time();
  230. $new_ilm_ifractions['author'] = $USER->id;
  231. $new_ilm_ifractions['timecreated'] = time();
  232. $new_ilm_ifractions['evaluate'] = 1;
  233. $DB->insert_record('iassign_ilm', $new_ilm_ifractions, false); // insert new iLM in the table '{iassign_ilm}';*/
  234. } // if ($oldversion < 2017120101)
  235. if ($oldversion < 2018031000) {
  236. // Verify if exist iLM with the same name
  237. // then, update the version and file_jar
  238. $records = array(
  239. // iGeom 5.9.22
  240. array_combine(
  241. array('name', 'url', 'version', 'type', 'description', 'extension', 'file_jar', 'file_class', 'width', 'height', 'enable', 'timemodified', 'author', 'timecreated', 'evaluate'), array('iGeom', 'http://www.matematica.br/igeom', '5.9.22', 'Java', '{"en":"Interactive Geometry on the Internet","pt_br":"Geometria Interativa na Internet"}', 'geo', 'ilm/iGeom/5.9.22/iGeom.jar', 'IGeomApplet.class', 800, 600, 1, time(), $USER->id, time(), 1)),
  242. // iGraf 4.4.0.10
  243. array_combine(
  244. array('name', 'url', 'version', 'type', 'description', 'extension', 'file_jar', 'file_class', 'width', 'height', 'enable', 'timemodified', 'author', 'timecreated', 'evaluate'), array('iGraf', 'http://www.matematica.br/igraf', '4.4.0.10', 'Java', '{"en":"Interactive Graphic on the Internet","pt_br":"Gráficos Interativos na Internet"}', 'grf', 'ilm/iGraf/4.4.0.10/iGraf.jar', 'igraf.IGraf.class', 840, 600, 1, time(), $USER->id, time(), 1)),
  245. // iComb 0.9.5
  246. array_combine(
  247. array('name', 'url', 'version', 'type', 'description', 'extension', 'file_jar', 'file_class', 'width', 'height', 'enable', 'timemodified', 'author', 'timecreated', 'evaluate'), array('iComb', 'http://www.matematica.br/icomb', '0.9.5', 'Java', '{"en":"Combinatorics Interactive on the Internet","pt_br":"Combinatória Interativa na Internet"}', 'icb,cmb', 'ilm/iComb/0.9.5/iComb.jar', 'icomb.IComb.class', 750, 685, 1, time(), $USER->id, time(), 1)),
  248. // iVProg2 2.1.0
  249. array_combine(
  250. array('name', 'url', 'version', 'type', 'description', 'extension', 'file_jar', 'file_class', 'width', 'height', 'enable', 'timemodified', 'author', 'timecreated', 'evaluate'), array('iVProg2', 'http://www.matematica.br/ivprog2', '2.1.0', 'Java', '{"en":"Visual Interactive Programming on the Internet","pt_br":"Programação visual interativa na Internet"}', 'ivp2', 'ilm/iVProg2/2.1.0/iVProg2.jar', 'usp.ime.line.ivprog.Ilm.class', 800, 700, 1, time(), $USER->id, time(), 1)),
  251. // iTangram2 0.4.6
  252. array_combine(
  253. array('name', 'url', 'version', 'type', 'description', 'extension', 'file_jar', 'file_class', 'width', 'height', 'enable', 'timemodified', 'author', 'timecreated', 'evaluate'),
  254. array('iTangram2', 'http://www.matematica.br/itangram', '0.4.6', 'Java', '{"en":"The Objective of the game is to reproduce the form of the model using all 7 pieces of iTangram","pt_br":"O Objetivo do jogo é reproduzir a forma do modelo usando todas as 7 peças do iTangram"}', 'itg2', 'ilm/iTangram2/0.4.6/iTangram2.jar', 'ilm.line.itangram2.Tangram', 800, 600, 1, time(), $USER->id, time(), 1)),
  255. // iHanoi 3.1.0
  256. array_combine(
  257. array('name', 'url', 'version', 'type', 'description', 'extension', 'file_jar', 'file_class', 'width', 'height', 'enable', 'timemodified', 'author', 'timecreated', 'evaluate'),
  258. array('iHanoi', 'http://www.matematica.br/ihanoi', '3.1.0', 'Java', '{"en":"The Objective to move N discs from stick A to C, following some rule (from the game Towers of Hanoi)","pt_br":"O objetivo é mover N discos da haste A para C, seguindo algumas regras (implementa o jogo Torres de Hanói)"}', 'ihn', 'ilm/iHanoi/3.1.0/iHanoi.jar', 'ihanoi.iHanoi', 730, 450, 1, time(), $USER->id, time(), 1)),
  259. // Risco 2
  260. array_combine(
  261. array('name', 'url', 'version', 'type', 'description', 'extension', 'file_jar', 'file_class', 'width', 'height', 'enable', 'timemodified', 'author', 'timecreated', 'evaluate'),
  262. array('Risko', 'http://risko.pcc.usp.br/', '2.2.23', 'Java', '{"en":"Interactive computational tool for teaching geometry","pt_br":"Ferramenta computacional interativa para o ensino de geometria"}', 'rsk', 'ilm/Risko/2.2.23/Risko.jar', 'RiskoApplet.class', 800, 600, 1, time(), $USER->id, time(), 0)),
  263. // iVProgH5 0.1 - HTML5
  264. array_combine(
  265. array('name', 'url', 'version', 'type', 'description', 'extension', 'file_jar', 'file_class', 'width', 'height', 'enable', 'timemodified', 'author', 'timecreated', 'evaluate'),
  266. array('iVProgH5', 'http://www.matematica.br/ivprogh5', '0.1.0', 'HTML5', '{"en":"Visual Interactive Programming on the Internet HTML5","pt_br":"Programação visual interativa na Internet"}', 'ivph', 'ilm/iVProgH5/0.1.0/ivprog-html/', 'main.html', 800, 600, 1, time(), $USER->id, time(), 1)),
  267. // fractions 0.1.2017.11.22 - HTML5
  268. array_combine(
  269. array('name', 'url', 'version', 'type', 'description', 'extension', 'file_jar', 'file_class', 'width', 'height', 'enable', 'timemodified', 'author', 'timecreated', 'evaluate'),
  270. array('iFractions', 'http://www.matematica.br/ifractions', '0.1.2017.11.22', 'HTML5', '{"en":"Visual Interactive Fractions Learning","pt_br":"Aprendizagem visual interativa de frações"}', 'frc', 'ilm/iFractions/0.1.2017.11.22/ifractions/', 'index.html', 1000, 600, 1, time(), $USER->id, time(), 1))
  271. );
  272. foreach ($records as $record) {
  273. // Verify if there is a iLM register to update it
  274. $iassign_ilm = $DB->get_record('iassign_ilm', array('name' => $record['name'], 'version' => $record['version']));
  275. if ($iassign_ilm) {
  276. // Update file_jar and file_class
  277. $newentry = new stdClass();
  278. $newentry->id = $iassign_ilm->id;
  279. $newentry->file_jar = $record['file_jar'];
  280. $newentry->file_class = $record['file_class'];
  281. $DB->update_record("iassign_ilm", $newentry);
  282. } else {
  283. // If not found a iLM with the same name and version, search a
  284. // different version, to use as parent of new version
  285. $iassign_ilm_parent = $DB->get_record('iassign_ilm', array('name' => $record['name'], 'parent' => 0));
  286. if ($iassign_ilm_parent) {
  287. $record['parent'] = $iassign_ilm_parent->id;
  288. $DB->insert_record('iassign_ilm', $record, false); // insert with parent
  289. } else {
  290. $DB->insert_record('iassign_ilm', $record, false); // insert new iLM in the table '*_iassign_ilm' without a parent
  291. }
  292. }
  293. } // foreach ($records as $record)
  294. } // if ($oldversion < 2018031000)
  295. // log event -----------------------------------------------------
  296. if (class_exists('plugin_manager'))
  297. $pluginman = plugin_manager::instance();
  298. else
  299. $pluginman = core_plugin_manager::instance();
  300. $plugins = $pluginman->get_plugins();
  301. iassign_log::add_log('upgrade', 'version: ' . $plugins['mod']['iassign']->versiondisk);
  302. // log event -----------------------------------------------------
  303. return true;
  304. }