|
@@ -50,333 +50,6 @@ function xmldb_iassign_upgrade ($oldversion) {
|
|
|
|
|
|
$dbman = $DB->get_manager();
|
|
|
|
|
|
- if ($oldversion < 2014012100) {
|
|
|
-
|
|
|
- $table = new xmldb_table('iassign_ilm');
|
|
|
- $index_name = new xmldb_index('name');
|
|
|
- $index_name->set_attributes(XMLDB_INDEX_UNIQUE, array('name'));
|
|
|
- if ($dbman->index_exists($table, $index_name)) {
|
|
|
- $dbman->drop_index($table, $index_name, $continue = true, $feedback = true);
|
|
|
- }
|
|
|
- $index_name_version = new xmldb_index('name_version');
|
|
|
- $index_name_version->set_attributes(XMLDB_INDEX_UNIQUE, array('name', 'version'));
|
|
|
- if (!$dbman->index_exists($table, $index_name_version)) {
|
|
|
- $dbman->add_index($table, $index_name_version, $continue = true, $feedback = true);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- $table = new xmldb_table('iassign_ilm');
|
|
|
- $field_height = new xmldb_field('heigth', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '600', 'width');
|
|
|
- if ($dbman->field_exists($table, $field_height))
|
|
|
- $dbman->rename_field($table, $field_height, 'height');
|
|
|
-
|
|
|
-
|
|
|
- $table = new xmldb_table('iassign');
|
|
|
- $field_intro = new xmldb_field('intro', XMLDB_TYPE_TEXT, 'medium', null, null, null, null, 'name');
|
|
|
- if (!$dbman->field_exists($table, $field_intro))
|
|
|
- $dbman->add_field($table, $field_intro);
|
|
|
- $field_introformat = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '0', 'intro');
|
|
|
- if (!$dbman->field_exists($table, $field_introformat))
|
|
|
- $dbman->add_field($table, $field_introformat);
|
|
|
- $field_grade = new xmldb_field('grade', XMLDB_TYPE_INTEGER, '11', null, XMLDB_NOTNULL, null, '0', 'activity_group');
|
|
|
- if (!$dbman->field_exists($table, $field_grade))
|
|
|
- $dbman->add_field($table, $field_grade);
|
|
|
- $field_timeavailable = new xmldb_field('timeavailable', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'grade');
|
|
|
- if (!$dbman->field_exists($table, $field_timeavailable))
|
|
|
- $dbman->add_field($table, $field_timeavailable);
|
|
|
- $field_timedue = new xmldb_field('timedue', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'timeavailable');
|
|
|
- if (!$dbman->field_exists($table, $field_timedue))
|
|
|
- $dbman->add_field($table, $field_timedue);
|
|
|
- $field_preventlate = new xmldb_field('preventlate', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, null, null, '1', 'timedue');
|
|
|
- if (!$dbman->field_exists($table, $field_preventlate))
|
|
|
- $dbman->add_field($table, $field_preventlate);
|
|
|
- $field_test = new xmldb_field('test', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, '0', 'preventlate');
|
|
|
- if (!$dbman->field_exists($table, $field_test))
|
|
|
- $dbman->add_field($table, $field_test);
|
|
|
- $field_max_experiment = new xmldb_field('max_experiment', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'test');
|
|
|
- if (!$dbman->field_exists($table, $field_max_experiment))
|
|
|
- $dbman->add_field($table, $field_max_experiment);
|
|
|
-
|
|
|
- if (!$dbman->table_exists($table)) {
|
|
|
- $field_id = new xmldb_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE);
|
|
|
- $field_time = new xmldb_field('time', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'id');
|
|
|
- $field_userid = new xmldb_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'time');
|
|
|
- $field_ip = new xmldb_field('ip', XMLDB_TYPE_CHAR, '255', null, null, null, null, 'userid');
|
|
|
- $field_course = new xmldb_field('course', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'ip');
|
|
|
- $field_cmid = new xmldb_field('cmid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'course');
|
|
|
- $field_ilmid = new xmldb_field('ilmid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'cmid');
|
|
|
- $field_action = new xmldb_field('action', XMLDB_TYPE_CHAR, '255', null, null, null, null, 'ilmid');
|
|
|
- $field_info = new xmldb_field('info', XMLDB_TYPE_TEXT, 'medium', null, null, null, null, 'action');
|
|
|
- $field_language = new xmldb_field('language', XMLDB_TYPE_CHAR, '10', null, null, null, null, 'info');
|
|
|
- $field_user_agent = new xmldb_field('user_agent', XMLDB_TYPE_TEXT, 'medium', null, null, null, null, 'language');
|
|
|
- $field_javascript = new xmldb_field('javascript', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'user_agent');
|
|
|
- $field_java = new xmldb_field('java', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'javascript');
|
|
|
-
|
|
|
- $key = new xmldb_key('primary');
|
|
|
- $key->set_attributes(XMLDB_KEY_PRIMARY, array('id'), null, null);
|
|
|
-
|
|
|
- $index = new xmldb_index('course');
|
|
|
- $index->set_attributes(XMLDB_INDEX_NOTUNIQUE, array('course'));
|
|
|
-
|
|
|
- $table->addField($field_id);
|
|
|
- $table->addField($field_time);
|
|
|
- $table->addField($field_userid);
|
|
|
- $table->addField($field_ip);
|
|
|
- $table->addField($field_course);
|
|
|
- $table->addField($field_cmid);
|
|
|
- $table->addField($field_ilmid);
|
|
|
- $table->addField($field_action);
|
|
|
- $table->addField($field_info);
|
|
|
- $table->addField($field_language);
|
|
|
- $table->addField($field_user_agent);
|
|
|
- $table->addField($field_javascript);
|
|
|
- $table->addField($field_java);
|
|
|
-
|
|
|
- $table->addKey($key);
|
|
|
-
|
|
|
- $table->addIndex($index);
|
|
|
-
|
|
|
- $status = $dbman->create_table($table);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- $fs = get_file_storage();
|
|
|
- $is_delete = true;
|
|
|
- $ilm_path = $CFG->dirroot . "/mod/iassign/ilm/";
|
|
|
-
|
|
|
-
|
|
|
- $exercise_files = $DB->get_records('files', array("component" => "mod_iassign", "filearea" => "activity"));
|
|
|
- foreach ($exercise_files as $exercise_file) {
|
|
|
- $exercise_file->filearea = "exercise";
|
|
|
- $DB->update_record('files', $exercise_file);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- $activity_files = $DB->get_records('files', array("component" => "mod_iassign", "filearea" => "ilm"));
|
|
|
- foreach ($activity_files as $activity_file) {
|
|
|
- $activity_file->filearea = "activity";
|
|
|
- $DB->update_record('files', $activity_file);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- upgrade_mod_savepoint(true, 2014012100, 'iassign');
|
|
|
- }
|
|
|
-
|
|
|
- if ($oldversion < 2017021900) {
|
|
|
-
|
|
|
- $count_iassign_ilm = $DB->count_records_sql('SELECT COUNT(id) FROM {iassign_ilm}');
|
|
|
- if ($count_iassign_ilm>0) {
|
|
|
-
|
|
|
-
|
|
|
- $context = context_system::instance();
|
|
|
- $file_ilm = array(
|
|
|
- 'userid' => $USER->id,
|
|
|
- 'contextid' => $context->id,
|
|
|
- 'component' => 'mod_iassign',
|
|
|
- 'filearea' => 'ilm',
|
|
|
- 'itemid' => 0,
|
|
|
- 'filepath' => '/iassign/ilm/',
|
|
|
- 'filename' => "iVProg/1.0.20200221/ivprog/index.html");
|
|
|
-
|
|
|
-
|
|
|
- $fs = get_file_storage();
|
|
|
- $is_delete = true;
|
|
|
- $ilm_path = $CFG->dirroot . "/mod/iassign/ilm/";
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- $file_ilm = $fs->create_file_from_string($file_ilm, file_get_contents($ilm_path . "ivprog-html/main.html"));
|
|
|
-
|
|
|
- if ($file_ilm)
|
|
|
- $is_delete &= @unlink($ilm_path . "ivprog-html");
|
|
|
-
|
|
|
-
|
|
|
- $newentry = new stdClass();
|
|
|
- $newentry->name = 'iVProg';
|
|
|
- $newentry->url = 'http://www.matematica.br/ivprog';
|
|
|
- $newentry->version = '1.0.20200221';
|
|
|
- $newentry->description = '{"en":"Visual Interactive Programming on the Internet HTML5","pt_br":"Programação visual interativa na Internet"}';
|
|
|
- $newentry->extension = 'ivph';
|
|
|
- $newentry->file_jar = 'iVProg/1.0.20200221/ivprog/';
|
|
|
- $newentry->file_class = 'index.html';
|
|
|
- $newentry->width = 800;
|
|
|
- $newentry->height = 700;
|
|
|
- $newentry->enable = 1;
|
|
|
- $newentry->timemodified = time();
|
|
|
- $newentry->author = $USER->id;
|
|
|
- $newentry->timecreated = time();
|
|
|
- $newentry->evaluate = 1;
|
|
|
-
|
|
|
- $newentry->id = $DB->insert_record("iassign_ilm", $newentry);
|
|
|
-
|
|
|
-
|
|
|
- upgrade_mod_savepoint(true, 2017021900, 'iassign');
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- if ($oldversion < 2017120100) {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- $table = new xmldb_table('iassign_ilm');
|
|
|
- $new_field_type = new xmldb_field('type', XMLDB_TYPE_CHAR, '20', null, null, null, null, 'version');
|
|
|
- if (!$dbman->field_exists($table, $new_field_type))
|
|
|
- $dbman->add_field($table, $new_field_type);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- $list_of_ilm_installed = $DB->get_records('iassign_ilm');
|
|
|
- foreach ($list_of_ilm_installed as $ilm_installed) {
|
|
|
- $ilm_name = strtolower($ilm_installed->name);
|
|
|
-
|
|
|
- if ($ilm_name=="ivprogh5" || $ilm_name=="ifractions" || $ilm_name=="fractions") {
|
|
|
- $ilm_installed->type = "HTML5";
|
|
|
- $file_jar = strtolower($ilm_installed->file_jar);
|
|
|
- if ($ilm_name=="ivprogh5" && $file_jar=="ivprogh5") {
|
|
|
- $ilm_installed->file_jar = "ilm/ivprog-html/";
|
|
|
- $ilm_installed->file_class = "main.html";
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- $ilm_installed->type = "Java";
|
|
|
-
|
|
|
- $DB->update_record('iassign_ilm', $ilm_installed);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- if ($oldversion < 2018031000) {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- $records = array(
|
|
|
- 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)),
|
|
|
- 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)),
|
|
|
- );
|
|
|
-
|
|
|
- foreach ($records as $record) {
|
|
|
- if ($record['type'] == 'HTML5') {
|
|
|
-
|
|
|
-
|
|
|
- $iassign_ilm = $DB->get_records('iassign_ilm', array('name' => $record['name']));
|
|
|
-
|
|
|
- if ($iassign_ilm) {
|
|
|
-
|
|
|
-
|
|
|
- foreach ($iassign_ilm as $iassign) {
|
|
|
- $iassign->name = trim($iassign->name);
|
|
|
- $iassign->version = trim($iassign->version);
|
|
|
-
|
|
|
- if ($iassign->version == $record['version']) {
|
|
|
- $newentry = new stdClass();
|
|
|
- $newentry->id = $iassign->id;
|
|
|
- $newentry->file_jar = $record['file_jar'];
|
|
|
- $newentry->file_class = $record['file_class'];
|
|
|
-
|
|
|
- $DB->update_record("iassign_ilm", $newentry);
|
|
|
- }
|
|
|
- else {
|
|
|
- $dest = $CFG->dirroot . '/mod/iassign/ilm/' . $iassign->name . '/' . $iassign->version . '/';
|
|
|
- mkdir($dest, 0755);
|
|
|
-
|
|
|
- $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 . $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 {
|
|
|
-
|
|
|
- $DB->insert_record('iassign_ilm', $record, false);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- else {
|
|
|
-
|
|
|
-
|
|
|
- $iassign_ilm = $DB->get_record('iassign_ilm', array('name' => $record['name'], 'version' => $record['version']));
|
|
|
-
|
|
|
- if ($iassign_ilm) {
|
|
|
-
|
|
|
- $newentry = new stdClass();
|
|
|
- $newentry->id = $iassign_ilm->id;
|
|
|
- $newentry->file_jar = $record['file_jar'];
|
|
|
- $newentry->file_class = $record['file_class'];
|
|
|
-
|
|
|
- $DB->update_record("iassign_ilm", $newentry);
|
|
|
- }
|
|
|
- else {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- $iassign_ilm_parent = $DB->get_record('iassign_ilm', array('name' => $record['name'], 'parent' => 0));
|
|
|
-
|
|
|
- if ($iassign_ilm_parent) {
|
|
|
- $record['parent'] = $iassign_ilm_parent->id;
|
|
|
- $DB->insert_record('iassign_ilm', $record, false);
|
|
|
-
|
|
|
-
|
|
|
- $dest = $CFG->dirroot . '/mod/iassign/ilm/' . $iassign_ilm_parent->name . '/' . $iassign_ilm_parent->version . '/';
|
|
|
- mkdir($dest, 0777);
|
|
|
-
|
|
|
- $fs = get_file_storage();
|
|
|
- $file = $fs->get_file_by_id($iassign_ilm_parent->file_jar);
|
|
|
- $file->copy_content_to($dest . $file->get_filename());
|
|
|
-
|
|
|
-
|
|
|
- $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();
|
|
|
-
|
|
|
- $DB->update_record("iassign_ilm", $update_parent);
|
|
|
-
|
|
|
- }
|
|
|
- else {
|
|
|
- $DB->insert_record('iassign_ilm', $record, false);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
if ($oldversion < 2020070613) {
|
|
|
$table = new xmldb_table('iassign_submission');
|
|
@@ -665,6 +338,29 @@ function xmldb_iassign_upgrade ($oldversion) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ if ($oldversion < 2020112000) {
|
|
|
+
|
|
|
+
|
|
|
+ $table = new xmldb_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);
|
|
|
+
|
|
|
+
|
|
|
+ $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
|
|
|
+
|
|
|
+
|
|
|
+ if (!$dbman->table_exists($table)) {
|
|
|
+ $dbman->create_table($table);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
|
|
|
if (class_exists('plugin_manager'))
|