|
@@ -23,11 +23,11 @@
|
|
*
|
|
*
|
|
* @author Patricia Alves Rodrigues
|
|
* @author Patricia Alves Rodrigues
|
|
* @author Leônidas O. Brandão
|
|
* @author Leônidas O. Brandão
|
|
- * @author Luciano Oliveira Borges
|
|
|
|
|
|
+ * @version v 1.5 2019/03/13
|
|
* @version v 1.4 2013/09/19
|
|
* @version v 1.4 2013/09/19
|
|
* @package mod_iassign_db
|
|
* @package mod_iassign_db
|
|
* @since 2010/12/21
|
|
* @since 2010/12/21
|
|
- * @copyright iMatica (<a href="http://www.matematica.br">iMath</a>) - Computer Science Dep. of IME-USP (Brazil)
|
|
|
|
|
|
+ * @copyright iMath (http://www.matematica.br) and LInE (http://line.ime.usp.br) - Computer Science Dep. of IME-USP (Brazil)
|
|
*
|
|
*
|
|
* <b>License</b>
|
|
* <b>License</b>
|
|
* - http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
* - http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
@@ -192,11 +192,11 @@ function xmldb_iassign_upgrade ($oldversion) {
|
|
$newentry = new stdClass();
|
|
$newentry = new stdClass();
|
|
$newentry->name = 'iVProgH5';
|
|
$newentry->name = 'iVProgH5';
|
|
$newentry->url = 'http://www.matematica.br/ivprogh5';
|
|
$newentry->url = 'http://www.matematica.br/ivprogh5';
|
|
- $newentry->version = '0.1.0';
|
|
|
|
|
|
+ $newentry->version = '0.1.1';
|
|
$newentry->description = '{"en":"Visual Interactive Programming on the Internet HTML5","pt_br":"Programação visual interativa na Internet"}';
|
|
$newentry->description = '{"en":"Visual Interactive Programming on the Internet HTML5","pt_br":"Programação visual interativa na Internet"}';
|
|
$newentry->extension = 'ivph';
|
|
$newentry->extension = 'ivph';
|
|
$newentry->file_jar = 'iVProgH5'; // to JAR this is the '*_files.id' correponding to the iLM storaged in '/var/moodledata/filedir/'
|
|
$newentry->file_jar = 'iVProgH5'; // to JAR this is the '*_files.id' correponding to the iLM storaged in '/var/moodledata/filedir/'
|
|
- $newentry->file_class = 'ivprog-html/main.html';
|
|
|
|
|
|
+ $newentry->file_class = 'ivprog-html/index.html';
|
|
$newentry->width = 800;
|
|
$newentry->width = 800;
|
|
$newentry->height = 700;
|
|
$newentry->height = 700;
|
|
$newentry->enable = 1;
|
|
$newentry->enable = 1;
|
|
@@ -247,7 +247,7 @@ function xmldb_iassign_upgrade ($oldversion) {
|
|
} // foreach
|
|
} // foreach
|
|
|
|
|
|
//---
|
|
//---
|
|
- // Insert in talbe '{iassign_ilm}' the new iLM iFractions version 0.1.2017.11.22
|
|
|
|
|
|
+ // Insert in table '{iassign_ilm}' the new iLM iFractions version 0.1.2017.11.22
|
|
// Table 'iassign_ilm' : id name version type description url extension parent file_jar file_class width height enable timemodified author timecreated evaluate
|
|
// Table 'iassign_ilm' : id name version type description url extension parent file_jar file_class width height enable timemodified author timecreated evaluate
|
|
/*$new_ilm_ifractions['name'] = 'iFractions';
|
|
/*$new_ilm_ifractions['name'] = 'iFractions';
|
|
$new_ilm_ifractions['version'] = '0.1.2017.11.22';
|
|
$new_ilm_ifractions['version'] = '0.1.2017.11.22';
|
|
@@ -269,150 +269,159 @@ function xmldb_iassign_upgrade ($oldversion) {
|
|
|
|
|
|
} // if ($oldversion < 2017120101)
|
|
} // if ($oldversion < 2017120101)
|
|
|
|
|
|
- if ($oldversion < 2018031000) {
|
|
|
|
- // Verify if exist iLM with the same name
|
|
|
|
- // then, update the version and file_jar
|
|
|
|
-
|
|
|
|
- $records = array(
|
|
|
|
- // iGeom 5.9.22
|
|
|
|
- array_combine(
|
|
|
|
- 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)),
|
|
|
|
- // iGraf 4.4.0.10
|
|
|
|
- array_combine(
|
|
|
|
- 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)),
|
|
|
|
- // iComb 0.9.5
|
|
|
|
- array_combine(
|
|
|
|
- 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)),
|
|
|
|
- // iVProg2 2.1.0
|
|
|
|
- array_combine(
|
|
|
|
- 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)),
|
|
|
|
- // iTangram2 0.4.6
|
|
|
|
- array_combine(
|
|
|
|
- array('name', 'url', 'version', 'type', 'description', 'extension', 'file_jar', 'file_class', 'width', 'height', 'enable', 'timemodified', 'author', 'timecreated', 'evaluate'),
|
|
|
|
- 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)),
|
|
|
|
- // iHanoi 3.1.0
|
|
|
|
- array_combine(
|
|
|
|
- array('name', 'url', 'version', 'type', 'description', 'extension', 'file_jar', 'file_class', 'width', 'height', 'enable', 'timemodified', 'author', 'timecreated', 'evaluate'),
|
|
|
|
- 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)),
|
|
|
|
- // Risco 2
|
|
|
|
- array_combine(
|
|
|
|
- array('name', 'url', 'version', 'type', 'description', 'extension', 'file_jar', 'file_class', 'width', 'height', 'enable', 'timemodified', 'author', 'timecreated', 'evaluate'),
|
|
|
|
- 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)),
|
|
|
|
- // iVProgH5 0.1 - HTML5
|
|
|
|
- array_combine(
|
|
|
|
- array('name', 'url', 'version', 'type', 'description', 'extension', 'file_jar', 'file_class', 'width', 'height', 'enable', 'timemodified', 'author', 'timecreated', 'evaluate'),
|
|
|
|
- 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)),
|
|
|
|
- // fractions 0.1.2017.11.22 - HTML5
|
|
|
|
- array_combine(
|
|
|
|
- array('name', 'url', 'version', 'type', 'description', 'extension', 'file_jar', 'file_class', 'width', 'height', 'enable', 'timemodified', 'author', 'timecreated', 'evaluate'),
|
|
|
|
- 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))
|
|
|
|
- );
|
|
|
|
-
|
|
|
|
- foreach ($records as $record) {
|
|
|
|
-
|
|
|
|
- if ($record['type'] == 'HTML5') {
|
|
|
|
-
|
|
|
|
- // Verify if there is a HTML5 iLM register to update it
|
|
|
|
|
|
+ if ($oldversion < 2018031000) {
|
|
|
|
+ // Verify if exist iLM with the same name
|
|
|
|
+ // then, update the version and file_jar
|
|
|
|
+
|
|
|
|
+ $records = array(
|
|
|
|
+ // iGeom 5.9.22
|
|
|
|
+ array_combine(
|
|
|
|
+ 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)),
|
|
|
|
+ // iGraf 4.4.0.10
|
|
|
|
+ array_combine(
|
|
|
|
+ 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)),
|
|
|
|
+ // iComb 0.9.5
|
|
|
|
+ array_combine(
|
|
|
|
+ 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)),
|
|
|
|
+ // iVProg2 2.1.0
|
|
|
|
+ array_combine(
|
|
|
|
+ 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)),
|
|
|
|
+ // iTangram2 0.4.6
|
|
|
|
+ array_combine(
|
|
|
|
+ array('name', 'url', 'version', 'type', 'description', 'extension', 'file_jar', 'file_class', 'width', 'height', 'enable', 'timemodified', 'author', 'timecreated', 'evaluate'),
|
|
|
|
+ array('iTangram2', 'http://www.matematica.br/itangram', '0.4.6', 'Java', '{"en":"interactive Tangram (by LInE)","pt_br":"Tangram interativo (do LInE)"}', 'itg2', 'ilm/iTangram2/0.4.6/iTangram2.jar', 'ilm.line.itangram2.Tangram', 800, 600, 1, time(), $USER->id, time(), 1)),
|
|
|
|
+ // iHanoi 3.1.0
|
|
|
|
+ array_combine(
|
|
|
|
+ array('name', 'url', 'version', 'type', 'description', 'extension', 'file_jar', 'file_class', 'width', 'height', 'enable', 'timemodified', 'author', 'timecreated', 'evaluate'),
|
|
|
|
+ array('iHanoi', 'http://www.matematica.br/ihanoi', '3.1.0', 'Java', '{"en":"interactive Tower os Hanoi (by LInE)", "pt_br":"Torres de Hanói (do LInE)"}', 'ihn', 'ilm/iHanoi/3.1.0/iHanoi.jar', 'ihanoi.iHanoi', 730, 450, 1, time(), $USER->id, time(), 1)),
|
|
|
|
+ // Risco 2
|
|
|
|
+ array_combine(
|
|
|
|
+ array('name', 'url', 'version', 'type', 'description', 'extension', 'file_jar', 'file_class', 'width', 'height', 'enable', 'timemodified', 'author', 'timecreated', 'evaluate'),
|
|
|
|
+ array('Risko', 'http://risko.pcc.usp.br/', '2.2.23', 'Java', '{"en":"Technical drawing with triangle and ruler","pt_br":"Desenho Geomẽtrico com esquadro"}', 'rsk', 'ilm/Risko/2.2.23/Risko.jar', 'RiskoApplet.class', 800, 600, 1, time(), $USER->id, time(), 0)),
|
|
|
|
+ // iVProgH5 0.1.1 - HTML5
|
|
|
|
+ array_combine(
|
|
|
|
+ array('name', 'url', 'version', 'type', 'description', 'extension', 'file_jar', 'file_class', 'width', 'height', 'enable', 'timemodified', 'author', 'timecreated', 'evaluate'),
|
|
|
|
+ array('iVProgH', 'http://www.matematica.br/ivprogh', '0.1.20190307', 'HTML5', '{"en":"Visual Interactive Programming on the Internet HTML5","pt_br":"Programação visual interativa na Internet"}', 'ivph', 'ilm/iVProgH/0.1.20190307/ivprog-html/', 'index.html', 800, 600, 1, time(), $USER->id, time(), 1)),
|
|
|
|
+ // fractions 0.1.2017.11.22 - HTML5
|
|
|
|
+ array_combine(
|
|
|
|
+ array('name', 'url', 'version', 'type', 'description', 'extension', 'file_jar', 'file_class', 'width', 'height', 'enable', 'timemodified', 'author', 'timecreated', 'evaluate'),
|
|
|
|
+ array('iFractions', 'http://www.matematica.br/ifractions', '0.1.2017.11.22', 'HTML5', '{"en":"Interactive Fractions game","pt_br":"Jogo interativa de frações"}', 'frc', 'ilm/iFractions/0.1.2017.11.22/ifractions/', 'index.html', 1000, 600, 1, time(), $USER->id, time(), 1))
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ foreach ($records as $record) {
|
|
|
|
+ if ($record['type'] == 'HTML5') {
|
|
|
|
+
|
|
|
|
+ //D echo " * iMA versao HTML<br/>\n";
|
|
|
|
+ // Verify if there is a HTML5 iLM register => update it
|
|
$iassign_ilm = $DB->get_records('iassign_ilm', array('name' => $record['name']));
|
|
$iassign_ilm = $DB->get_records('iassign_ilm', array('name' => $record['name']));
|
|
|
|
|
|
if ($iassign_ilm) {
|
|
if ($iassign_ilm) {
|
|
// Update file_jar and file_class
|
|
// Update file_jar and file_class
|
|
|
|
|
|
foreach ($iassign_ilm as $iassign) {
|
|
foreach ($iassign_ilm as $iassign) {
|
|
-
|
|
|
|
|
|
+ $iassign->name = trim($iassign->name);
|
|
|
|
+ $iassign->version = trim($iassign->version);
|
|
|
|
+ //D echo " " . $iassign->id . ", " . $iassign->name . "<br/>\n";
|
|
// If HTML5 iLM is the same version, only update the path
|
|
// If HTML5 iLM is the same version, only update the path
|
|
if ($iassign->version == $record['version']) {
|
|
if ($iassign->version == $record['version']) {
|
|
|
|
+ //D echo " mesma versao " . $iassign->version . "<br/>\n";
|
|
$newentry = new stdClass();
|
|
$newentry = new stdClass();
|
|
$newentry->id = $iassign->id;
|
|
$newentry->id = $iassign->id;
|
|
$newentry->file_jar = $record['file_jar'];
|
|
$newentry->file_jar = $record['file_jar'];
|
|
$newentry->file_class = $record['file_class'];
|
|
$newentry->file_class = $record['file_class'];
|
|
|
|
|
|
$DB->update_record("iassign_ilm", $newentry);
|
|
$DB->update_record("iassign_ilm", $newentry);
|
|
- } else { // If HTML5 iLM is NOT the same version, make a copy of the iLM
|
|
|
|
- $dest = $CFG->dirroot . '/mod/iassign/ilm/' . $iassign->name . '/' . $iassign->version . '/';
|
|
|
|
- mkdir($dest, 0777);
|
|
|
|
-
|
|
|
|
- $source = $CFG->dirroot . '/mod/iassign/ilm/' . $iassign->name . '/' . $record['version'] . '/';
|
|
|
|
-
|
|
|
|
- foreach (
|
|
|
|
- $iterator = new \RecursiveIteratorIterator(
|
|
|
|
- new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS),
|
|
|
|
- \RecursiveIteratorIterator::SELF_FIRST) as $item
|
|
|
|
- ) {
|
|
|
|
- if ($item->isDir()) {
|
|
|
|
- mkdir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
|
|
|
|
- } else {
|
|
|
|
- copy($item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- $newentry = new stdClass();
|
|
|
|
- $newentry->id = $iassign->id;
|
|
|
|
- $newentry->file_jar = 'ilm/' . $iassign->name . '/' . $iassign->version . '/' . basename($record['file_jar']) . '/';
|
|
|
|
- $newentry->file_class = $record['file_class'];
|
|
|
|
-
|
|
|
|
- $DB->update_record("iassign_ilm", $newentry);
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
- }
|
|
|
|
-
|
|
|
|
- } else {
|
|
|
|
- // If not found a iLM with the same name
|
|
|
|
- $DB->insert_record('iassign_ilm', $record, false); // insert new iLM in the table '*_iassign_ilm'
|
|
|
|
|
|
+ else { // If HTML5 iLM is NOT the same version, make a copy of the iLM
|
|
|
|
+ $dest = $CFG->dirroot . '/mod/iassign/ilm/' . $iassign->name . '/' . $iassign->version . '/';
|
|
|
|
+ mkdir($dest, 0755); // permissions "drwxr-xr-x"
|
|
|
|
+
|
|
|
|
+ $source = $CFG->dirroot . '/mod/iassign/ilm/' . $iassign->name . '/' . $record['version'] . '/';
|
|
|
|
+
|
|
|
|
+ foreach (
|
|
|
|
+ $iterator = new \RecursiveIteratorIterator(
|
|
|
|
+ new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS),
|
|
|
|
+ \RecursiveIteratorIterator::SELF_FIRST) as $item) {
|
|
|
|
+ if ($item->isDir()) {
|
|
|
|
+ mkdir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
|
|
|
|
+ }
|
|
|
|
+ else { // copy or move?
|
|
|
|
+ copy($item, $dest . $iterator->getSubPathName());
|
|
|
|
+ // copy($item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
|
|
|
|
+ // rename($item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ $newentry = new stdClass();
|
|
|
|
+ $newentry->id = $iassign->id;
|
|
|
|
+ $newentry->file_jar = 'ilm/' . $iassign->name . '/' . $iassign->version . '/' . basename($record['file_jar']) . '/';
|
|
|
|
+ $newentry->file_class = $record['file_class'];
|
|
|
|
|
|
- } // if ($record['type'] == 'HTML5')
|
|
|
|
- else {
|
|
|
|
|
|
+ $DB->update_record("iassign_ilm", $newentry);
|
|
|
|
+ }
|
|
|
|
+ } // foreach ($iassign_ilm as $iassign)
|
|
|
|
|
|
- // Verify if there is a Java iLM register to update it
|
|
|
|
- $iassign_ilm = $DB->get_record('iassign_ilm', array('name' => $record['name'], 'version' => $record['version']));
|
|
|
|
|
|
+ }
|
|
|
|
+ else { // if ($iassign_ilm)
|
|
|
|
+ // If not found a iLM with the same name
|
|
|
|
+ $DB->insert_record('iassign_ilm', $record, false); // insert new iLM in the table '*_iassign_ilm'
|
|
|
|
+ }
|
|
|
|
|
|
- if ($iassign_ilm) {
|
|
|
|
- // Update file_jar and file_class
|
|
|
|
- $newentry = new stdClass();
|
|
|
|
- $newentry->id = $iassign_ilm->id;
|
|
|
|
- $newentry->file_jar = $record['file_jar'];
|
|
|
|
- $newentry->file_class = $record['file_class'];
|
|
|
|
|
|
+ } // if ($record['type'] == 'HTML5')
|
|
|
|
+ else {
|
|
|
|
|
|
- $DB->update_record("iassign_ilm", $newentry);
|
|
|
|
- } else {
|
|
|
|
-
|
|
|
|
- // If not found a Java iLM with the same name and version, search a
|
|
|
|
- // different version, to use as parent of new version
|
|
|
|
|
|
+ // Verify if there is a Java iLM register to update it
|
|
|
|
+ $iassign_ilm = $DB->get_record('iassign_ilm', array('name' => $record['name'], 'version' => $record['version']));
|
|
|
|
|
|
- $iassign_ilm_parent = $DB->get_record('iassign_ilm', array('name' => $record['name'], 'parent' => 0));
|
|
|
|
|
|
+ if ($iassign_ilm) {
|
|
|
|
+ // Update file_jar and file_class
|
|
|
|
+ $newentry = new stdClass();
|
|
|
|
+ $newentry->id = $iassign_ilm->id;
|
|
|
|
+ $newentry->file_jar = $record['file_jar'];
|
|
|
|
+ $newentry->file_class = $record['file_class'];
|
|
|
|
|
|
- if ($iassign_ilm_parent) {
|
|
|
|
|
|
+ $DB->update_record("iassign_ilm", $newentry);
|
|
|
|
+ }
|
|
|
|
+ else { // if ($iassign_ilm) - I couldn't find an iLM with this name ($record['name']) and under this version ($record['version'])
|
|
|
|
+ // If not found a Java iLM with the same name and version, search a
|
|
|
|
+ // different version, to use as parent of new version
|
|
|
|
|
|
- $record['parent'] = $iassign_ilm_parent->id;
|
|
|
|
- $DB->insert_record('iassign_ilm', $record, false); // insert with parent
|
|
|
|
|
|
+ $iassign_ilm_parent = $DB->get_record('iassign_ilm', array('name' => $record['name'], 'parent' => 0));
|
|
|
|
|
|
- // Download the JAR file of parent from MoodleData and put it in iassign/ilm/
|
|
|
|
- $dest = $CFG->dirroot . '/mod/iassign/ilm/' . $iassign_ilm_parent->name . '/' . $iassign_ilm_parent->version . '/';
|
|
|
|
- mkdir($dest, 0777);
|
|
|
|
|
|
+ if ($iassign_ilm_parent) {
|
|
|
|
+ $record['parent'] = $iassign_ilm_parent->id;
|
|
|
|
+ $DB->insert_record('iassign_ilm', $record, false); // insert with parent
|
|
|
|
|
|
- $fs = get_file_storage();
|
|
|
|
- $file = $fs->get_file_by_id($iassign_ilm_parent->file_jar);
|
|
|
|
- $file->copy_content_to($dest . $file->get_filename());
|
|
|
|
|
|
+ // Download the JAR file of parent from MoodleData and put it in iassign/ilm/
|
|
|
|
+ $dest = $CFG->dirroot . '/mod/iassign/ilm/' . $iassign_ilm_parent->name . '/' . $iassign_ilm_parent->version . '/';
|
|
|
|
+ mkdir($dest, 0777);
|
|
|
|
+ //D echo " mover para " . $dest . "<br/>\n";
|
|
|
|
|
|
- // Update file_jar of iLM parent
|
|
|
|
- $update_parent = new stdClass();
|
|
|
|
- $update_parent->id = $iassign_ilm_parent->id;
|
|
|
|
- $update_parent->file_jar = 'ilm/' . $iassign_ilm_parent->name . '/' . $iassign_ilm_parent->version . '/' . $file->get_filename();
|
|
|
|
|
|
+ $fs = get_file_storage();
|
|
|
|
+ $file = $fs->get_file_by_id($iassign_ilm_parent->file_jar);
|
|
|
|
+ $file->copy_content_to($dest . $file->get_filename());
|
|
|
|
|
|
- $DB->update_record("iassign_ilm", $update_parent);
|
|
|
|
|
|
+ // Update file_jar of iLM parent
|
|
|
|
+ $update_parent = new stdClass();
|
|
|
|
+ $update_parent->id = $iassign_ilm_parent->id;
|
|
|
|
+ $update_parent->file_jar = 'ilm/' . $iassign_ilm_parent->name . '/' . $iassign_ilm_parent->version . '/' . $file->get_filename();
|
|
|
|
|
|
- } else {
|
|
|
|
- $DB->insert_record('iassign_ilm', $record, false); // insert new iLM in the table '*_iassign_ilm' without a parent
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ $DB->update_record("iassign_ilm", $update_parent);
|
|
|
|
|
|
- } // foreach ($records as $record)
|
|
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ $DB->insert_record('iassign_ilm', $record, false); // insert new iLM in the table '*_iassign_ilm' without a parent
|
|
|
|
+ }
|
|
|
|
+ } // else if ($iassign_ilm)
|
|
|
|
+ } // else if ($record['type'] == 'HTML5')
|
|
|
|
|
|
- } // if ($oldversion < 2018031000)
|
|
|
|
|
|
+ } // foreach ($records as $record)
|
|
|
|
|
|
|
|
+ } // if ($oldversion < 2018031000)
|
|
|
|
|
|
|
|
|
|
// log event -----------------------------------------------------
|
|
// log event -----------------------------------------------------
|