install.php 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <?php
  2. /**
  3. * Script for install all ilm in iassign table.
  4. *
  5. * This file replaces:
  6. * STATEMENTS section in db/install.xml
  7. * lib.php/modulename_install() post installation hook partially defaults.php.
  8. *
  9. * Release Notes:
  10. * - v 1.4 2017/02/16
  11. * + Insert iVProgH5, updated iGeom, iGraf, iComb, iHanoi
  12. * - v 1.3 2013/12/12
  13. * + Language support in iLM
  14. * - v 1.2 2013/09/19
  15. * + Change path file for ilm, consider version in pathname
  16. *
  17. * @author Patricia Alves Rodrigues
  18. * @author Leônidas O. Brandão
  19. * @author Luciano Oliveira Borges
  20. * @version v 1.2 2013/09/19
  21. * @package mod_iassign_db
  22. * @since 2010/09/27
  23. * @copyright iMatica (<a href="http://www.matematica.br">iMath</a>) - Computer Science Dep. of IME-USP (Brazil)
  24. *
  25. * <b>License</b>
  26. * - http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  27. */
  28. require_once ($CFG->dirroot . '/mod/iassign/locallib.php');
  29. function xmldb_iassign_install() {
  30. global $DB, $USER, $CFG;
  31. $records = array(
  32. // iGeom 5.9.22
  33. array_combine(
  34. 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)),
  35. // iGraf 4.4.0.10
  36. array_combine(
  37. 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)),
  38. // iComb 0.9.5
  39. array_combine(
  40. 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)),
  41. // iVProg2 2.1.0
  42. array_combine(
  43. 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)),
  44. // iTangram2 0.4.6
  45. array_combine(
  46. array('name', 'url', 'version', 'type', 'description', 'extension', 'file_jar', 'file_class', 'width', 'height', 'enable', 'timemodified', 'author', 'timecreated', 'evaluate'),
  47. 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)),
  48. // iHanoi 3.1.0
  49. array_combine(
  50. array('name', 'url', 'version', 'type', 'description', 'extension', 'file_jar', 'file_class', 'width', 'height', 'enable', 'timemodified', 'author', 'timecreated', 'evaluate'),
  51. 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)),
  52. // Risco 2
  53. array_combine(
  54. array('name', 'url', 'version', 'type', 'description', 'extension', 'file_jar', 'file_class', 'width', 'height', 'enable', 'timemodified', 'author', 'timecreated', 'evaluate'),
  55. 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)),
  56. // iVProgH5 0.1 - HTML5
  57. array_combine(
  58. array('name', 'url', 'version', 'type', 'description', 'extension', 'file_jar', 'file_class', 'width', 'height', 'enable', 'timemodified', 'author', 'timecreated', 'evaluate'),
  59. 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)),
  60. // fractions 0.1.2017.11.22 - HTML5
  61. array_combine(
  62. array('name', 'url', 'version', 'type', 'description', 'extension', 'file_jar', 'file_class', 'width', 'height', 'enable', 'timemodified', 'author', 'timecreated', 'evaluate'),
  63. 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))
  64. );
  65. foreach ($records as $record) {
  66. // Verify if there is a previous iLM (an old version that must be kept)
  67. $iassign_ilm_parent = $DB->get_record('iassign_ilm', array('name' => $record['name'], 'parent' => 0));
  68. $ilm_exists = false;
  69. if ($iassign_ilm_parent) {
  70. if ($iassign_ilm_parent->version != $record['version'])
  71. $record['parent'] = $iassign_ilm_parent->id;
  72. else
  73. $ilm_exists = true;
  74. }
  75. $file_jar = $record['file_jar'];
  76. if (!empty($file_jar)) {
  77. $DB->insert_record('iassign_ilm', $record, false); // insert new iLM in the table '*_iassign_ilm'
  78. }
  79. } // foreach ($records as $record)
  80. // Add iAssign button to the Atto Editor
  81. $toolbar = get_config('editor_atto', 'toolbar');
  82. if (strpos($toolbar, 'iassign') === false && $toolbar && $toolbar != '') {
  83. $groups = explode("\n", $toolbar);
  84. // Try to put iassign in the html group.
  85. $found = false;
  86. foreach ($groups as $i => $group) {
  87. $parts = explode('=', $group);
  88. if (trim($parts[0]) == 'other') {
  89. $groups[$i] = 'other = ' . trim($parts[1]) . ', iassign';
  90. $found = true;
  91. }
  92. }
  93. // if the group is not found, create the other group and insert it there
  94. // Maybe unecessary as the other group is a standard, but if the user has changed it?
  95. if (!$found) {
  96. do {
  97. $last = array_pop($groups);
  98. } while (empty($last) && !empty($groups));
  99. $groups[] = 'other = iassign';
  100. $groups[] = $last;
  101. }
  102. // Update $toolbar and add to the config
  103. $toolbar = implode("\n", $groups);
  104. set_config('toolbar', $toolbar, 'editor_atto');
  105. } // if (strpos($toolbar, 'iassign') === false && $toolbar && $toolbar != '')
  106. // end Add
  107. // log event -----------------------------------------------------
  108. if (class_exists('plugin_manager'))
  109. $pluginman = plugin_manager::instance();
  110. else
  111. $pluginman = core_plugin_manager::instance();
  112. $plugins = $pluginman->get_plugins();
  113. iassign_log::add_log('install', 'version: ' . $plugins['mod']['iassign']->versiondb);
  114. // log event -----------------------------------------------------
  115. }
  116. // function xmldb_iassign_install()