upgrade.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * This file keeps track of upgrades to the nasatlx module
  4. *
  5. * Sometimes, changes between versions involve alterations to database
  6. * structures and other major things that may break installations. The upgrade
  7. * function in this file will attempt to perform all the necessary actions to
  8. * upgrade your older installation to the current version. If there's something
  9. * it cannot do itself, it will tell you what you need to do. The commands in
  10. * here will all be database-neutral, using the functions defined in DLL libraries.
  11. *
  12. * @package mod_nasatlx
  13. * @copyright 2014 LInE - http://line.ime.usp.br
  14. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  15. */
  16. defined('MOODLE_INTERNAL') || die();
  17. /**
  18. * Execute nasatlx upgrade from the given old version
  19. *
  20. * @param int $oldversion
  21. * @return bool
  22. */
  23. function xmldb_nasatlx_upgrade ($oldversion) {
  24. global $DB;
  25. $dbman = $DB->get_manager(); // loads ddl manager and xmldb classes
  26. //D echo "./mod/nasatlx/db/upgrade.php: entrou xmldb_nasatlx_upgrade, oldversion=$oldversion<br/>";
  27. //D General form to update after new version
  28. // if ($oldversion < YYYYMMDD00) { //New version in version.php
  29. // }
  30. // add_to_log() has been deprecated, please rewrite your code to the new events API
  31. // line 50 of /lib/deprecatedlib.php: call to debugging()
  32. // line 45 of /mod/nasatlx/view.php: call to add_to_log()
  33. // The initial version of NASA-TLX does not defined capabilities, fix it with 'access.php'!
  34. if ($oldversion < 2019030100) {
  35. // get_records_sql
  36. // get_recordset_sql
  37. //DEBUG To test NASA-TLX capabilities in table '*_capabilities': id name captype contextlevel component riskbitmask
  38. //D $list_nasalti_capabilities = $DB->get_records_sql("SELECT * FROM {capabilities} WHERE component='mod_nasatlx';");
  39. //D $num_cap = sizeof($list_nasalti_capabilities);
  40. //D echo "./mod/nasatlx/db/upgrade.php: #list_nasalti_capabilities=" . sizeof($list_nasalti_capabilities) . "<br/>";
  41. //D print_r($list_nasalti_capabilities); echo "<br/>";
  42. //D exit; // foreach ();
  43. //D if ($num_cap == 0) {
  44. //D $newentry = new stdClass();
  45. // Final return of upgrade result (true, all went good) to Moodle.
  46. return true;
  47. } // if ($oldversion < 2019030400)
  48. //D echo "./mod/nasatlx/db/upgrade.php: fim 'xmldb_nasatlx_upgrade(...)'<br/>";
  49. } // function xmldb_nasatlx_upgrade($oldversion)
  50. // First this script is loaded, after it the 'xmldb_nasatlx_upgrade($oldversion)' is executed
  51. //D echo "./mod/nasatlx/db/upgrade.php: fim<br/>";