|
@@ -264,11 +264,9 @@ function xmldb_iassign_upgrade ($oldversion) {
|
|
|
print '</div>' + "\n";
|
|
|
}
|
|
|
|
|
|
-// s_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: 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) {
|
|
@@ -286,170 +284,187 @@ function xmldb_iassign_upgrade ($oldversion) {
|
|
|
|
|
|
} // if ($oldversion < 2020080300)
|
|
|
|
|
|
- //TODO Codigo do Igor para atualizar 'files.itemid' e 'iassign_statement.filesid':
|
|
|
- if ($oldversion < 2020102800) {
|
|
|
- // 1. encontrar os contextos dos arquivos do itarefa:
|
|
|
- $iassign_contexts_list = $DB->get_records_sql("SELECT contextid FROM {files} f " .
|
|
|
- " WHERE component='mod_iassign'");
|
|
|
- // 2. compor um array com todos os contextos encontrados:
|
|
|
- $contexts = array();
|
|
|
- foreach ($iassign_contexts_list as $iassign_context_item) {
|
|
|
- array_push($contexts, $iassign_context_item->contextid);
|
|
|
- }
|
|
|
- // 3. encontrar todas as atividades do itarefa, em que o arquivo não tenha o mesmo id do statement:
|
|
|
- $iassign_statement_list = $DB->get_records_sql("SELECT * FROM {iassign_statement} s " .
|
|
|
- " WHERE s.id != s.file");
|
|
|
- $fs = get_file_storage();
|
|
|
+ //TODO Codigo do Igor para atualizar 'files.itemid' e 'iassign_statement.filesid':
|
|
|
+ if ($oldversion < 2020120500) {
|
|
|
|
|
|
- // 4. percorrer o conjunto de atividades:
|
|
|
- foreach ($iassign_statement_list as $iassign_statement_activity_item) {
|
|
|
-
|
|
|
- // 5. encontrar o arquivo, considerando os possíveis contextos:
|
|
|
- $files = array();
|
|
|
- foreach ($contexts as $context) {
|
|
|
-
|
|
|
- $files = $fs->get_area_files($context, 'mod_iassign', 'exercise', $iassign_statement_activity_item->file);
|
|
|
-
|
|
|
- // 6. se o arquivo for encontrado, fazer uma cópia do conteúdo,
|
|
|
- // com o itemid novo, atualizar o iassign_statement, e apagar o arquivo antigo:
|
|
|
- if ($files) {
|
|
|
- foreach ($files as $value) {
|
|
|
- if ($value != null && $value->get_filename() != ".") {
|
|
|
- // 6.A. Fazer uma cópia:
|
|
|
- $newfile = $fs->create_file_from_storedfile(array('contextid' => $context, 'component' => 'mod_iassign', 'filearea' => 'exercise', 'itemid' => $iassign_statement_activity_item->id), $value);
|
|
|
-
|
|
|
- // 6.B. Atualizar o registro da atividade para o arquivo novo:
|
|
|
- $update_entry = new stdClass();
|
|
|
- $update_entry->id = $iassign_statement_activity_item->id;
|
|
|
- $update_entry->file = $newfile->get_itemid();
|
|
|
- $DB->update_record("iassign_statement", $update_entry);
|
|
|
-
|
|
|
- // 6.C. Remover o arquivo antigo:
|
|
|
- $value->delete();
|
|
|
- } else if ($value != null && $value->get_filename() == ".") {
|
|
|
- // 6.C.I. Remover também os indicadores de diretório:
|
|
|
- $value->delete();
|
|
|
- }
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- } // if ($oldversion < 2020102800)
|
|
|
+ // Adding field iassing_statement.filesid
|
|
|
+ $table = new xmldb_table('iassign_statement');
|
|
|
|
|
|
- /// @Igor - adicionar a tabela iassign_allsubmissions
|
|
|
- if ($oldversion < 2020112000) {
|
|
|
+ $field_filesid = new xmldb_field('filesid', XMLDB_TYPE_CHAR, '255', null, null, null, null, null);
|
|
|
|
|
|
- // Define table iassign_allsubmissions to be created.
|
|
|
- $table = new xmldb_table('iassign_allsubmissions');
|
|
|
+ if (!$dbman->field_exists($table, $field_filesid))
|
|
|
+ $dbman->add_field($table, $field_filesid);
|
|
|
+
|
|
|
+ // Updating all registers from iassing_statement.filesid
|
|
|
+ $DB->execute("UPDATE {iassign_statement} SET filesid = file");
|
|
|
|
|
|
- // Adding fields to table iassign_allsubmissions.
|
|
|
- $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
|
|
- $table->add_field('iassign_statementid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
|
|
|
- $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
|
|
|
- $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '16', null, XMLDB_NOTNULL, null, null);
|
|
|
- $table->add_field('grade', XMLDB_TYPE_FLOAT, null, null, null, null, null, null);
|
|
|
- $table->add_field('answer', XMLDB_TYPE_TEXT, 'long', null, null, null, null, null);
|
|
|
|
|
|
- // Adding keys to table iassign_allsubmissions.
|
|
|
- $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
|
|
|
+ // 1. encontrar os contextos dos arquivos do itarefa:
|
|
|
+ $iassign_contexts_list = $DB->get_records_sql("SELECT DISTINCT contextid FROM {files} f WHERE component='mod_iassign'");
|
|
|
+ // 2. compor um array com todos os contextos encontrados:
|
|
|
+ $contexts = array();
|
|
|
+ foreach ($iassign_contexts_list as $iassign_context_item) {
|
|
|
+ array_push($contexts, $iassign_context_item->contextid);
|
|
|
+ }
|
|
|
+ // 3. encontrar todas as atividades do itarefa, em que o arquivo não tenha o mesmo id do statement:
|
|
|
+ $iassign_statement_list = $DB->get_records_sql("SELECT * FROM {iassign_statement} s WHERE s.id != s.file");
|
|
|
+ $fs = get_file_storage();
|
|
|
|
|
|
- // Conditionally launch create table for iassign_allsubmissions.
|
|
|
- if (!$dbman->table_exists($table)) {
|
|
|
- $dbman->create_table($table);
|
|
|
+ // 4. percorrer o conjunto de atividades:
|
|
|
+ foreach ($iassign_statement_list as $iassign_statement_activity_item) {
|
|
|
+
|
|
|
+ // 5. encontrar o arquivo, considerando os possíveis contextos:
|
|
|
+ $files = array();
|
|
|
+ foreach ($contexts as $context) {
|
|
|
+
|
|
|
+ $files = $fs->get_area_files($context, 'mod_iassign', 'exercise', $iassign_statement_activity_item->file);
|
|
|
+
|
|
|
+ // 6. se o arquivo for encontrado, fazer uma cópia do conteúdo,
|
|
|
+ // com o itemid novo, atualizar o iassign_statement, e apagar o arquivo antigo:
|
|
|
+ if ($files) {
|
|
|
+ foreach ($files as $value) {
|
|
|
+ if ($value != null && $value->get_filename() != ".") {
|
|
|
+ // 6.A. Fazer uma cópia:
|
|
|
+ $newfile = $fs->create_file_from_storedfile(array('contextid' => $context, 'component' => 'mod_iassign', 'filearea' => 'exercise', 'itemid' => $iassign_statement_activity_item->id), $value);
|
|
|
+
|
|
|
+ // 6.B. Atualizar o registro da atividade para o arquivo novo:
|
|
|
+ $update_entry = new stdClass();
|
|
|
+ $update_entry->id = $iassign_statement_activity_item->id;
|
|
|
+ $update_entry->file = $newfile->get_itemid();
|
|
|
+ $update_entry->filesid = $newfile->get_itemid();
|
|
|
+ $DB->update_record("iassign_statement", $update_entry);
|
|
|
+
|
|
|
+ // 6.C. Remover o arquivo antigo:
|
|
|
+ $value->delete();
|
|
|
+ }
|
|
|
+ else if ($value != null && $value->get_filename() == ".") {
|
|
|
+ // 6.C.I. Remover também os indicadores de diretório:
|
|
|
+ $value->delete();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ } // 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) {
|
|
|
+
|
|
|
+ // Define table iassign_allsubmissions to be created.
|
|
|
+ $table = new xmldb_table('iassign_allsubmissions');
|
|
|
+
|
|
|
+ // Adding fields to table iassign_allsubmissions.
|
|
|
+ $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
|
|
+ $table->add_field('iassign_statementid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
|
|
|
+ $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
|
|
|
+ $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '16', null, XMLDB_NOTNULL, null, null);
|
|
|
+ $table->add_field('grade', XMLDB_TYPE_FLOAT, null, null, null, null, null, null);
|
|
|
+ $table->add_field('answer', XMLDB_TYPE_TEXT, 'long', null, null, null, null, null);
|
|
|
+
|
|
|
+ // Adding keys to table iassign_allsubmissions.
|
|
|
+ $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
|
|
|
+
|
|
|
+ // Conditionally launch create table for iassign_allsubmissions.
|
|
|
+ if (!$dbman->table_exists($table)) {
|
|
|
+ $dbman->create_table($table);
|
|
|
}
|
|
|
|
|
|
- // Adding fields to table iassign_ilm.
|
|
|
- $table = new xmldb_table('iassign_ilm');
|
|
|
+ // Adding fields to table iassign_ilm.
|
|
|
+ $table = new xmldb_table('iassign_ilm');
|
|
|
|
|
|
- $field_editingbehavior = new xmldb_field('editingbehavior', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', null);
|
|
|
+ $field_editingbehavior = new xmldb_field('editingbehavior', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', null);
|
|
|
|
|
|
- if (!$dbman->field_exists($table, $field_editingbehavior))
|
|
|
- $dbman->add_field($table, $field_editingbehavior);
|
|
|
+ if (!$dbman->field_exists($table, $field_editingbehavior))
|
|
|
+ $dbman->add_field($table, $field_editingbehavior);
|
|
|
|
|
|
- $field_submissionbehavior = new xmldb_field('submissionbehavior', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', null);
|
|
|
+ $field_submissionbehavior = new xmldb_field('submissionbehavior', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', null);
|
|
|
|
|
|
- if (!$dbman->field_exists($table, $field_submissionbehavior))
|
|
|
- $dbman->add_field($table, $field_submissionbehavior);
|
|
|
+ if (!$dbman->field_exists($table, $field_submissionbehavior))
|
|
|
+ $dbman->add_field($table, $field_submissionbehavior);
|
|
|
|
|
|
- $field_action_buttons = new xmldb_field('action_buttons', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '1', null);
|
|
|
-
|
|
|
- if (!$dbman->field_exists($table, $field_action_buttons))
|
|
|
- $dbman->add_field($table, $field_action_buttons);
|
|
|
+ $field_action_buttons = new xmldb_field('action_buttons', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '1', null);
|
|
|
+
|
|
|
+ if (!$dbman->field_exists($table, $field_action_buttons))
|
|
|
+ $dbman->add_field($table, $field_action_buttons);
|
|
|
|
|
|
- // Adding field to table iassign_statement:
|
|
|
- $table = new xmldb_table('iassign_statement');
|
|
|
+ // Adding field to table iassign_statement:
|
|
|
+ $table = new xmldb_table('iassign_statement');
|
|
|
|
|
|
- $field_store_all_submissions = new xmldb_field('store_all_submissions', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', null);
|
|
|
+ $field_store_all_submissions = new xmldb_field('store_all_submissions', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', null);
|
|
|
|
|
|
- if (!$dbman->field_exists($table, $field_store_all_submissions))
|
|
|
- $dbman->add_field($table, $field_store_all_submissions);
|
|
|
+ if (!$dbman->field_exists($table, $field_store_all_submissions))
|
|
|
+ $dbman->add_field($table, $field_store_all_submissions);
|
|
|
|
|
|
- // Update new fields for previous installed iLM:
|
|
|
- $iassign_ilm = $DB->get_records('iassign_ilm');
|
|
|
- foreach ($iassign_ilm as $iassign) {
|
|
|
- $updateentry = new stdClass();
|
|
|
- $updateentry->id = $iassign->id;
|
|
|
- if (($iassign->name == 'iHanoi' && $iassign->type == 'HTML5')) {
|
|
|
- $updateentry->editingbehavior = 0;
|
|
|
- $updateentry->submissionbehavior = 0;
|
|
|
+ // Update new fields for previous installed iLM:
|
|
|
+ $iassign_ilm = $DB->get_records('iassign_ilm');
|
|
|
+ foreach ($iassign_ilm as $iassign) {
|
|
|
+ $updateentry = new stdClass();
|
|
|
+ $updateentry->id = $iassign->id;
|
|
|
+ if (($iassign->name == 'iHanoi' && $iassign->type == 'HTML5')) {
|
|
|
+ $updateentry->editingbehavior = 0;
|
|
|
+ $updateentry->submissionbehavior = 0;
|
|
|
}
|
|
|
- if (($iassign->name == 'iGeom' && $iassign->type == 'Java')) {
|
|
|
- $updateentry->editingbehavior = 0;
|
|
|
- $updateentry->submissionbehavior = 0;
|
|
|
+ if (($iassign->name == 'iGeom' && $iassign->type == 'Java')) {
|
|
|
+ $updateentry->editingbehavior = 0;
|
|
|
+ $updateentry->submissionbehavior = 0;
|
|
|
}
|
|
|
- if (($iassign->name == 'iVProg' && $iassign->type == 'HTML5')) {
|
|
|
- $updateentry->editingbehavior = 1;
|
|
|
- $updateentry->submissionbehavior = 0;
|
|
|
+ if (($iassign->name == 'iVProg' && $iassign->type == 'HTML5')) {
|
|
|
+ $updateentry->editingbehavior = 1;
|
|
|
+ $updateentry->submissionbehavior = 0;
|
|
|
}
|
|
|
- if (($iassign->name == 'iFractions' && $iassign->type == 'HTML5')) {
|
|
|
- $updateentry->editingbehavior = 0;
|
|
|
- $updateentry->submissionbehavior = 1;
|
|
|
+ if (($iassign->name == 'iFractions' && $iassign->type == 'HTML5')) {
|
|
|
+ $updateentry->editingbehavior = 0;
|
|
|
+ $updateentry->submissionbehavior = 1;
|
|
|
}
|
|
|
- if (($iassign->name == 'Risko' && $iassign->type == 'Java')) {
|
|
|
- $updateentry->editingbehavior = 1;
|
|
|
- $updateentry->submissionbehavior = 0;
|
|
|
+ if (($iassign->name == 'Risko' && $iassign->type == 'Java')) {
|
|
|
+ $updateentry->editingbehavior = 1;
|
|
|
+ $updateentry->submissionbehavior = 0;
|
|
|
}
|
|
|
- if (isset($updateentry->editingbehavior)) {
|
|
|
- $updateentry->timemodified = time();
|
|
|
- $DB->update_record("iassign_ilm", $updateentry);
|
|
|
+ if (isset($updateentry->editingbehavior)) {
|
|
|
+ $updateentry->timemodified = time();
|
|
|
+ $DB->update_record("iassign_ilm", $updateentry);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // Add iassign_allsubmissions table
|
|
|
- $table = new xmldb_table('iassign_allsubmissions');
|
|
|
+ // Add iassign_allsubmissions table
|
|
|
+ $table = new xmldb_table('iassign_allsubmissions');
|
|
|
|
|
|
- if (!$dbman->table_exists($table)) {
|
|
|
- $field1 = new xmldb_field('id');
|
|
|
- $field1->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null);
|
|
|
+ if (!$dbman->table_exists($table)) {
|
|
|
+ $field1 = new xmldb_field('id');
|
|
|
+ $field1->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null);
|
|
|
|
|
|
- $field2 = new xmldb_field('iassign_statementid');
|
|
|
- $field2->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null);
|
|
|
+ $field2 = new xmldb_field('iassign_statementid');
|
|
|
+ $field2->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null);
|
|
|
|
|
|
- $field3 = new xmldb_field('userid');
|
|
|
- $field3->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null);
|
|
|
-
|
|
|
- $field4 = new xmldb_field('timecreated');
|
|
|
- $field4->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null);
|
|
|
+ $field3 = new xmldb_field('userid');
|
|
|
+ $field3->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null);
|
|
|
+
|
|
|
+ $field4 = new xmldb_field('timecreated');
|
|
|
+ $field4->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null);
|
|
|
|
|
|
- $field5 = new xmldb_field('grade');
|
|
|
- $field5->set_attributes(XMLDB_TYPE_FLOAT, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null);
|
|
|
+ $field5 = new xmldb_field('grade');
|
|
|
+ $field5->set_attributes(XMLDB_TYPE_FLOAT, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null);
|
|
|
|
|
|
- $field6 = new xmldb_field('answer');
|
|
|
- $field6->set_attributes(XMLDB_TYPE_TEXT, 'long', null, null, null, null, 'type');
|
|
|
+ $field6 = new xmldb_field('answer');
|
|
|
+ $field6->set_attributes(XMLDB_TYPE_TEXT, 'long', null, null, null, null, 'type');
|
|
|
|
|
|
- $table->addIndex($field1);
|
|
|
- $table->addField($field2);
|
|
|
- $table->addField($field3);
|
|
|
- $table->addField($field4);
|
|
|
- $table->addField($field5);
|
|
|
- $table->addField($field6);
|
|
|
+ $table->addIndex($field1);
|
|
|
+ $table->addField($field2);
|
|
|
+ $table->addField($field3);
|
|
|
+ $table->addField($field4);
|
|
|
+ $table->addField($field5);
|
|
|
+ $table->addField($field6);
|
|
|
|
|
|
- $dbman->create_table($table);
|
|
|
- }
|
|
|
+ $dbman->create_table($table);
|
|
|
+ } // if (!$dbman->table_exists($table))
|
|
|
+
|
|
|
+ // Update file_jar field:
|
|
|
+ try {
|
|
|
+ $DB->execute("ALTER TABLE {iassign_ilm} DROP INDEX {iassilm_fil_uix}");
|
|
|
+ } catch (Exception $ex) {}
|
|
|
|
|
|
- } // if ($oldversion < 2020112000) {
|
|
|
+ } // if ($oldversion < 2020122900)
|
|
|
|
|
|
// log event -----------------------------------------------------
|
|
|
if (class_exists('plugin_manager'))
|