Fix upgrade process.

1.10.x
Julio Montoya 9 years ago
parent b89d62c14f
commit b3a91ac99a
  1. 48
      app/Migrations/Schema/V110/Version110.php
  2. 106
      app/Migrations/Schema/V110/Version20150505132304.php
  3. 23
      app/Migrations/Schema/V110/Version20150507152600.php
  4. 2
      app/Migrations/Schema/V110/Version20150511133949.php
  5. 1
      app/Migrations/Schema/V110/Version20150522112023.php
  6. 1
      app/Migrations/Schema/V110/Version20150527101600.php
  7. 3
      app/Migrations/Schema/V110/Version20150603181728.php
  8. 12
      app/Migrations/Schema/V110/Version20150713132630.php
  9. 5
      main/admin/sub_language.class.php
  10. 4
      main/inc/lib/database.constants.inc.php
  11. 2
      main/install/index.php
  12. 240
      main/install/install.lib.php
  13. 21
      src/Chamilo/CoreBundle/Entity/GradeComponents.php
  14. 21
      src/Chamilo/CoreBundle/Entity/GradeModel.php
  15. 20
      src/Chamilo/CoreBundle/Entity/GradebookCategory.php
  16. 21
      src/Chamilo/CoreBundle/Entity/GradebookCertificate.php
  17. 21
      src/Chamilo/CoreBundle/Entity/GradebookEvaluation.php
  18. 22
      src/Chamilo/CoreBundle/Entity/GradebookLink.php
  19. 1
      src/Chamilo/CoreBundle/Entity/GradebookLinkevalLog.php
  20. 1
      src/Chamilo/CoreBundle/Entity/GradebookResult.php
  21. 1
      src/Chamilo/CoreBundle/Entity/GradebookResultLog.php
  22. 1
      src/Chamilo/CoreBundle/Entity/GradebookScoreDisplay.php
  23. 4
      src/Chamilo/CoreBundle/Entity/SettingsCurrent.php
  24. 23
      src/Chamilo/CoreBundle/Entity/SettingsOptions.php

@ -29,10 +29,10 @@ class Version110 extends AbstractMigrationChamilo
$this->addSql("CREATE TABLE IF NOT EXISTS hook_observer( id int UNSIGNED NOT NULL AUTO_INCREMENT, class_name varchar(255) UNIQUE, path varchar(255) NOT NULL, plugin_name varchar(255) NULL, PRIMARY KEY PK_hook_management_hook_observer(id))");
$this->addSql("CREATE TABLE IF NOT EXISTS hook_event( id int UNSIGNED NOT NULL AUTO_INCREMENT, class_name varchar(255) UNIQUE, description varchar(255), PRIMARY KEY PK_hook_management_hook_event(id))");
$this->addSql("CREATE TABLE IF NOT EXISTS hook_call( id int UNSIGNED NOT NULL AUTO_INCREMENT, hook_event_id int UNSIGNED NOT NULL, hook_observer_id int UNSIGNED NOT NULL, type tinyint NOT NULL, hook_order int UNSIGNED NOT NULL, enabled tinyint NOT NULL, PRIMARY KEY PK_hook_management_hook_call(id))");
$this->addSql("CREATE TABLE IF NOT EXISTS c_student_publication_rel_document (id INT PRIMARY KEY NOT NULL AUTO_INCREMENT, work_id INT NOT NULL, document_id INT NOT NULL, c_id INT NOT NULL)");
$this->addSql("CREATE TABLE IF NOT EXISTS c_student_publication_rel_user (id INT PRIMARY KEY NOT NULL AUTO_INCREMENT, work_id INT NOT NULL, user_id INT NOT NULL, c_id INT NOT NULL)");
$this->addSql("CREATE TABLE IF NOT EXISTS c_student_publication_comment (id INT PRIMARY KEY NOT NULL AUTO_INCREMENT, work_id INT NOT NULL, c_id INT NOT NULL, comment text, file VARCHAR(255), user_id int NOT NULL, sent_at datetime NOT NULL)");
$this->addSql("CREATE TABLE IF NOT EXISTS c_attendance_calendar_rel_group (id int NOT NULL auto_increment PRIMARY KEY, c_id INT NOT NULL, group_id INT NOT NULL, calendar_id INT NOT NULL)");
$this->addSql("CREATE TABLE IF NOT EXISTS c_student_publication_rel_document (iid INT PRIMARY KEY NOT NULL AUTO_INCREMENT, id INT, work_id INT NOT NULL, document_id INT NOT NULL, c_id INT NOT NULL)");
$this->addSql("CREATE TABLE IF NOT EXISTS c_student_publication_rel_user (iid INT PRIMARY KEY NOT NULL AUTO_INCREMENT, id INT, work_id INT NOT NULL, user_id INT NOT NULL, c_id INT NOT NULL)");
$this->addSql("CREATE TABLE IF NOT EXISTS c_student_publication_comment (iid INT PRIMARY KEY NOT NULL AUTO_INCREMENT, id INT, work_id INT NOT NULL, c_id INT NOT NULL, comment text, file VARCHAR(255), user_id int NOT NULL, sent_at datetime NOT NULL)");
$this->addSql("CREATE TABLE IF NOT EXISTS c_attendance_calendar_rel_group (iid int NOT NULL auto_increment PRIMARY KEY, id INT, c_id INT NOT NULL, group_id INT NOT NULL, calendar_id INT NOT NULL)");
//$this->addSql("ALTER TABLE skill_rel_user ADD COLUMN course_id INT NOT NULL DEFAULT 0 AFTER id");
//$this->addSql("ALTER TABLE skill_rel_user ADD COLUMN session_id INT NOT NULL DEFAULT 0 AFTER course_id");
@ -178,9 +178,9 @@ class Version110 extends AbstractMigrationChamilo
//'c_role_user',
'c_student_publication',
'c_student_publication_assignment',
//'c_student_publication_comment',
//'c_student_publication_rel_document',
//'c_student_publication_rel_user',
'c_student_publication_comment',
'c_student_publication_rel_document',
'c_student_publication_rel_user',
//'c_survey',
//'c_survey_answer',
'c_survey_group',
@ -201,20 +201,19 @@ class Version110 extends AbstractMigrationChamilo
];
foreach ($tables as $table) {
$this->addSql("ALTER TABLE $table MODIFY COLUMN id int unsigned DEFAULT NULL");
$this->addSql("ALTER TABLE $table MODIFY COLUMN c_id int unsigned DEFAULT NULL");
$this->addSql("ALTER TABLE $table DROP PRIMARY KEY");
$this->addSql("ALTER TABLE $table ADD COLUMN iid int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT");
if ($schema->hasTable($table)) {
$this->addSql("ALTER TABLE $table MODIFY COLUMN id int unsigned DEFAULT NULL");
$this->addSql("ALTER TABLE $table MODIFY COLUMN c_id int unsigned DEFAULT NULL");
$this->addSql("ALTER TABLE $table DROP PRIMARY KEY");
$this->addSql("ALTER TABLE $table ADD COLUMN iid int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT");
}
}
$this->addSql("ALTER TABLE c_attendance_calendar_rel_group MODIFY COLUMN id int unsigned DEFAULT NULL");
$this->addSql("ALTER TABLE c_attendance_calendar_rel_group DROP PRIMARY KEY");
$this->addSql("ALTER TABLE c_attendance_calendar_rel_group ADD COLUMN iid int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT");
$this->addSql("ALTER TABLE c_student_publication_comment MODIFY COLUMN id int unsigned DEFAULT NULL");
$this->addSql("ALTER TABLE c_student_publication_comment DROP PRIMARY KEY");
$this->addSql("ALTER TABLE c_student_publication_comment ADD COLUMN iid int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT");
if ($schema->hasTable('c_attendance_calendar_rel_group')) {
$this->addSql("ALTER TABLE c_attendance_calendar_rel_group MODIFY COLUMN id int unsigned DEFAULT NULL");
$this->addSql("ALTER TABLE c_attendance_calendar_rel_group DROP PRIMARY KEY");
$this->addSql("ALTER TABLE c_attendance_calendar_rel_group ADD COLUMN iid int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT");
}
$this->addSql("ALTER TABLE c_attendance_sheet MODIFY COLUMN c_id int unsigned DEFAULT NULL");
$this->addSql("ALTER TABLE c_attendance_sheet DROP PRIMARY KEY");
@ -334,7 +333,7 @@ class Version110 extends AbstractMigrationChamilo
$this->addSql("ALTER TABLE c_quiz_answer MODIFY COLUMN c_id int unsigned DEFAULT NULL");
$this->addSql("ALTER TABLE c_quiz_answer MODIFY COLUMN id_auto int unsigned DEFAULT NULL");
$this->addSql("ALTER TABLE c_quiz_answer DROP PRIMARY KEY");
$this->addSql("ALTER TABLE c_quiz_answer MODIFY COLUMN id_auto int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT");
$this->addSql("ALTER TABLE c_quiz_answer ADD COLUMN iid int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT");
$this->addSql("ALTER TABLE c_quiz_question_rel_category MODIFY COLUMN c_id int unsigned DEFAULT NULL");
$this->addSql("ALTER TABLE c_quiz_question_rel_category MODIFY COLUMN question_id int unsigned DEFAULT NULL");
@ -441,6 +440,11 @@ class Version110 extends AbstractMigrationChamilo
$this->addSql("UPDATE access_url_rel_course SET c_id = (SELECT id FROM course WHERE code = course_code)");
$this->addSql("ALTER TABLE settings_current DROP INDEX unique_setting");
$this->addSql("ALTER TABLE settings_options DROP INDEX unique_setting_option");
$this->addSql("DELETE FROM settings_current WHERE variable = 'wcag_anysurfer_public_pages'");
$this->addSql("DELETE FROM settings_current WHERE variable = 'wcag_anysurfer_public_pages'");
$this->addSql("DELETE FROM settings_options WHERE variable = 'wcag_anysurfer_public_pages'");
$this->addSql("DELETE FROM settings_current WHERE variable = 'advanced_filemanager'");
@ -460,10 +464,6 @@ class Version110 extends AbstractMigrationChamilo
$this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('enabled_mathjax', 'true', 'Yes')");
$this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('enabled_mathjax', 'false', 'No')");
$this->addSql("INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('enabled_mathjax', NULL, 'radio', 'Editor', 'false', 'EnableMathJaxTitle', 'EnableMathJaxComment', NULL, NULL, 0)");
$this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('enabled_mathjax', 'true', 'Yes')");
$this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('enabled_mathjax', 'false', 'No')");
$this->addSql("INSERT INTO language (original_name, english_name, isocode, dokeos_folder, available) VALUES ('Føroyskt', 'faroese', 'fo', 'faroese', 0), ('Tagalog', 'tagalog', 'tl', 'tagalog',1), ('Tibetan', 'tibetan', 'bo', 'tibetan', 0), ('isiXhosa', 'xhosa', 'xh', 'xhosa', 0)");
$this->addSql("DELETE FROM settings_options WHERE variable = 'show_glossary_in_extra_tools'");

@ -3,11 +3,7 @@
namespace Application\Migrations\Schema\V110;
use Chamilo\CoreBundle\Entity\ExtraField;
use Chamilo\CoreBundle\Entity\ExtraFieldOptions;
use Chamilo\CoreBundle\Entity\ExtraFieldValues;
use Application\Migrations\AbstractMigrationChamilo;
use Database;
use Doctrine\DBAL\Schema\Schema;
/**
@ -49,109 +45,7 @@ class Version20150505132304 extends AbstractMigrationChamilo
*/
public function postUp(Schema $schema)
{
// Extra fields
$extraFieldTables = [
ExtraField::USER_FIELD_TYPE => Database::get_main_table(TABLE_MAIN_USER_FIELD),
ExtraField::COURSE_FIELD_TYPE => Database::get_main_table(TABLE_MAIN_COURSE_FIELD),
//ExtraField::LP_FIELD_TYPE => Database::get_main_table(TABLE_MAIN_LP_FIELD),
ExtraField::SESSION_FIELD_TYPE => Database::get_main_table(TABLE_MAIN_SESSION_FIELD),
//ExtraField::CALENDAR_FIELD_TYPE => Database::get_main_table(TABLE_MAIN_CALENDAR_EVENT_FIELD),
//ExtraField::QUESTION_FIELD_TYPE => Database::get_main_table(TABLE_MAIN_CALENDAR_EVENT_FIELD),
//ExtraField::USER_FIELD_TYPE => //Database::get_main_table(TABLE_MAIN_SPECIFIC_FIELD),
];
$em = $this->getEntityManager();
$connection = $em->getConnection();
foreach ($extraFieldTables as $type => $table) {
//continue;
$sql = "SELECT * FROM $table ";
$result = $connection->query($sql);
$fields = $result->fetchAll();
foreach ($fields as $field) {
$originalId = $field['id'];
$extraField = new ExtraField();
$extraField
->setExtraFieldType($type)
->setVariable($field['field_variable'])
->setFieldType($field['field_type'])
->setDisplayText($field['field_display_text'])
->setDefaultValue($field['field_default_value'])
->setFieldOrder($field['field_order'])
->setVisible($field['field_visible'])
->setChangeable($field['field_changeable'])
->setFilter($field['field_filter']);
$em->persist($extraField);
$em->flush();
$values = array();
switch ($type) {
case ExtraField::USER_FIELD_TYPE:
$optionTable = Database::get_main_table(
TABLE_MAIN_USER_FIELD_OPTIONS
);
$valueTable = Database::get_main_table(
TABLE_MAIN_USER_FIELD_VALUES
);
$handlerId = 'user_id';
break;
case ExtraField::COURSE_FIELD_TYPE:
$optionTable = Database::get_main_table(
TABLE_MAIN_COURSE_FIELD_OPTIONS
);
$valueTable = Database::get_main_table(
TABLE_MAIN_COURSE_FIELD_VALUES
);
$handlerId = 'c_id';
break;
case ExtraField::SESSION_FIELD_TYPE:
$optionTable = Database::get_main_table(
TABLE_MAIN_SESSION_FIELD_OPTIONS
);
$valueTable = Database::get_main_table(
TABLE_MAIN_SESSION_FIELD_VALUES
);
$handlerId = 'session_id';
break;
}
if (!empty($optionTable)) {
$sql = "SELECT * FROM $optionTable WHERE field_id = $originalId ";
$result = $connection->query($sql);
$options = $result->fetchAll();
foreach ($options as $option) {
$extraFieldOption = new ExtraFieldOptions();
$extraFieldOption
->setDisplayText($option['option_display_text'])
->setField($extraField)
->setOptionOrder($option['option_order'])
->setValue($option['option_value']);
$em->persist($extraFieldOption);
$em->flush();
}
$sql = "SELECT * FROM $valueTable WHERE field_id = $originalId ";
$result = $connection->query($sql);
$values = $result->fetchAll();
}
if (!empty($values)) {
foreach ($values as $value) {
$extraFieldValue = new ExtraFieldValues();
$extraFieldValue
->setValue($value['field_value'])
->setField($extraField)
->setItemId($value[$handlerId]);
$em->persist($extraFieldValue);
$em->flush();
}
}
}
}
}
/**

@ -28,12 +28,13 @@ class Version20150507152600 extends AbstractMigrationChamilo
// Setting $_configuration['hide_home_top_when_connected'] = true;
$value = api_get_configuration_value('hide_home_top_when_connected');
$this->addSettingCurrent(
'hide_home_top_when_connected',
'',
'radio',
'Platform',
($value?'true':'false'),
($value ? 'true' : 'false'),
'HideHomeTopContentWhenLoggedInText',
'HideHomeTopContentWhenLoggedInComment',
null,
@ -41,7 +42,10 @@ class Version20150507152600 extends AbstractMigrationChamilo
1,
true,
false,
[0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]
[
0 => ['value' => 'true', 'text' => 'Yes'],
1 => ['value' => 'false', 'text' => 'No'],
]
);
// Hide the global announcements for non-connected users
@ -60,7 +64,10 @@ class Version20150507152600 extends AbstractMigrationChamilo
1,
true,
false,
[0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]
[
0 => ['value' => 'true', 'text' => 'Yes'],
1 => ['value' => 'false', 'text' => 'No'],
]
);
// Use this course as template for all new courses (define course real ID as value)
@ -79,7 +86,10 @@ class Version20150507152600 extends AbstractMigrationChamilo
1,
true,
false,
[0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]
[
0 => ['value' => 'true', 'text' => 'Yes'],
1 => ['value' => 'false', 'text' => 'No'],
]
);
// Add password strength checker
@ -98,7 +108,10 @@ class Version20150507152600 extends AbstractMigrationChamilo
1,
true,
false,
[0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]
[
0 => ['value' => 'true', 'text' => 'Yes'],
1 => ['value' => 'false', 'text' => 'No'],
]
);
// Enable captcha

@ -18,7 +18,7 @@ class Version20150511133949 extends AbstractMigrationChamilo
{
$this->addSql('ALTER TABLE user ADD salt VARCHAR(255) NOT NULL');
$this->addSql('ALTER TABLE user ADD username_canonical VARCHAR(100) NOT NULL');
$this->addSql('CREATE UNIQUE INDEX UNIQ_8D93D64992FC23A8 ON user (username_canonical)');
//$this->addSql('CREATE UNIQUE INDEX UNIQ_8D93D64992FC23A8 ON user (username_canonical)');
$this->addSql('ALTER TABLE user CHANGE password password VARCHAR(255) NOT NULL');
$this->addSql("INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('allow_teachers_to_create_sessions', NULL,'radio','Session','false','AllowTeachersToCreateSessionsTitle','AllowTeachersToCreateSessionsComment', NULL, NULL, 0)");

@ -22,6 +22,7 @@ class Version20150522112023 extends AbstractMigrationChamilo
$this->addSql('ALTER TABLE usergroup ADD group_type INT NOT NULL, ADD created_at DATETIME NOT NULL, ADD updated_at DATETIME NOT NULL');
$this->addSql('ALTER TABLE usergroup ADD picture VARCHAR(255) DEFAULT NULL, ADD url VARCHAR(255) DEFAULT NULL, ADD visibility VARCHAR(255) NOT NULL, ADD allow_members_leave_group INT NOT NULL, CHANGE description description LONGTEXT DEFAULT NULL');
$this->addSql('CREATE TABLE usergroup_rel_usergroup (id INT AUTO_INCREMENT NOT NULL, group_id INT NOT NULL, subgroup_id INT NOT NULL, relation_type INT NOT NULL, PRIMARY KEY(id));');
$this->addSql('ALTER TABLE usergroup_rel_user ADD relation_type INT');
if (!$schema->hasTable('access_url_rel_usergroup')) {
$this->addSql(

@ -52,5 +52,4 @@ class Version20150527101600 extends AbstractMigrationChamilo
$this->addSql("DELETE FROM settings_options WHERE variable = 'gamification_mode'");
$this->addSql("DELETE FROM settings_current WHERE variable = 'gamification_mode'");
}
}

@ -17,9 +17,6 @@ class Version20150603181728 extends AbstractMigrationChamilo
public function up(Schema $schema)
{
$this->addSql('ALTER TABLE c_lp ADD max_attempts INT NOT NULL, ADD subscribe_users INT NOT NULL DEFAULT 0');
$this->addSql('DELETE FROM c_item_property TABLE c_lp ADD max_attempts INT NOT NULL, ADD subscribe_users INT NOT NULL DEFAULT 0');
$this->addSql('ALTER TABLE c_item_property CHANGE c_id c_id INT DEFAULT NULL, CHANGE insert_user_id insert_user_id INT DEFAULT NULL, CHANGE start_visible start_visible DATETIME DEFAULT NULL, CHANGE end_visible end_visible DATETIME DEFAULT NULL, CHANGE session_id session_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE c_item_property ADD CONSTRAINT FK_1D84C18191D79BD3 FOREIGN KEY (c_id) REFERENCES course (id)');
$this->addSql('ALTER TABLE c_item_property ADD CONSTRAINT FK_1D84C181330D47E9 FOREIGN KEY (to_group_id) REFERENCES c_group_info (iid)');

@ -18,9 +18,15 @@ class Version20150713132630 extends AbstractMigrationChamilo
*/
public function up(Schema $schema)
{
$this->addSql('ALTER TABLE c_student_publication ADD url_correction VARCHAR(255) DEFAULT NULL');
$this->addSql('ALTER TABLE c_student_publication ADD title_correction VARCHAR(255) DEFAULT NULL');
$this->addSql('ALTER TABLE c_student_publication ADD document_id INT NOT NULL');
if ($schema->hasTable('c_student_publication')) {
$this->addSql('ALTER TABLE c_student_publication ADD url_correction VARCHAR(255) DEFAULT NULL');
$this->addSql('ALTER TABLE c_student_publication ADD title_correction VARCHAR(255) DEFAULT NULL');
if (!$schema->getTable('c_student_publication')->hasColumn('document_id')) {
$this->addSql(
'ALTER TABLE c_student_publication ADD document_id INT NOT NULL'
);
}
}
}
/**

@ -0,0 +1,5 @@
<?php
/*
* File needed to overwrite file in 1.9.x
*/

@ -81,8 +81,10 @@ define('TABLE_MAIN_TAG', 'tag');
define('TABLE_MAIN_USER_REL_TAG', 'user_rel_tag');
define('TABLE_MAIN_EXTRA_FIELD_REL_TAG', 'extra_field_rel_tag');
define('TABLE_MAIN_GROUP', 'groups');
//User groups
/*define('TABLE_MAIN_GROUP', 'groups');
/*
define('TABLE_MAIN_USER_REL_GROUP', 'group_rel_user');
define('TABLE_MAIN_GROUP_REL_TAG', 'group_rel_tag');
define('TABLE_MAIN_GROUP_REL_GROUP', 'group_rel_group');*/

@ -681,7 +681,7 @@ if (@$_POST['step2']) {
$manager
);
fixIds($manager->getConnection());
fixIds($manager);
include 'update-files-1.9.0-1.10.0.inc.php';
// Only updates the configuration.inc.php with the new version

@ -11,7 +11,9 @@
*/
use Doctrine\ORM\EntityManager;
use Doctrine\DBAL\Connection;
use Chamilo\CoreBundle\Entity\ExtraField;
use Chamilo\CoreBundle\Entity\ExtraFieldOptions;
use Chamilo\CoreBundle\Entity\ExtraFieldValues;
/* CONSTANTS */
define('SYSTEM_CONFIG_FILENAME', 'configuration.dist.php');
@ -1942,11 +1944,10 @@ function migrate($chamiloVersion, EntityManager $manager)
}
}
/**
* @param Connection $connection
*/
function fixIds(Connection $connection)
function fixIds(EntityManager $em)
{
$connection = $em->getConnection();
$sql = "SELECT * FROM c_lp_item";
$result = $connection->fetchAll($sql);
foreach ($result as $item) {
@ -1959,43 +1960,43 @@ function fixIds(Connection $connection)
switch ($item['item_type']) {
case TOOL_LINK:
$sql = "SELECT * c_link WHERE c_id = $courseId AND id = $ref";
$data = $connection->fetchArray($sql);
$sql = "SELECT * FROM c_link WHERE c_id = $courseId AND id = $ref";
$data = $connection->fetchAssoc($sql);
if ($data) {
$newId = $data['iid'];
}
break;
case TOOL_STUDENTPUBLICATION:
$sql = "SELECT * c_student_publication WHERE c_id = $courseId AND id = $ref";
$data = $connection->fetchArray($sql);
$sql = "SELECT * FROM c_student_publication WHERE c_id = $courseId AND id = $ref";
$data = $connection->fetchAssoc($sql);
if ($data) {
$newId = $data['iid'];
}
break;
case TOOL_QUIZ:
$sql = "SELECT * c_quiz WHERE c_id = $courseId AND id = $ref";
$data = $connection->fetchArray($sql);
$sql = "SELECT * FROM c_quiz WHERE c_id = $courseId AND id = $ref";
$data = $connection->fetchAssoc($sql);
if ($data) {
$newId = $data['iid'];
}
break;
case TOOL_DOCUMENT:
$sql = "SELECT * c_document WHERE c_id = $courseId AND id = $ref";
$data = $connection->fetchArray($sql);
$sql = "SELECT * FROM c_document WHERE c_id = $courseId AND id = $ref";
$data = $connection->fetchAssoc($sql);
if ($data) {
$newId = $data['iid'];
}
break;
case TOOL_FORUM:
$sql = "SELECT * c_forum_forum WHERE c_id = $courseId AND id = $ref";
$data = $connection->fetchArray($sql);
$sql = "SELECT * FROM c_forum_forum WHERE c_id = $courseId AND id = $ref";
$data = $connection->fetchAssoc($sql);
if ($data) {
$newId = $data['iid'];
}
break;
case 'thread':
$sql = "SELECT * c_forum_thread WHERE c_id = $courseId AND id = $ref";
$data = $connection->fetchArray($sql);
$sql = "SELECT * FROM c_forum_thread WHERE c_id = $courseId AND id = $ref";
$data = $connection->fetchAssoc($sql);
if ($data) {
$newId = $data['iid'];
}
@ -2051,9 +2052,9 @@ function fixIds(Connection $connection)
// Fix group id
if (!empty($groupId)) {
$sql = "SELECT * c_group_info
$sql = "SELECT * FROM c_group_info
WHERE c_id = $courseId AND id = $groupId LIMIT 1";
$data = $connection->fetchArray($sql);
$data = $connection->fetchAssoc($sql);
if (!empty($data)) {
$newGroupId = $data['iid'];
$sql = "UPDATE $table SET group_id = $newGroupId
@ -2082,8 +2083,8 @@ function fixIds(Connection $connection)
// Fix group id
if (!empty($groupId)) {
$sql = "SELECT * c_group_info WHERE c_id = $courseId AND id = $groupId";
$data = $connection->fetchArray($sql);
$sql = "SELECT * FROM c_group_info WHERE c_id = $courseId AND id = $groupId";
$data = $connection->fetchAssoc($sql);
if (!empty($data)) {
$newGroupId = $data['iid'];
$sql = "UPDATE c_item_property SET to_group_id = $newGroupId
@ -2096,42 +2097,34 @@ function fixIds(Connection $connection)
}
}
$sql = null;
$sql = '';
$newId = '';
switch ($item['tool']) {
case TOOL_LINK:
$sql = "SELECT * c_link WHERE c_id = $courseId AND id = $ref ";
$data = $connection->fetchArray($sql);
$newId = $data['iid'];
$sql = "SELECT * FROM c_link WHERE c_id = $courseId AND id = $ref ";
break;
case TOOL_STUDENTPUBLICATION:
$sql = "SELECT * c_student_publication WHERE c_id = $courseId AND id = $ref";
$data = $connection->fetchArray($sql);
$newId = $data['iid'];
$sql = "SELECT * FROM c_student_publication WHERE c_id = $courseId AND id = $ref";
break;
case TOOL_QUIZ:
$sql = "SELECT * c_quiz WHERE c_id = $courseId AND id = $ref";
$data = $connection->fetchArray($sql);
$newId = $data['iid'];
$sql = "SELECT * FROM c_quiz WHERE c_id = $courseId AND id = $ref";
break;
case TOOL_DOCUMENT:
$sql = "SELECT * c_document WHERE c_id = $courseId AND id = $ref";
$data = $connection->fetchArray($sql);
$newId = $data['iid'];
$sql = "SELECT * FROM c_document WHERE c_id = $courseId AND id = $ref";
break;
case TOOL_FORUM:
$sql = "SELECT * c_forum_forum WHERE c_id = $courseId AND id = $ref";
$data = $connection->fetchArray($sql);
$newId = $data['iid'];
$sql = "SELECT * FROM c_forum_forum WHERE c_id = $courseId AND id = $ref";
break;
case 'thread':
$sql = "SELECT * c_forum_thread WHERE c_id = $courseId AND id = $ref";
$data = $connection->fetchArray($sql);
$newId = $data['iid'];
$sql = "SELECT * FROM c_forum_thread WHERE c_id = $courseId AND id = $ref";
break;
}
if (!empty($sql)) {
if (!empty($sql) && !empty($newId)) {
$data = $connection->fetchAssoc($sql);
if (isset($data['iid'])) {
$newId = $data['iid'];
}
$sql = "UPDATE c_item_property SET ref = $newId WHERE iid = $iid";
$connection->executeQuery($sql);
}
@ -2141,52 +2134,47 @@ function fixIds(Connection $connection)
$sql = "SELECT * FROM gradebook_link";
$result = $connection->fetchAll($sql);
foreach ($result as $item) {
$courseId = $item['c_id'];
$courseCode = $item['course_code'];
$courseInfo = api_get_course_info($courseCode);
if (empty($courseInfo)) {
continue;
}
$courseId = $courseInfo['real_id'];
$ref = $item['ref_id'];
$sql = null;
$iid = $item['id'];
$sql = '';
switch ($item['tool']) {
case TOOL_LINK:
$sql = "SELECT * c_link WHERE c_id = $courseId AND id = $ref ";
$data = $connection->fetchArray($sql);
$newId = $data['iid'];
switch ($item['type']) {
case LINK_LEARNPATH:
$sql = "SELECT * FROM c_link WHERE c_id = $courseId AND id = $ref ";
break;
case TOOL_STUDENTPUBLICATION:
$sql = "SELECT * c_student_publication WHERE c_id = $courseId AND id = $ref";
$data = $connection->fetchArray($sql);
$newId = $data['iid'];
case LINK_STUDENTPUBLICATION:
$sql = "SELECT * FROM c_student_publication WHERE c_id = $courseId AND id = $ref";
break;
case TOOL_QUIZ:
$sql = "SELECT * c_quiz WHERE c_id = $courseId AND id = $ref";
$data = $connection->fetchArray($sql);
$newId = $data['iid'];
case LINK_EXERCISE:
$sql = "SELECT * FROM c_quiz WHERE c_id = $courseId AND id = $ref";
break;
case TOOL_DOCUMENT:
$sql = "SELECT * c_document WHERE c_id = $courseId AND id = $ref";
$data = $connection->fetchArray($sql);
$newId = $data['iid'];
case LINK_ATTENDANCE:
//$sql = "SELECT * FROM c_document WHERE c_id = $courseId AND id = $ref";
break;
case TOOL_FORUM:
$sql = "SELECT * c_forum_forum WHERE c_id = $courseId AND id = $ref";
$data = $connection->fetchArray($sql);
$newId = $data['iid'];
break;
case 'thread':
$sql = "SELECT * c_forum_thread WHERE c_id = $courseId AND id = $ref";
$data = $connection->fetchArray($sql);
$newId = $data['iid'];
case LINK_FORUM_THREAD:
$sql = "SELECT * FROM c_forum_thread WHERE c_id = $courseId AND id = $ref";
break;
}
if (!empty($sql)) {
$sql = "UPDATE c_item_property SET ref_id = $newId WHERE iid = $iid";
$connection->executeQuery($sql);
$data = $connection->fetchAssoc($sql);
if (isset($data) && isset($data['iid'])) {
$newId = $data['iid'];
$sql = "UPDATE gradebook_link SET ref_id = $newId
WHERE id = $iid";
$connection->executeQuery($sql);
}
}
}
$sql = "SELECT * FROM groups";
$result = $connection->executeQuery($sql);
$groups = $result->fetchAll();
@ -2281,13 +2269,115 @@ function fixIds(Connection $connection)
if (isset($oldGroups[$data['group_id']])) {
$data['group_id'] = $oldGroups[$data['group_id']];
$sql = "INSERT INTO usergroup_rel_tag (tag_id, usergroup_id)
VALUES ('{$data['tag_id']}', '{$data['group_id']}')";
VALUES ('{$data['tag_id']}', '{$data['group_id']}')";
$connection->executeQuery($sql);
}
}
}
}
// Extra fields
$extraFieldTables = [
ExtraField::USER_FIELD_TYPE => Database::get_main_table(TABLE_MAIN_USER_FIELD),
ExtraField::COURSE_FIELD_TYPE => Database::get_main_table(TABLE_MAIN_COURSE_FIELD),
//ExtraField::LP_FIELD_TYPE => Database::get_main_table(TABLE_MAIN_LP_FIELD),
ExtraField::SESSION_FIELD_TYPE => Database::get_main_table(TABLE_MAIN_SESSION_FIELD),
//ExtraField::CALENDAR_FIELD_TYPE => Database::get_main_table(TABLE_MAIN_CALENDAR_EVENT_FIELD),
//ExtraField::QUESTION_FIELD_TYPE => Database::get_main_table(TABLE_MAIN_CALENDAR_EVENT_FIELD),
//ExtraField::USER_FIELD_TYPE => //Database::get_main_table(TABLE_MAIN_SPECIFIC_FIELD),
];
foreach ($extraFieldTables as $type => $table) {
//continue;
$sql = "SELECT * FROM $table ";
$result = $connection->query($sql);
$fields = $result->fetchAll();
foreach ($fields as $field) {
$originalId = $field['id'];
$extraField = new ExtraField();
$extraField
->setExtraFieldType($type)
->setVariable($field['field_variable'])
->setFieldType($field['field_type'])
->setDisplayText($field['field_display_text'])
->setDefaultValue($field['field_default_value'])
->setFieldOrder($field['field_order'])
->setVisible($field['field_visible'])
->setChangeable($field['field_changeable'])
->setFilter($field['field_filter']);
$em->persist($extraField);
$em->flush();
$values = array();
switch ($type) {
case ExtraField::USER_FIELD_TYPE:
$optionTable = Database::get_main_table(
TABLE_MAIN_USER_FIELD_OPTIONS
);
$valueTable = Database::get_main_table(
TABLE_MAIN_USER_FIELD_VALUES
);
$handlerId = 'user_id';
break;
case ExtraField::COURSE_FIELD_TYPE:
$optionTable = Database::get_main_table(
TABLE_MAIN_COURSE_FIELD_OPTIONS
);
$valueTable = Database::get_main_table(
TABLE_MAIN_COURSE_FIELD_VALUES
);
$handlerId = 'c_id';
break;
case ExtraField::SESSION_FIELD_TYPE:
$optionTable = Database::get_main_table(
TABLE_MAIN_SESSION_FIELD_OPTIONS
);
$valueTable = Database::get_main_table(
TABLE_MAIN_SESSION_FIELD_VALUES
);
$handlerId = 'session_id';
break;
}
if (!empty($optionTable)) {
$sql = "SELECT * FROM $optionTable WHERE field_id = $originalId ";
$result = $connection->query($sql);
$options = $result->fetchAll();
foreach ($options as $option) {
$extraFieldOption = new ExtraFieldOptions();
$extraFieldOption
->setDisplayText($option['option_display_text'])
->setField($extraField)
->setOptionOrder($option['option_order'])
->setValue($option['option_value']);
$em->persist($extraFieldOption);
$em->flush();
}
$sql = "SELECT * FROM $valueTable WHERE field_id = $originalId ";
$result = $connection->query($sql);
$values = $result->fetchAll();
}
if (!empty($values)) {
foreach ($values as $value) {
$extraFieldValue = new ExtraFieldValues();
$extraFieldValue
->setValue($value['field_value'])
->setField($extraField)
->setItemId($value[$handlerId]);
$em->persist($extraFieldValue);
$em->flush();
}
}
}
}
}
/**

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Entity;
@ -12,6 +13,15 @@ use Doctrine\ORM\Mapping as ORM;
*/
class GradeComponents
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue
*/
private $id;
/**
* @var string
*
@ -40,17 +50,6 @@ class GradeComponents
*/
private $gradeModelId;
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* Set percentage
*

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Entity;
@ -12,6 +13,15 @@ use Doctrine\ORM\Mapping as ORM;
*/
class GradeModel
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue
*/
private $id;
/**
* @var string
*
@ -47,17 +57,6 @@ class GradeModel
*/
private $defaultExternalEvalPrefix;
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* Set name
*

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Entity;
@ -12,6 +13,14 @@ use Doctrine\ORM\Mapping as ORM;
*/
class GradebookCategory
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue
*/
private $id;
/**
* @var string
@ -123,17 +132,6 @@ class GradebookCategory
*/
private $isRequirement;
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* Set name
*

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Entity;
@ -12,6 +13,15 @@ use Doctrine\ORM\Mapping as ORM;
*/
class GradebookCertificate
{
/**
* @var integer
*
* @ORM\Column(name="id", type="bigint")
* @ORM\Id
* @ORM\GeneratedValue
*/
private $id;
/**
* @var integer
*
@ -47,17 +57,6 @@ class GradebookCertificate
*/
private $pathCertificate;
/**
* @var integer
*
* @ORM\Column(name="id", type="bigint")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* Set catId
*

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Entity;
@ -12,6 +13,15 @@ use Doctrine\ORM\Mapping as ORM;
*/
class GradebookEvaluation
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue
*/
private $id;
/**
* @var string
*
@ -89,17 +99,6 @@ class GradebookEvaluation
*/
private $locked;
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* Set name
*

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Entity;
@ -12,6 +13,15 @@ use Doctrine\ORM\Mapping as ORM;
*/
class GradebookLink
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue
*/
private $id;
/**
* @var integer
*
@ -75,21 +85,11 @@ class GradebookLink
*/
private $locked;
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* Set type
*
* @param integer $type
*
* @return GradebookLink
*/
public function setType($type)

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Entity;

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Entity;

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Entity;

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Entity;

@ -8,7 +8,7 @@ use Doctrine\ORM\Mapping as ORM;
/**
* SettingsCurrent
*
* @ORM\Table(name="settings_current", uniqueConstraints={@ORM\UniqueConstraint(name="unique_setting", columns={"variable", "subkey", "category", "access_url"})}, indexes={@ORM\Index(name="access_url", columns={"access_url"})})
* @ORM\Table(name="settings_current", uniqueConstraints={@ORM\UniqueConstraint(name="unique_setting", columns={"variable", "access_url"})}, indexes={@ORM\Index(name="access_url", columns={"access_url"})})
* @ORM\Entity
*/
class SettingsCurrent
@ -18,7 +18,7 @@ class SettingsCurrent
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
* @ORM\GeneratedValue
*/
private $id;

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Entity;
@ -7,11 +8,20 @@ use Doctrine\ORM\Mapping as ORM;
/**
* SettingsOptions
*
* @ORM\Table(name="settings_options", uniqueConstraints={@ORM\UniqueConstraint(name="id", columns={"id"}), @ORM\UniqueConstraint(name="unique_setting_option", columns={"variable", "value"})})
* @ORM\Table(name="settings_options", uniqueConstraints={@ORM\UniqueConstraint(name="unique_setting_option", columns={"variable", "value"})})
* @ORM\Entity
*/
class SettingsOptions
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue
*/
private $id;
/**
* @var string
*
@ -33,17 +43,6 @@ class SettingsOptions
*/
private $displayText;
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* Set variable
*

Loading…
Cancel
Save