|
@@ -14,6 +14,10 @@
|
|
|
* The commands in here will all be database-neutral,
|
|
|
* using the functions defined in lib/ddllib.php
|
|
|
*
|
|
|
+ * - v 1.5.5 2022/01/10
|
|
|
+ * + Added new version of iVProg 2022_01_13_21_43
|
|
|
+ * - v 1.5.4 2021/12/23
|
|
|
+ * + Added new version of iVProg 2021_11_30_22_06
|
|
|
* - v 1.5.3 2021/10/10
|
|
|
* + Fixed several string concatenation from '+' to '.'
|
|
|
* + Since now is allowed null file associated to "test" activity,
|
|
@@ -54,7 +58,15 @@ function xmldb_iassign_upgrade ($oldversion) {
|
|
|
|
|
|
$dbman = $DB->get_manager();
|
|
|
|
|
|
- //L if ($oldversion < 2019112219) {
|
|
|
+ // Sequence of updates:
|
|
|
+ // - 2020070613: structure
|
|
|
+ // - 2020080300
|
|
|
+ // - 2020120500
|
|
|
+ // - 2020122900
|
|
|
+ // - 2021020700
|
|
|
+ // - 2021122300: new version iVProg "1.0.20211130"
|
|
|
+ // - 2022011300: new version iVProg "1.0.20220113"
|
|
|
+
|
|
|
if ($oldversion < 2020070613) {
|
|
|
$table = new xmldb_table('iassign_submission');
|
|
|
$field = new xmldb_field('previous_grade', XMLDB_TYPE_FLOAT, null, null, null, null, null);
|
|
@@ -72,9 +84,9 @@ function xmldb_iassign_upgrade ($oldversion) {
|
|
|
array_combine( // iHanoi 1.0.20200803
|
|
|
array('name', 'url', 'version', 'type', 'description', 'extension', 'file_jar', 'file_class', 'width', 'height', 'enable', 'timemodified', 'author', 'timecreated', 'evaluate', 'reevaluate'),
|
|
|
array('iHanoi', 'http://www.matematica.br/ihanoi', '1.0.20200803', 'HTML5', '{"en":"interactive Tower os Hanoi (by LInE)", "pt_br":"Torres de Hanói (do LInE)"}', 'ihn', 'ilm/iHanoi/1.0.20200803/ihanoi/', 'index.html', 1100, 500, 1, time(), $USER->id, time(), 1, 0)),
|
|
|
- array_combine( // iVProg 1.0.20200221/ - HTML5 - 2020
|
|
|
+ array_combine( // iVProg 1.0.20220113/ - HTML5 - 2020
|
|
|
array('name', 'url', 'version', 'type', 'description', 'extension', 'file_jar', 'file_class', 'width', 'height', 'enable', 'timemodified', 'author', 'timecreated', 'evaluate', 'reevaluate'),
|
|
|
- array('iVProg', 'http://www.usp.br/line/ivprog/', '1.0.20200221', 'HTML5', '{"en":"Visual Interactive Programming on the Internet (HTML)","pt_br":"Programação visual interativa na Internet"}', 'ivph', 'ilm/iVProg/1.0.20200221/ivprog/', 'index.html', 800, 600, 1, time(), $USER->id, time(), 1, 1)),
|
|
|
+ array('iVProg', 'http://www.usp.br/line/ivprog/', '1.0.20220113', 'HTML5', '{"en":"Visual Interactive Programming on the Internet (HTML)","pt_br":"Programação visual interativa na Internet"}', 'ivph', 'ilm/iVProg/1.0.20220113/ivprog/', 'index.html', 900, 700, 1, time(), $USER->id, time(), 1, 1)),
|
|
|
array_combine( // iFractions 0.1.20200221 - HTML5
|
|
|
array('name', 'url', 'version', 'type', 'description', 'extension', 'file_jar', 'file_class', 'width', 'height', 'enable', 'timemodified', 'author', 'timecreated', 'evaluate', 'reevaluate'),
|
|
|
array('iFractions', 'http://www.matematica.br/ifractions', '0.1.20200221', 'HTML5', '{"en":"Interactive Fractions game","pt_br":"Jogo interativa de frações"}', 'frc', 'ilm/iFractions/0.1.20200221/ifractions/', 'index.html', 1000, 600, 1, time(), $USER->id, time(), 1, 0))
|
|
@@ -186,6 +198,7 @@ function xmldb_iassign_upgrade ($oldversion) {
|
|
|
}
|
|
|
} // if ($oldversion < 2020070612)
|
|
|
|
|
|
+ $strNot_installed = '';
|
|
|
if ($oldversion < 2020080300) { // new iHanoi
|
|
|
// iassign_submission . grade : from 'BIGINT(11)' to 'real'
|
|
|
if ($dbman->field_exists('iassign', 'grade')) {
|
|
@@ -206,7 +219,7 @@ function xmldb_iassign_upgrade ($oldversion) {
|
|
|
$DB->execute($sql);
|
|
|
}
|
|
|
|
|
|
- // Update iHanoi, iVProg, iFractions and iGeom
|
|
|
+ // Update iHanoi
|
|
|
$records = array(
|
|
|
array_combine( // iHanoi 1.0.20200803
|
|
|
array('name', 'url', 'version', 'type', 'description',
|
|
@@ -219,11 +232,12 @@ function xmldb_iassign_upgrade ($oldversion) {
|
|
|
$iassign_ilm = $DB->get_records('iassign_ilm');
|
|
|
foreach ($records as $record) { // For each iLM in the current version of iAssign
|
|
|
$newentry = new stdClass();
|
|
|
+
|
|
|
$newentry->name = $record['name'];
|
|
|
$newentry->version = $record['version'];
|
|
|
$newentry->type = $record['type'];
|
|
|
- $newentry->url = $record['url'];
|
|
|
$newentry->description = $record['description'];
|
|
|
+ $newentry->url = $record['url'];
|
|
|
$newentry->extension = $record['extension'];
|
|
|
$newentry->file_jar = $record['file_jar'];
|
|
|
$newentry->file_class = $record['file_class'];
|
|
@@ -235,7 +249,6 @@ function xmldb_iassign_upgrade ($oldversion) {
|
|
|
$newentry->reevaluate = $record['reevaluate'];
|
|
|
$newentry->author = $USER->id;
|
|
|
$newentry->timecreated = time();
|
|
|
- $newentry->evaluate = $record['evaluate'];
|
|
|
|
|
|
$exists = 0;
|
|
|
$last_id = -1;
|
|
@@ -295,12 +308,10 @@ function xmldb_iassign_upgrade ($oldversion) {
|
|
|
$table = new xmldb_table('iassign_statement');
|
|
|
|
|
|
$field_filesid = new xmldb_field('filesid', XMLDB_TYPE_CHAR, '255', null, null, null, null, null);
|
|
|
- // field_filesid=xmldb_field Object ( [type:protected] => 4 [length:protected] => 255 [notnull:protected] => [default:protected] => [sequence:protected] => [decimals:protected] => [name:protected] =>
|
|
|
- // filesid [comment:protected] => [previous:protected] => [next:protected] => [hash:protected] => [loaded:protected] => [changed:protected] => [errormsg:protected] => [precision] => 4 )
|
|
|
|
|
|
if (!$dbman->field_exists($table, $field_filesid))
|
|
|
$dbman->add_field($table, $field_filesid);
|
|
|
-
|
|
|
+
|
|
|
// Updating all registers from iassing_statement.filesid
|
|
|
try {
|
|
|
//2021/10/10: $DB->execute("UPDATE {iassign_statement} SET filesid = file");
|
|
@@ -354,12 +365,11 @@ function xmldb_iassign_upgrade ($oldversion) {
|
|
|
} // if ($files)
|
|
|
} // foreach ($contexts as $context)
|
|
|
} // foreach ($iassign_statement_list as $iassign_statement_activity_item)
|
|
|
-
|
|
|
} // if ($oldversion < 2020120500)
|
|
|
|
|
|
- /// @Igor - adicionar a tabela iassign_allsubmissions
|
|
|
- if ($oldversion < 2020122900) {
|
|
|
|
|
|
+ /// @Igor - add table 'iassign_allsubmissions'
|
|
|
+ if ($oldversion < 2020122900) {
|
|
|
// Define table iassign_allsubmissions to be created.
|
|
|
$table = new xmldb_table('iassign_allsubmissions');
|
|
|
|
|
@@ -485,16 +495,98 @@ function xmldb_iassign_upgrade ($oldversion) {
|
|
|
|
|
|
} // if ($oldversion < 2020122900)
|
|
|
|
|
|
- if ($oldversion < 2021020700) {
|
|
|
-
|
|
|
- // Update SAW iVProg to inform reevalute is enabled:
|
|
|
- $updateentry = new stdClass();
|
|
|
- $updateentry->id = 57;
|
|
|
- $updateentry->reevaluate = 1;
|
|
|
- $updateentry->timemodified = time();
|
|
|
- $DB->update_record("iassign_ilm", $updateentry); // insert new iLM
|
|
|
+ if ($oldversion < 2021020700) {
|
|
|
+ // Update SAW iVProg to inform reevalute is enabled:
|
|
|
+ $updateentry = new stdClass();
|
|
|
+ $updateentry->id = 57;
|
|
|
+ $updateentry->reevaluate = 1;
|
|
|
+ $updateentry->timemodified = time();
|
|
|
+ $DB->update_record("iassign_ilm", $updateentry); // insert new iLM
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ $strNot_installed = '';
|
|
|
+ if ($oldversion < 2021122300) { // 2021/12/23
|
|
|
+
|
|
|
+ // Update iVProg
|
|
|
+ $records = array(
|
|
|
+ array_combine( // iVProg 1.0.20220113/ - HTML5 - 2021/12/30
|
|
|
+ array('name', 'url', 'version', 'type', 'description', 'extension', 'file_jar', 'file_class', 'width', 'height', 'enable', 'timemodified', 'author', 'timecreated', 'evaluate', 'reevaluate'),
|
|
|
+ array('iVProg', 'http://www.usp.br/line/ivprog/', '1.0.20220113', 'HTML5', '{"en":"Visual Interactive Programming on the Internet (HTML)","pt_br":"Programação visual interativa na Internet"}',
|
|
|
+ 'ivph', 'ilm/iVProg/1.0.20220113/ivprog/', 'index.html', 900, 700, 1, time(), $USER->id, time(), 1, 1))
|
|
|
+ );
|
|
|
+ $iassign_ilm = $DB->get_records('iassign_ilm');
|
|
|
+ foreach ($records as $record) { // For each iLM in the current version of iAssign
|
|
|
+ $newentry = new stdClass();
|
|
|
+ $newentry->name = $record['name'];
|
|
|
+ $newentry->url = $record['url'];
|
|
|
+ $newentry->version = $record['version'];
|
|
|
+ $newentry->type = $record['type'];
|
|
|
+ $newentry->description = $record['description'];
|
|
|
+ $newentry->extension = $record['extension'];
|
|
|
+ $newentry->file_jar = $record['file_jar'];
|
|
|
+ $newentry->file_class = $record['file_class'];
|
|
|
+ $newentry->width = $record['width'];
|
|
|
+ $newentry->height = $record['height'];
|
|
|
+ $newentry->enable = $record['enable'];
|
|
|
+ $newentry->timemodified = time();
|
|
|
+ $newentry->author = $USER->id;
|
|
|
+ $newentry->timecreated = time();
|
|
|
+ $newentry->evaluate = $record['evaluate'];
|
|
|
+ $newentry->reevaluate = $record['reevaluate'];
|
|
|
+
|
|
|
+ $exists = 0;
|
|
|
+ $last_id = -1;
|
|
|
+ if ($iassign_ilm) { // Search if there is any previous installed iLM that is also in the current version of iAssign
|
|
|
+ $record_type = strtolower($record['type']);
|
|
|
+ foreach ($iassign_ilm as $iassign) {
|
|
|
+ if ($iassign->name == $record['name'] && strtolower($iassign->type) == $record_type) {
|
|
|
+ if ($iassign->id > $last_id)
|
|
|
+ $last_id = $iassign->id; // last ID => last version (hopefully)
|
|
|
+ if ($iassign->version == $record['version']) { // or with the one with the same version
|
|
|
+ $exists = 1; // iLM found - exit with the last one, same version
|
|
|
+ $strNot_installed .= "\n" . ' <li>' . $record['name'] . ';' . $record['type'] . ';' . $record['version'] . ' </li>' . "\n";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $newentry->parent = $last_id; // parent is the last iLM found (corresponde to the smallest ID)
|
|
|
+ }
|
|
|
+ else
|
|
|
+ $newentry->parent = -1; // first iLM of this one
|
|
|
+ if ($exists == 0) { // iLM does not exists or it has old version
|
|
|
+ // $newentry->parent = $record['parent'];
|
|
|
+ $DB->insert_record("iassign_ilm", $newentry, false);
|
|
|
+ }
|
|
|
+ } // foreach ($records as $record)
|
|
|
+
|
|
|
+ if ($strNot_installed != '') {
|
|
|
+ print '<div class="alert alert-warning alert-block fade in " role="alert" data-aria-autofocus="true" tabindex="0" >' . "\n";
|
|
|
+ print get_string('upgrade_alert_exists', 'iassign'); // iLM previouly existent
|
|
|
+ print ' <ul style="margin-top: 1rem;">' . "\n";
|
|
|
+ print $strNot_installed;
|
|
|
+ print ' </ul>' . "\n";
|
|
|
+ print '</div>' . "\n";
|
|
|
+ }
|
|
|
+
|
|
|
+ // iassign_ilm: atualizou iHanoi existente, mas nao era isso! Deveria ter inserido novo!
|
|
|
+ // id name version type ... parent file_jar file_class width height ... evaluate reevaluate
|
|
|
+ // 53 iHanoi 2 HTML5 ... 0 ilm/iHanoi/2/ihanoi/ index.html 1100 700 ... 1 0
|
|
|
+ $iassign_ilm = $DB->get_records('iassign_ilm');
|
|
|
+ foreach ($iassign_ilm as $iassign) { // for iLM iHanoi update the new field 'reevaluate' as 1
|
|
|
+ if ($iassign->name == 'iHanoi' && $iassign->type == 'HTML5' && $iassign->reevaluate!=1) {
|
|
|
+ $updateentry = new stdClass();
|
|
|
+ $updateentry->id = $iassign->id;
|
|
|
+ $updateentry->reevaluate = 1;
|
|
|
+ $updateentry->timemodified = time();
|
|
|
+ $DB->update_record("iassign_ilm", $updateentry);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // iAssign savepoint reached.
|
|
|
+ upgrade_mod_savepoint(true, 2021122300, 'iassign');
|
|
|
+ } // if ($oldversion < 2021122300)
|
|
|
+
|
|
|
|
|
|
// log event -----------------------------------------------------
|
|
|
if (class_exists('plugin_manager'))
|