upgrade.php 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706
  1. <?php
  2. /**
  3. * This file keeps track of upgrades to the lams module.
  4. *
  5. * Sometimes, changes between versions involve alterations to database structures and other
  6. * major things that may break installations.
  7. * The upgrade function in this file will attempt to perform all the necessary actions to upgrade
  8. * your older installation to the current version.
  9. * If there's something it cannot do itself, it must tell the Admin what must be done.
  10. * The commands in here will all be database-neutral, using the functions defined in lib/ddllib.php
  11. *
  12. * The iAssign upgrade function "xmldb_iassign_upgrade($oldversion)" is called by './lib/upgradelib.php' (after './admin/index.php')
  13. * The version of each Moodle "plugin" is keeped on {config_plugins} : id , plugin , name , value
  14. *
  15. * Additional explanation about Moodle management of "plugins":
  16. * 1. {modules} is the Moodle table with all installed "plugin" (as "iassign")
  17. * 2. {config_plugins} is the table with the "plugin" version, e.g.
  18. * (id, plugin , name , value) = (1139 , "mod_iassign" , "version" , "2023041000")
  19. *
  20. * - v 1.6.0 2023/04/03
  21. * + Replaced old code treating '$oldversion < 2020120500': before to {iassign_statement} AS ias, ias.id!=ias.file remove {files} and create new with {files}.itemid=ias.id
  22. * + New version is faster, since perform a single query to all {files}, "foreach" {iassign_statement} find correspondent {files} using new "find_2_files(.)"
  23. * - v 1.5.5 2022/01/10
  24. * + Added new version of iVProg 2022_01_13_21_43
  25. * - v 1.5.4 2021/12/23
  26. * + Added new version of iVProg 2021_11_30_22_06
  27. * - v 1.5.2 2020/08/03
  28. * + Fixed 'ALTER TABLE' of 'iassign_submission.grade' from BIGINT(11) to REAL
  29. * + New version of iHanoi 1.0.20200803
  30. * - v 1.5.1 2020/05/28-30
  31. * + Avoid to update one iLM causing colision with other instance of the same iLM
  32. * - v 1.4 2013/09/19
  33. * + Insert general fields for iassign statement (grade, timeavaliable, timedue, preventlate, test, max_experiment).
  34. * + Change index field 'name' in 'iassign_ilm' table to index field 'name,version'.
  35. * - v 1.2 2013/08/30
  36. * + Change 'filearea' for new concept for files.
  37. * + Change path file for ilm, consider version in pathname.
  38. *
  39. * @author Leo^nidas de Oliveira Branda~o
  40. * @author Patricia Alves Rodrigues
  41. * @author Igor Moreira Fe'lix
  42. * @version v 1.6.0 2023/04/03
  43. * @version v 1.5.1 2020/05/28-30
  44. * @version v 1.5 2019/03/13
  45. * @version v 1.4 2013/09/19
  46. * @package mod_iassign_db
  47. * @since 2010/12/21
  48. * @copyright iMath (http://www.matematica.br) and LInE (http://line.ime.usp.br) - Computer Science Dep. of IME-USP (Brazil)
  49. *
  50. * <b>License</b>
  51. * - http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  52. *
  53. * @param $oldversion Number of the "old version" of iAssing (registered in {config_plugins}.
  54. */
  55. require_once $CFG->dirroot . '/mod/iassign/locallib.php';
  56. //DEBUG Since results in 'upgrade' is not presented (only the final situation), you
  57. //DEBUG can use the auxiliary function 'writeContent(.)' to register some information
  58. //DEBUG on the './mod/iassign/ilm_debug/upgrade_aaaa_mm_dd_hh_ss_mm.txt'.
  59. //DEBUG @param: $filetype1 to special indentification (e.g. "student", "log", "sendemail")
  60. //DEBUG @return 1 in case of success; -1 in case do not overwrite
  61. function writeContent ($filetype1, $pathbase, $outputFile, $msgToRegister) {
  62. global $CFG, $GROUP, $WRITEMSG, $OVERWRITE;
  63. $pathbase = $CFG->dirroot . "/mod/iassign/ilm_debug/"; // "/moodle/mod/iassign/ilm_debug/", $CFG->dirroot defined in "./lib/setup.php"
  64. $outputFile = $pathbase . $outputFile;
  65. if (!is_writable($pathbase)) { // TRUE se arquivo existe e pode ser escrito
  66. // Just ignore... You must change the write permission to 'www-data' on './mod/iassign/ilm_debug/'
  67. // print "Erro! Problema de acesso ao servidor! Por favor, avise ao administrador (<tt>$pathbase</tt> nao acessivel para escrita).<br/>"; // . $file_debug . "
  68. // exit(0);
  69. }
  70. // To write: verify if the file does not exists or have permission to overwrite
  71. if (is_file($outputFile)) { // already exist this file
  72. } // if (is_file($outputFile))
  73. if (1==1) { // write/overwrite the file
  74. $fpointer = fopen($outputFile, "w"); // write - if executed, it clear the previou content at this file
  75. if (!$fpointer) {
  76. // $file_debug .= "Erro: nao foi possivel abrir o arquivo (" . $outputFile . ")!<br/>\n";
  77. // it was not possible to open the file '$completfilepath" . $file_name . "'!<br/>\n";
  78. // print "<br/>" . $file_debug . "<br/>\n";
  79. return 0;
  80. }
  81. fwrite($fpointer, $msgToRegister . "\n");
  82. fclose($fpointer);
  83. }
  84. else { } // error
  85. return 1;
  86. } // function writeContent($outputFile, $msgToRegister)
  87. // @calledby ./admin/index.php : provides this call with $oldversion = {config_plugins}.value, it uses $CFG->libdir.'/upgradelib.php'
  88. // @calledby ./lib/upgradelib.php :
  89. // + function upgrade_mod_savepoint($result, $version, $modname, $allowabort=true): 298/2712
  90. // Module upgrade savepoint, marks end of module upgrade blocks. It stores module version, resets upgrade timeout and abort upgrade if user cancels page loading.
  91. // + function upgrade_plugins($type, $startcallback, $endcallback, $verbose): 513/2712,' "$newupgrade_function='xmldb_'.$plugin->fullname.'_upgrade';"
  92. // + function upgrade_plugins_modules($startcallback, $endcallback, $verbose): 674/2712, Find and check all modules and load them up or upgrade them if necessary
  93. function xmldb_iassign_upgrade ($oldversion) {
  94. global $CFG, $DB, $USER;
  95. //DEBUG To be used to register in file ./mod/iassign/ilm_debug/upgrade_AAAA_MM_DD_hh_mm_ss.txt
  96. $msgD = "./mod/iassign/db/upgrade.php: oldversion=" . $oldversion . " upgrade in ./mod/iassign/ilm_debug/upgrade_AAAA_MM_DD_hh_mm_ss.txt\n"; //DEBUG
  97. $msgD .= " - Initial time: " . date('Y_m_d_H_i_s') . "\n"; //DEBUG
  98. $dbman = $DB->get_manager();
  99. // Sequence of updates:
  100. // - 2020070613: structure
  101. // - 2020080300
  102. // - 2020120500
  103. // - 2020122900
  104. // - 2021020700
  105. // - 2021122300: new version iVProg "1.0.20211130"
  106. // - 2022011300: new version iVProg "1.0.20220113"
  107. // - 2023041000: new version iVProg "1.0.20230707", iHanoi "1.0.20230526"
  108. if ($oldversion < 2023041000) { // < 2020070613
  109. $msgD .= "+ " . $oldversion . " < 2020070613: " . "\n" ; //DEBUG to ./mod/iassign/ilm_debug/upgrade_AAAA_MM_DD_hh_mm_ss.txt
  110. $msgD .= " * {iassign_allsubmissions}.previous_grade; insere iLM (iGeom 5.9.22; iHanoi 1.0.20230526; iVProg 1.0.20230504; iFractions 3.1.0)\n"; //DEBUG
  111. $table = new xmldb_table('iassign_submission');
  112. $field = new xmldb_field('previous_grade', XMLDB_TYPE_FLOAT, null, null, null, null, null);
  113. if (!$dbman->field_exists($table, $field)) {
  114. $dbman->add_field($table, $field);
  115. }
  116. $records = array( // iLM adjusted to iAssign 2020/08/03
  117. array_combine( // iGeom 5.9.22
  118. array('name', 'url', 'version', 'type', 'description', 'extension', 'file_jar', 'file_class', 'width', 'height', 'enable', 'timemodified', 'author', 'timecreated', 'evaluate', 'reevaluate'),
  119. array('iGeom', 'http://www.matematica.br/igeom', '5.9.22', 'Java', '{"en":"Interactive Geometry on the Internet","pt_br":"Geometria Interativa na Internet"}', 'geo',
  120. 'ilm/iGeom/5.9.22/iGeom.jar', 'IGeomApplet.class', 800, 600, 1, time(), $USER->id, time(), 1, 0)),
  121. array_combine( // iHanoi 1.0.20230526
  122. array('name', 'url', 'version', 'type', 'description', 'extension', 'file_jar', 'file_class', 'width', 'height', 'enable', 'timemodified', 'author', 'timecreated', 'evaluate', 'reevaluate'),
  123. array('iHanoi', 'http://www.matematica.br/ihanoi', '1.0.20230526', 'HTML5', '{"en":"interactive Tower os Hanoi (by LInE)", "pt_br":"Torres de Hanói (do LInE)"}', 'ihn',
  124. 'ilm/iHanoi/1.0.20230526/ihanoi/', 'index.html', 1100, 500, 1, time(), $USER->id, time(), 1, 0)),
  125. array_combine( // iVProg 1.0.20230504/ - HTML5 - 2020
  126. array('name', 'url', 'version', 'type', 'description', 'extension', 'file_jar', 'file_class', 'width', 'height', 'enable', 'timemodified', 'author', 'timecreated', 'evaluate', 'reevaluate'),
  127. array('iVProg', 'http://www.usp.br/line/ivprog/', '1.0.20230504', 'HTML5', '{"en":"Visual Interactive Programming on the Internet (HTML)","pt_br":"Programação visual interativa na Internet"}',
  128. 'ivph', 'ilm/iVProg/1.0.20230504/ivprog/', 'index.html', 900, 700, 1, time(), $USER->id, time(), 1, 1)),
  129. array_combine( // iFractions 3.1.0 - HTML5
  130. array('name', 'url', 'version', 'type', 'description', 'extension', 'file_jar', 'file_class', 'width', 'height', 'enable', 'timemodified', 'author', 'timecreated', 'evaluate', 'reevaluate'),
  131. array('iFractions', 'http://www.matematica.br/ifractions', '3.1.0', 'HTML5', '{"en":"Interactive Fractions game","pt_br":"Jogo interativa de frações"}', 'frc',
  132. 'ilm/iFractions/3.1.0/ifractions/', 'index.html', 1000, 600, 1, time(), $USER->id, time(), 1, 0))
  133. );
  134. $iassign_ilm = $DB->get_records('iassign_ilm');
  135. $strNot_installed = '';
  136. foreach ($records as $record) { // this version 'iassign_ilm' does not has field 'reevaluate'
  137. $newentry = new stdClass();
  138. $newentry->name = $record['name'];
  139. $newentry->version = $record['version'];
  140. $newentry->type = $record['type'];
  141. $newentry->url = $record['url'];
  142. $newentry->description = $record['description'];
  143. $newentry->extension = $record['extension'];
  144. $newentry->file_jar = $record['file_jar'];
  145. $newentry->file_class = $record['file_class'];
  146. $newentry->width = $record['width'];
  147. $newentry->height = $record['height'];
  148. $newentry->enable = $record['enable'];
  149. $newentry->timemodified = time();
  150. $newentry->author = $USER->id;
  151. $newentry->timecreated = time();
  152. $newentry->evaluate = $record['evaluate'];
  153. $exists = 0;
  154. if ($iassign_ilm) { // Search if there is any iLM of this with this version
  155. $record_type = strtolower($record['type']);
  156. foreach ($iassign_ilm as $iassign) {
  157. if ($iassign->name == $record['name'] && strtolower($iassign->type) == $record_type) {
  158. if ($iassign->version == $record['version']) { // or with the one with the same version
  159. $exists = 1; // iLM found - exit with the last one, same version
  160. $strNot_installed .= "\n" . ' <li>' . $record['name'] . ';' . $record['type'] . ';' . $record['version'] . ' </li>' . "\n";
  161. break;
  162. }
  163. }
  164. }
  165. }
  166. if ($exists == 0) try { // iLM does not exists or it has old version
  167. $DB->insert_record("iassign_ilm", $newentry, false);
  168. $msgD .= " * insert_record('iassign_ilm', newentry...) : " . $record['name'] . ", version=" . $record['version'] . "\n"; //DEBUG
  169. } catch (Exception $e) {
  170. print 'Caught exception: ' . $e->getMessage() . "<br/>\n";
  171. $msgD .= " * Caught exception: " . $e->getMessage() . "\n"; //DEBUG
  172. }
  173. } // foreach ($records as $record)
  174. if ($strNot_installed != '') { // ATTENTION: this implies that Moodle administrator updated this iLM, please verify if it is really the current one.
  175. // 'There already exists this iLM (with same type and version), then the current version on iAssign was not installed:'
  176. print '<div class="alert alert-warning alert-block fade in" role="alert" data-aria-autofocus="true" tabindex="0" >' . "\n";
  177. print get_string('upgrade_alert_exists', 'iassign'); // iLM previouly existent
  178. print ' <ul style="margin-top: 1rem;">' . "\n";
  179. print $strNot_installed;
  180. print ' </ul>' . "\n";
  181. print '</div>' . "\n";
  182. }
  183. // Verify if each iLM previously installed is present in fresh new iAssign. This does not means problem, perhaps the admin installed a particular iLM.
  184. $strNot_found = '';
  185. if ($iassign_ilm) { // exists iLM ($DB->get_records('iassign_ilm'))
  186. foreach ($iassign_ilm as $iassign) {
  187. $found = false;
  188. foreach ($records as $record) {
  189. if ($iassign->name == $record['name']) {
  190. $found = true;
  191. break;
  192. }
  193. }
  194. if (!$found) {
  195. $strNot_found .= '<li>' . $iassign->name . ' - <a href="' . $iassign->url . '" target="_blank">' . $iassign->url . '</a></li>' . "\n";
  196. $updateentry = new stdClass();
  197. $updateentry->id = $iassign->id;
  198. $updateentry->enable = 0;
  199. $updateentry->timemodified = time();
  200. $DB->update_record("iassign_ilm", $updateentry); // insert new iLM
  201. $msgD .= " * update_record('iassign_ilm', updateentry): " . $iassign->id . ", " . $iassign->name . ", enable:=0\n"; //DEBUG
  202. }
  203. } // foreach ($iassign_ilm as $iassign)
  204. } // if ($iassign_ilm)
  205. if ($strNot_found != '') {
  206. // The iLM update was completed successfully. However, it was detected that some of your iLM previously installed are not (any more) available on the current distribution of iAssign:
  207. print '<div class="alert alert-warning alert-block fade in" role="alert" data-aria-autofocus="true" tabindex="0" >' . "\n";
  208. print get_string('upgrade_alert_iMA_msg', 'iassign'); // Updated but some previous iLM installed are not available in fresh iAssign
  209. print '<ul style="margin-top: 1rem;">' . "\n";
  210. print $strNot_found;
  211. print '</ul>' . "\n";
  212. print get_string('upgrade_alert_iMA_solution_pt1', 'iassign');
  213. print '<a href="'.new moodle_url('/admin/settings.php?section=modsettingiassign').'">' . get_string('upgrade_alert_iMA_solution_pt2', 'iassign') . '</a>.' . "\n";
  214. print '</div>' . "\n";
  215. }
  216. } // if ($oldversion < 2023041000) { // < 2020070613
  217. if ($oldversion < 2020070613) {
  218. $msgD .= "+ " . $oldversion . " < 2020070613: " . "\n"; //DEBUG to ./mod/iassign/ilm_debug/upgrade_AAAA_MM_DD_hh_mm_ss.txt
  219. $msgD .= " * {iassign_ilm}.reevaluate\n"; //DEBUG
  220. $table = new xmldb_table('iassign_ilm');
  221. $field = new xmldb_field('reevaluate');
  222. $field->set_attributes(XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', null, null, null);
  223. if (!$dbman->field_exists($table, $field)) { // if 'iassign_ilm.reevaluate' does not exist, then create this field
  224. $dbman->add_field($table, $field);
  225. }
  226. $msgD .= " * {iassign_ilm}.id, {iassign_ilm}.version, {iassign_ilm}.name\n"; //DEBUG
  227. $iassign_ilm = $DB->get_records('iassign_ilm');
  228. foreach ($iassign_ilm as $iassign) { // If already installed iVProg/JS or iHanoi/JS set it with re-evaluate feature
  229. $msgD .= " * " . $iassign->id . ", " . $iassign->version . ", " . $iassign->name . "\n"; //DEBUG
  230. if ($iassign->type == 'HTML5' && ($iassign->name == 'iVProg' || $iassign->name == 'iHanoi')) {
  231. $updateentry = new stdClass();
  232. $updateentry->id = $iassign->id;
  233. $updateentry->reevaluate = 1;
  234. $updateentry->timemodified = time();
  235. $answerbd = $DB->update_record("iassign_ilm", $updateentry);
  236. $msgD .= " - - update {iassign_ilm}.reevaluate := 1 -> answerbd=" . $answerbd . "\n"; //DEBUG
  237. break;
  238. }
  239. }
  240. } // if ($oldversion < 2020070613)
  241. if ($oldversion < 2020080300) { // new iHanoi
  242. $msgD .= "+ " . $oldversion . " < 2023052600: " . "\n"; //DEBUG to ./mod/iassign/ilm_debug/upgrade_AAAA_MM_DD_hh_mm_ss.txt
  243. $strNot_installed = '';
  244. // iassign_submission . grade : from 'BIGINT(11)' to 'real'
  245. if ($dbman->field_exists('iassign', 'grade')) {
  246. $sql = 'ALTER TABLE {iassign} CHANGE grade grade FLOAT NOT NULL DEFAULT 0.0';
  247. $msgD .= " * before execute " . $sql . "\n"; //DEBUG
  248. $DB->execute($sql);
  249. $msgD .= " * after OK \n"; //DEBUG
  250. }
  251. if ($dbman->field_exists('iassign_statement', 'grade')) {
  252. $sql = 'ALTER TABLE {iassign_statement} CHANGE grade grade FLOAT NOT NULL DEFAULT 0.0';
  253. $msgD .= " * before execute " . $sql . "\n"; //DEBUG
  254. $DB->execute($sql);
  255. $msgD .= " * after OK \n"; //DEBUG
  256. }
  257. if ($dbman->field_exists('iassign_submission', 'grade')) {
  258. $sql = 'ALTER TABLE {iassign_submission} CHANGE grade grade FLOAT NOT NULL DEFAULT 0.0';
  259. $msgD .= " * before execute " . $sql . "\n"; //DEBUG
  260. $DB->execute($sql);
  261. $msgD .= " * after OK \n"; //DEBUG
  262. }
  263. if ($dbman->field_exists('iassign_submission', 'previous_grade')) {
  264. // $sql = 'ALTER TABLE {iassign_submission} CHANGE previous_grade previous_grade REAL NOT NULL DEFAULT 0.0'; // Invalid use of NULL value
  265. $sql = 'ALTER TABLE {iassign_submission} CHANGE previous_grade previous_grade FLOAT DEFAULT 0.0';
  266. $msgD .= " * before execute " . $sql . "\n"; //DEBUG
  267. $DB->execute($sql);
  268. $msgD .= " * after OK \n"; //DEBUG
  269. }
  270. // Update iHanoi - but the "if ($oldversion < 2020070613)" must had inserted it ("iHanoi 1.0.20230526")
  271. $records = array(
  272. array_combine( // iHanoi 1.0.20230526
  273. array('name', 'url', 'version', 'type', 'description',
  274. 'extension', 'file_jar', 'file_class', 'width', 'height',
  275. 'enable', 'timemodified', 'evaluate', 'reevaluate', 'author', 'timecreated'),
  276. array('iHanoi', 'http://www.matematica.br/ihanoi', '1.0.20230526', 'HTML5', '{"en":"interactive Tower os Hanoi (by LInE)", "pt_br":"Torres de Hanói (do LInE)"}',
  277. 'ihn', 'ilm/iHanoi/1.0.20230526/ihanoi/', 'index.html', 1100, 500,
  278. 1, time(), 1, 1, $USER->id, time()))
  279. );
  280. $iassign_ilm = $DB->get_records('iassign_ilm');
  281. foreach ($records as $record) { // For each iLM in the current version of iAssign
  282. $newentry = new stdClass();
  283. $newentry->name = $record['name'];
  284. $newentry->url = $record['url'];
  285. $newentry->version = $record['version'];
  286. $newentry->type = $record['type'];
  287. $newentry->description = $record['description'];
  288. $newentry->extension = $record['extension'];
  289. $newentry->file_jar = $record['file_jar'];
  290. $newentry->file_class = $record['file_class'];
  291. $newentry->width = $record['width'];
  292. $newentry->height = $record['height'];
  293. $newentry->enable = $record['enable'];
  294. $newentry->timemodified = time();
  295. $newentry->evaluate = $record['evaluate'];
  296. $newentry->reevaluate = $record['reevaluate'];
  297. $newentry->author = $USER->id;
  298. $newentry->timecreated = time();
  299. $exists = 0;
  300. $last_id = -1;
  301. if ($iassign_ilm) { // Search if there is any previous installed iLM that is also in the current version of iAssign
  302. $record_type = strtolower($record['type']);
  303. foreach ($iassign_ilm as $iassign) {
  304. if ($iassign->name == $record['name'] && strtolower($iassign->type) == $record_type) {
  305. if ($iassign->id > $last_id)
  306. $last_id = $iassign->id; // last ID => last version (hopefully)
  307. if ($iassign->version == $record['version']) { // or with the one with the same version
  308. $exists = 1; // iLM found - exit with the last one, same version
  309. $strNot_installed .= "\n" . ' <li>' . $record['name'] . ';' . $record['type'] . ';' . $record['version'] . ' </li>' . "\n";
  310. break;
  311. }
  312. }
  313. }
  314. }
  315. if ($exists == 0) { // iLM does not exists or it has old version
  316. $newentry->parent = $record['parent'];
  317. try {
  318. $DB->insert_record("iassign_ilm", $newentry, false);
  319. $msgD .= " * insert_record iassign_ilm iHanoi 1.0.20230526 \n"; //DEBUG
  320. } catch (Exception $er) {
  321. $msgD .= " * Error insert_record iassign_ilm iHanoi 1.0.20230526 " . $er->getMessage() . "\n"; //DEBUG
  322. }
  323. }
  324. } // foreach ($records as $record)
  325. if ($strNot_installed != '') {
  326. print '<div class="alert alert-warning alert-block fade in " role="alert" data-aria-autofocus="true" tabindex="0" >' . "\n";
  327. print get_string('upgrade_alert_exists', 'iassign'); // iLM previouly existent
  328. print ' <ul style="margin-top: 1rem;">' . "\n";
  329. print $strNot_installed;
  330. print ' </ul>' . "\n";
  331. print '</div>' . "\n";
  332. }
  333. // iassign_ilm: atualizou iHanoi existente, mas nao era isso! Deveria ter inserido novo!
  334. // id name version type ... parent file_jar file_class width height ... evaluate reevaluate
  335. // 53 iHanoi 2 HTML5 ... 0 ilm/iHanoi/2/ihanoi/ index.html 1100 700 ... 1 0
  336. $iassign_ilm = $DB->get_records('iassign_ilm');
  337. foreach ($iassign_ilm as $iassign) { // for iLM iHanoi update the new field 'reevaluate' as 1
  338. if ($iassign->name == 'iHanoi' && $iassign->type == 'HTML5' && $iassign->reevaluate!=1) {
  339. $updateentry = new stdClass();
  340. $updateentry->id = $iassign->id;
  341. $updateentry->reevaluate = 1;
  342. $updateentry->timemodified = time();
  343. $DB->update_record("iassign_ilm", $updateentry);
  344. $msgD .= " * update_record('iassign_ilm'...) iHanoi reevaluate:=1\n"; //DEBUG
  345. break;
  346. }
  347. }
  348. // iAssign savepoint reached.
  349. upgrade_mod_savepoint(true, 2020080300, 'iassign');
  350. } // if ($oldversion < 2020080300)
  351. // Considering ias as {iassign_statement}, create new ias.filesid (initially with ias.file)
  352. // Fix {files}.itemid := {iassign_statement}.id and {iassign_statement}.filesid := {files}.id
  353. // New update from 2023/04/06 (old one was first released in 2020/11/24 with a smaller differences)
  354. if ($oldversion < 2020120500) {
  355. $msgD .= "+ " . $oldversion . " < 2020120500: " . "\n"; //DEBUG to ./mod/iassign/ilm_debug/upgrade_AAAA_MM_DD_hh_mm_ss.txt
  356. // Adding field iassing_statement.filesid
  357. $table = new xmldb_table('iassign_statement');
  358. $field_filesid = new xmldb_field('filesid', XMLDB_TYPE_CHAR, '255', null, null, null, null, null);
  359. if (!$dbman->field_exists($table, $field_filesid)) {
  360. $dbman->add_field($table, $field_filesid);
  361. // Updating all registers from {iassing_statement}.filesid
  362. // Current version (2020 on) is different: {files}.itemid={iassign_statement}.id and {iassign_statement}.filesid={file}.id
  363. $msgD .= " * execute('UPDATE {iassign_statement} SET filesid = file'\n"; //DEBUG
  364. $answerbd = $DB->execute("UPDATE {iassign_statement} SET filesid = file");
  365. if (!$answerbd)
  366. $msgD .= " * ERROR execute('UPDATE {iassign_statement} SET filesid = file'\n"; //DEBUG
  367. }
  368. // Update file_jar field: allow 2 iLM with the same path...
  369. try {
  370. $sql = "ALTER TABLE {iassign_ilm} DROP INDEX {iaima_fil_uix}";
  371. $answerbd = $DB->execute($sql); // remove "UNIQUE KEY *_iaima_fil_uix (file_jar),"
  372. $msgD .= " * execute " . $sql . "\n"; //DEBUG
  373. } catch (Exception $er) {
  374. $msgD .= " * ERROR execute " . $sql . ": " . $er->getMessage() . "\n"; //DEBUG
  375. }
  376. // In this point {{iassign_statement} already has field 'filesid': see above "UPDATE {iassign_statement} SET filesid = file"
  377. // Prepare to find all {files} associated to a single iAssign {iassign} using {modules}, {course_modules}, {context}, {files}, {iassign}
  378. // ATTENTION: it is very important to use {files}.id as the first column of this SELECT statement (since it must be a unique value)
  379. $sql_list = "{files}.id AS files_id, {course_modules}.course, {course_modules}.id, {context}.instanceid, {context}.id AS contextid, " .
  380. "{course_modules}.instance, {iassign}.id AS iaid, {files}.itemid, " .
  381. "{iassign_statement}.file, {iassign_statement}.filesid, {files}.author, {files}.timecreated, " .
  382. "{files}.filename, {iassign}.name AS ianame, {iassign_statement}.file AS iasfile, {iassign_statement}.id AS iasid, " .
  383. "{iassign_statement}.name AS iasname, {iassign_statement}.timecreated";
  384. $sql_from = "{modules}, {course_modules}, {context}, {files}, {iassign}, {iassign_statement}";
  385. $sql_where = "{modules}.name='iassign' AND {modules}.id={course_modules}.module AND {course_modules}.id = {context}.instanceid AND " .
  386. "{course_modules}.instance = {iassign}.id AND {context}.id={files}.contextid AND {files}.component='mod_iassign' AND " .
  387. "{iassign}.id={iassign_statement}.iassignid AND ({files}.itemid={iassign_statement}.file OR {files}.itemid={iassign_statement}.id)";
  388. // "SELECT " . $dist . " " . $campos . " FROM " . $table . " WHERE " . $where . $compl
  389. //./lib/dml/moodle_database.php : public abstract function get_records_sql($sql, array $params=null, $limitfrom=0, $limitnum=0)
  390. // ATTENTION! The first column of this SELECT statement must be a unique value (usually the 'id' field), for this reason it necessary
  391. // $sql_list starts with {files}.id (that is the unique value from all returned)
  392. $iassign_files_contexts_list = $DB->get_records_sql("SELECT " . $sql_list . " FROM " . $sql_from . " WHERE " . $sql_where); // versao para 'upgrade.php'
  393. $msgD .= " * SELECT " . $sql_list . " FROM " . $sql_from . "\n WHERE " . $sql_where . "\n"; //DEBUG
  394. $msgD .= " * #iassign_files_contexts_list = " . count($iassign_files_contexts_list) . "\n"; //DEBUG
  395. $ii = 0;
  396. foreach ($iassign_files_contexts_list as $iassign_statement_activity_item) { // all {iassign_statement}/{files}
  397. if ($iassign_statement_activity_item->filename=='.') { // if second {files} - directory/path
  398. $one_files = $iassign_statement_activity_item; // just to produce a more readable code...
  399. if ($one_files->itemid != $iassign_statement_activity_item->iasid) {
  400. // {files}.itemid != {iassign_statement}.id => UPDATE {files} with itemid := {iassign_statement}.id
  401. $newentry = new stdClass();
  402. $newentry->id = $one_files->files_id; // set {files}.id
  403. $newentry->itemid = $iassign_statement_activity_item->iasid; // update {files}.itemid := {iassign_statement}.id
  404. $DB->update_record("files", $newentry); // update {files}
  405. $msgD .= " * update " . $one_files->itemid . "={files}.itemid := {iassign_statement}.id = " . $iassign_statement_activity_item->iasid . " - {files}.id=" . $one_files->files_id . "\n"; //DEBUG
  406. }
  407. }
  408. else {
  409. $one_files = $iassign_statement_activity_item; // just to produce a more readable code...
  410. if ($iassign_statement_activity_item->filesid) $msgiasfilesid = $iassign_statement_activity_item->filesid; else $msgiasfilesid = "&lt;&gt;"; //DEBUG
  411. if (!$iassign_statement_activity_item->filesid || $iassign_statement_activity_item->filesid != $one_files->files_id) { // {iassign_statement}.filesid not defined
  412. // {iassign_statement}.filesid != {files}.id => UPDATE {iassign_statement}.filesid := {files}.id
  413. $newentry = new stdClass();
  414. $newentry->id = $iassign_statement_activity_item->iasid; // set {iassign_statement}.id
  415. $newentry->filesid = $one_files->files_id; // update {iassign_statement}.filesid := {files}.id
  416. $DB->update_record("iassign_statement", $newentry); // update {iassign_statement}
  417. $msgD .= " * update " . $msgiasfilesid . "={iassign_statement}.filesid := {files}.id=" . $one_files->files_id . " - ias.id=" . $iassign_statement_activity_item->iasid . "\n"; //DEBUG
  418. }
  419. if ($one_files->itemid != $iassign_statement_activity_item->iasid) {
  420. // {files}.itemid != {iassign_statement}.id => UPDATE {files} with itemid := {iassign_statement}.id
  421. $newentry = new stdClass();
  422. $newentry->id = $one_files->files_id; // set {files}.id
  423. $newentry->itemid = $iassign_statement_activity_item->iasid; // update {files}.itemid := {iassign_statement}.id
  424. $DB->update_record("files", $newentry); // update {files}
  425. $msgD .= " * update " . $one_files->itemid . "={files}.itemid := {iassign_statement}.id=" . $iassign_statement_activity_item->iasid . " - {files}.id=" . $one_files->files_id . "\n"; //DEBUG
  426. }
  427. }
  428. $ii++; // count...
  429. } // foreach ($ias_files as $iassign_statement_activity_item)
  430. } // if ($oldversion < 2020120500)
  431. /// @Igor - create the new table {iassign_allsubmissions}
  432. if ($oldversion < 2020122900) { // < 2020122900
  433. $msgD .= "+ " . $oldversion . " < 2020122900: " . "\n"; //DEBUG to ./mod/iassign/ilm_debug/upgrade_AAAA_MM_DD_hh_mm_ss.txt
  434. // Define table iassign_allsubmissions to be created.
  435. $table = new xmldb_table('iassign_allsubmissions');
  436. // Adding fields to table iassign_allsubmissions.
  437. $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
  438. $table->add_field('iassign_statementid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
  439. $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
  440. $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '16', null, XMLDB_NOTNULL, null, null);
  441. $table->add_field('grade', XMLDB_TYPE_FLOAT, null, null, null, null, null, null);
  442. $table->add_field('answer', XMLDB_TYPE_TEXT, 'long', null, null, null, null, null);
  443. // Adding keys to table iassign_allsubmissions.
  444. $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
  445. // Conditionally launch create table for iassign_allsubmissions.
  446. if (!$dbman->table_exists($table)) {
  447. $dbman->create_table($table);
  448. $msgD .= " * {iassign_allsubmissions}.{id, iassign_statementid, userid, timecreated, grade, answer}\n"; //DEBUG
  449. }
  450. // Adding fields to table iassign_ilm:
  451. $table = new xmldb_table('iassign_ilm');
  452. $field_editingbehavior = new xmldb_field('editingbehavior', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', null);
  453. if (!$dbman->field_exists($table, $field_editingbehavior)) $dbman->add_field($table, $field_editingbehavior);
  454. $field_submissionbehavior = new xmldb_field('submissionbehavior', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', null);
  455. if (!$dbman->field_exists($table, $field_submissionbehavior)) $dbman->add_field($table, $field_submissionbehavior);
  456. $field_action_buttons = new xmldb_field('action_buttons', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '1', null);
  457. if (!$dbman->field_exists($table, $field_action_buttons)) $dbman->add_field($table, $field_action_buttons);
  458. $msgD .= " * {iassign_ilm}.{editingbehavior, submissionbehavior, action_buttons}\n"; //DEBUG
  459. // Adding field to table iassign_statement:
  460. $table = new xmldb_table('iassign_statement');
  461. $field_store_all_submissions = new xmldb_field('store_all_submissions', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', null);
  462. if (!$dbman->field_exists($table, $field_store_all_submissions)) $dbman->add_field($table, $field_store_all_submissions);
  463. $msgD .= " * {iassign_statement}.store_all_submissions - change ias.editingbehavior,submissionbehavior de iHanoiJS, iGeomJava, iVProgJS, iFractions, Risko\n"; //DEBUG
  464. // Update new fields for previous installed iLM:
  465. $iassign_ilm = $DB->get_records('iassign_ilm');
  466. foreach ($iassign_ilm as $iassign) {
  467. $updateentry = new stdClass();
  468. $updateentry->id = $iassign->id;
  469. $change = 0; // any change to update?
  470. if (($iassign->name == 'iHanoi' && $iassign->type == 'HTML5')) {
  471. $change = 1;
  472. $updateentry->editingbehavior = 0; // editingbehavior=1 => iLM auto-evaluation remains working over a solution sent by the student (iGeom not; iVProg yes)
  473. $updateentry->submissionbehavior = 0; // 0 => 'After submission, this iLM remains on the same page'; 1 => 'this iLM changes the current page
  474. }
  475. else
  476. if (($iassign->name == 'iGeom' && $iassign->type == 'Java')) {
  477. $updateentry->editingbehavior = 0; $change = 1;
  478. $updateentry->submissionbehavior = 0;
  479. }
  480. else
  481. if (($iassign->name == 'iVProg' && $iassign->type == 'HTML5')) {
  482. $updateentry->editingbehavior = 1; $change = 1;
  483. $updateentry->submissionbehavior = 0;
  484. }
  485. else
  486. if (($iassign->name == 'iFractions' && $iassign->type == 'HTML5')) {
  487. $updateentry->editingbehavior = 0; $change = 1;
  488. $updateentry->submissionbehavior = 1;
  489. }
  490. else
  491. if (($iassign->name == 'Risko' && $iassign->type == 'Java')) {
  492. $updateentry->editingbehavior = 1; $change = 1;
  493. $updateentry->submissionbehavior = 0;
  494. }
  495. if ($change==1) {
  496. $updateentry->timemodified = time();
  497. $DB->update_record("iassign_ilm", $updateentry);
  498. }
  499. }
  500. //x // Add iassign_allsubmissions table - not necessary, {iassign_allsubmissions}.{id, iassign_statementid, userid, timecreated, grade, answer} already created
  501. //x $table = new xmldb_table('iassign_allsubmissions');
  502. //x if (!$dbman->table_exists($table)) {
  503. //x $field1 = new xmldb_field('id'); $field1->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null);
  504. //x $field2 = new xmldb_field('iassign_statementid'); $field2->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null);
  505. //x $field3 = new xmldb_field('userid'); $field3->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null);
  506. //x $field4 = new xmldb_field('timecreated'); $field4->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null);
  507. //x $field5 = new xmldb_field('grade'); $field5->set_attributes(XMLDB_TYPE_FLOAT, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null);
  508. //x $field6 = new xmldb_field('answer'); $field6->set_attributes(XMLDB_TYPE_TEXT, 'long', null, null, null, null, 'type');
  509. //x $table->addIndex($field1); $table->addField($field2); $table->addField($field3);
  510. //x $table->addField($field4); $table->addField($field5); $table->addField($field6);
  511. //x $dbman->create_table($table);
  512. //x } // if (!$dbman->table_exists($table))
  513. // Update file_jar field: allow 2 iLM with the same path...
  514. try {
  515. $DB->execute("ALTER TABLE {iassign_ilm} DROP INDEX {iassilm_fil_uix}");
  516. $msgD .= " * ALTER TABLE {iassign_ilm} DROP INDEX {iassilm_fil_uix} \n"; //DEBUG
  517. } catch (Exception $er) {
  518. $msgD .= " * ERROR ALTER TABLE {iassign_ilm} DROP INDEX {iassilm_fil_uix}: " . $er->getMessage() . "\n"; //DEBUG
  519. }
  520. // Create temporary area in MoodleData: $CFG->dataroot/temp/iassign_files //TODO: not using... ***
  521. $tempfilespath = $CFG->dataroot . DIRECTORY_SEPARATOR . 'temp';
  522. if (!file_exists($tempfilespath)) {
  523. mkdir($tempfilespath, 0777, true);
  524. $msgD .= " * mkdir " . $tempfilespath . "\n"; //DEBUG
  525. }
  526. $iassignfilespath = $tempfilespath . DIRECTORY_SEPARATOR . 'iassign_files';
  527. if (!file_exists($iassignfilespath)) {
  528. mkdir($iassignfilespath, 0777, true);
  529. $msgD .= " * mkdir " . $iassignfilespath . "\n"; //DEBUG
  530. }
  531. } // if ($oldversion < 2020122900)
  532. if ($oldversion < 2021020700) {
  533. $msgD .= "+ " . $oldversion . " < 2021020700: " . "\n"; //DEBUG to ./mod/iassign/ilm_debug/upgrade_AAAA_MM_DD_hh_mm_ss.txt
  534. // Update SAW iVProg to inform reevalute is enabled:
  535. // SELECT id FROM s_iassign_ilm WHERE type='HTML5' AND name='iVProg'
  536. $ivprogs = $DB->get_records('iassign_ilm', array('name' => 'iVProg', 'type' => 'HTML5'));
  537. foreach ($ivprogs as $one_ivprog) {
  538. $ivprogid = $one_ivprog->id;
  539. $updateentry = new stdClass();
  540. $updateentry->id = $ivprogid; // {iassign_ilm}.id such that {iassign_ilm}.name='iVProg' and {iassign_ilm}.type='HTML5'
  541. $updateentry->reevaluate = 1;
  542. $updateentry->timemodified = time();
  543. $DB->update_record("iassign_ilm", $updateentry); // update {iassign_ilm}.id=57 with 'reevaluate = 1'
  544. $msgD .= " * update_record 'iassign_ilm' id=" . $ivprogid . ", reevaluate:=1\n"; //DEBUG
  545. }
  546. } // if ($oldversion < 2021020700)
  547. if ($oldversion < 2021122300) { // 2021/12/23
  548. $msgD .= "+ " . $oldversion . " < 2021122300: " . "\n"; //DEBUG to ./mod/iassign/ilm_debug/upgrade_AAAA_MM_DD_hh_mm_ss.txt
  549. $strNot_installed = '';
  550. // Update iVProg JS to the latest version (ilm/iVProg/1.0.20230504/ivprog/)
  551. $records = array(
  552. array_combine( // iVProg 1.0.20230504/ - HTML5 - 2021/12/30
  553. array('name', 'url', 'version', 'type', 'description', 'extension', 'file_jar', 'file_class', 'width', 'height', 'enable', 'timemodified', 'author', 'timecreated', 'evaluate', 'reevaluate'),
  554. array('iVProg', 'http://www.usp.br/line/ivprog/', '1.0.20230504', 'HTML5', '{"en":"Visual Interactive Programming on the Internet (HTML)","pt_br":"Programação visual interativa na Internet"}',
  555. 'ivph', 'ilm/iVProg/1.0.20230504/ivprog/', 'index.html', 900, 700, 1, time(), $USER->id, time(), 1, 1))
  556. );
  557. $iassign_ilm = $DB->get_records('iassign_ilm');
  558. foreach ($records as $record) { // For each iLM in the current version of iAssign
  559. $newentry = new stdClass();
  560. $newentry->name = $record['name'];
  561. $newentry->url = $record['url'];
  562. $newentry->version = $record['version'];
  563. $newentry->type = $record['type'];
  564. $newentry->description = $record['description'];
  565. $newentry->extension = $record['extension'];
  566. $newentry->file_jar = $record['file_jar'];
  567. $newentry->file_class = $record['file_class'];
  568. $newentry->width = $record['width'];
  569. $newentry->height = $record['height'];
  570. $newentry->enable = $record['enable'];
  571. $newentry->timemodified = time();
  572. $newentry->author = $USER->id;
  573. $newentry->timecreated = time();
  574. $newentry->evaluate = $record['evaluate']; // 1
  575. $newentry->reevaluate = $record['reevaluate']; // 1
  576. $exists = -1;
  577. $last_id = -1; // to be used to get the last version of the same iLM (will be its 'parent')
  578. if ($iassign_ilm) { // Search if there is any previous installed iLM that is also in the current version of iAssign
  579. $record_type = strtolower($record['type']);
  580. foreach ($iassign_ilm as $iassign) {
  581. if ($iassign->name == $record['name'] && strtolower($iassign->type) == $record_type) {
  582. if ($iassign->id > $last_id)
  583. $last_id = $iassign->id; // last ID => last version (hopefully)
  584. if ($iassign->version == $record['version']) { // or with the one with the same version
  585. $exists = $iassign->id; // iLM found - exit with the last one, same version
  586. $strNot_installed .= "\n" . ' <li>' . $record['name'] . ';' . $record['type'] . ';' . $record['version'] . ' </li>' . "\n";
  587. break;
  588. }
  589. }
  590. }
  591. $newentry->parent = $last_id; // parent is the last iLM found (corresponde to the smallest ID)
  592. }
  593. else
  594. $newentry->parent = -1; // first iLM of this one
  595. if ($exists == -1) { // iLM does not exists or it has old version
  596. // $newentry->parent = $record['parent'];
  597. $answerbd = $DB->insert_record("iassign_ilm", $newentry, false);
  598. if (!$answerbd) $msgD .= " * ERROR insert_record('iassign_ilm', newentry,...): " . $newentry->name . "\n"; //DEBUG
  599. else $msgD .= " * insert_record('iassign_ilm', newentry,...): " . $newentry->name . "\n"; //DEBUG
  600. }
  601. else $msgD .= " * 'iassign_ilm' " . $record['name'] . " already exists with id=" . $last_id . "!\n"; //DEBUG
  602. } // foreach ($records as $record)
  603. if ($strNot_installed != '') {
  604. print '<div class="alert alert-warning alert-block fade in " role="alert" data-aria-autofocus="true" tabindex="0" >' . "\n";
  605. print get_string('upgrade_alert_exists', 'iassign'); // iLM previouly existent
  606. print ' <ul style="margin-top: 1rem;">' . "\n";
  607. print $strNot_installed;
  608. print ' </ul>' . "\n";
  609. print '</div>' . "\n";
  610. }
  611. // iassign_ilm: atualizou iHanoi existente, mas nao era isso! Deveria ter inserido novo!
  612. // iassign_ilm: update iHanoi from
  613. // id name version type ... parent file_jar file_class width height ... evaluate reevaluate
  614. // 53 iHanoi 2 HTML5 ... 0 ilm/iHanoi/1.0.20200803/ihanoi/ index.html 1100 700 ... 1 0 ou
  615. // 53 iHanoi 2 HTML5 ... 0 ilm/iHanoi/2/ihanoi/ index.html 1100 700 ... 1 0
  616. $iassign_ilm = $DB->get_records('iassign_ilm');
  617. foreach ($iassign_ilm as $iassign) { // for iLM iHanoi update the new field 'reevaluate' as 1
  618. if ($iassign->name == 'iHanoi' && $iassign->type == 'HTML5' && $iassign->reevaluate!=1) {
  619. $updateentry = new stdClass();
  620. $updateentry->id = $iassign->id;
  621. $updateentry->reevaluate = 1; // new iHanoi allow teacher to re-evaluate (all of them at once)
  622. $updateentry->timemodified = time();
  623. $DB->update_record("iassign_ilm", $updateentry);
  624. $msgD .= " * update_record 'iassign_ilm'iHanoi HTML id=" . $iassign->id . "\n"; //DEBUG
  625. break;
  626. }
  627. }
  628. // iAssign savepoint reached.
  629. upgrade_mod_savepoint(true, 2021122300, 'iassign');
  630. } // if ($oldversion < 2021122300)
  631. //DEBUG to ./mod/iassign/ilm_debug/upgrade_AAAA_MM_DD_hh_mm_ss.txt
  632. try { // register in ./mod/iassign/ilm_debug/
  633. $timeWrite = date('Y_m_d_H_i_s'); // Year_Month_Day_Hour_Minutes_Seconds
  634. $msgD .= " - Final time: " . $timeWrite . "\n"; //DEBUG
  635. $filenamewrite = "upgrade_" . $timeWrite . ".txt";
  636. $resp = writeContent("", "", $filenamewrite, $msgD); // ($filetype1, $pathbase, $outputFile, $msgToRegister)
  637. } catch (Exception $er) {
  638. // print 'Erro: upgrade ' . $er->getMessage() . "\n";
  639. }
  640. // log event -----------------------------------------------------
  641. if (class_exists('plugin_manager'))
  642. $pluginman = plugin_manager::instance();
  643. else
  644. $pluginman = core_plugin_manager::instance();
  645. $plugins = $pluginman->get_plugins();
  646. iassign_log::add_log('upgrade', 'version: ' . $plugins['mod']['iassign']->versiondisk);
  647. // log event -----------------------------------------------------
  648. return true;
  649. } // function xmldb_iassign_upgrade($oldversion)