skala
Julio Montoya 12 years ago
commit d166766429
  1. 34
      main/exercice/admin.php
  2. 2
      main/exercice/exercise_submit.php
  3. 37
      vendor/chamilo/chash/src/Chash/Command/Chash/SetupCommand.php
  4. 2
      vendor/chamilo/chash/src/Chash/Command/Files/GenerateTempFileStructureCommand.php
  5. 33
      vendor/chamilo/chash/src/Chash/Command/Installation/UpgradeCommand.php
  6. 11
      vendor/chamilo/chash/src/Chash/Resources/Database/1.10.0/db_course.sql
  7. 3
      vendor/chamilo/chash/src/Chash/Resources/Database/1.10.0/db_main.sql
  8. 6
      vendor/chamilo/chash/src/Chash/Resources/Database/1.10.0/migrate-db-1.9.0-1.10.0-pre.sql
  9. 16
      vendor/chamilo/chash/src/Chash/Resources/Database/1.10.0/update-db-1.9.0-1.10.0.inc.php

@ -512,12 +512,8 @@ if ($inATest) {
ICON_SIZE_MEDIUM ICON_SIZE_MEDIUM
).'</a>'; ).'</a>';
} else { } else {
echo '<a href="'.$urlMainExercise.'exercise_admin.php?'.api_get_cidreq().'&modifyExercise=yes&exerciseId='.$objExercise->id.'">'.Display::return_icon( echo '<a href="'.$urlMainExercise.'exercise_admin.php?'.api_get_cidreq().'&modifyExercise=yes&exerciseId='.$objExercise->id.'">'.
'settings.png', Display::return_icon('settings.png', get_lang('ModifyExercise'), '', ICON_SIZE_MEDIUM ).'</a>';
get_lang('ModifyExercise'),
'',
ICON_SIZE_MEDIUM
).'</a>';
} }
// @todo if you have 5000 questions this will slow down everything // @todo if you have 5000 questions this will slow down everything
@ -534,27 +530,11 @@ if ($inATest) {
echo '<span style="float:right">'.sprintf(get_lang('XQuestionsWithTotalScoreY'), $objExercise->selectNbrQuestions(), $maxScoreAllQuestions ).'</span>';*/ echo '<span style="float:right">'.sprintf(get_lang('XQuestionsWithTotalScoreY'), $objExercise->selectNbrQuestions(), $maxScoreAllQuestions ).'</span>';*/
echo '</div>'; echo '</div>';
} else { } else {
if (isset($_GET['newQuestion'])) { // we are in create a new question from question pool not in a test
// we are in create a new question from question pool not in a test echo '<div class="actions">';
echo '<div class="actions">'; echo '<a href="'.$urlMainExercise.'admin.php?exerciseId='.$objExercise->id.'&'.api_get_cidreq().'">'.
echo '<a href="'.$urlMainExercise.'admin.php?'.api_get_cidreq().'">.'.Display::return_icon( Display::return_icon('back.png', get_lang('GoBackToQuestionList'),'', ICON_SIZE_MEDIUM ).'</a>';
'back.png', echo '</div>';
get_lang('GoBackToQuestionList'),
'',
ICON_SIZE_MEDIUM
).'</a>';
echo '</div>';
} else {
// If we are in question_poolbut not in an test, go back to question create in pool
echo '<div class="actions">';
echo '<a href="'.$urlMainExercise.'question_pool.php">'.Display::return_icon(
'back.png',
get_lang('GoBackToQuestionList'),
'',
ICON_SIZE_MEDIUM
).'</a>';
echo '</div>';
}
} }

@ -839,7 +839,6 @@ if (is_null($current_question)) {
} }
} }
if ($question_count != 0) { if ($question_count != 0) {
if (($objExercise->type == ALL_ON_ONE_PAGE || $current_question > $question_count)) { if (($objExercise->type == ALL_ON_ONE_PAGE || $current_question > $question_count)) {
if (api_is_allowed_to_session_edit()) { if (api_is_allowed_to_session_edit()) {
@ -1270,6 +1269,7 @@ if (!empty($error)) {
} }
$("#save_for_now_"+question_id).html("'.addslashes(Display::return_icon('save.png', get_lang('Saved'), array(), ICON_SIZE_SMALL)).'"); $("#save_for_now_"+question_id).html("'.addslashes(Display::return_icon('save.png', get_lang('Saved'), array(), ICON_SIZE_SMALL)).'");
if (redirect) { if (redirect) {
window.location = url; window.location = url;
} }

@ -7,6 +7,7 @@ use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console; use Symfony\Component\Console;
use Symfony\Component\Yaml\Dumper; use Symfony\Component\Yaml\Dumper;
use Symfony\Component\Filesystem\Filesystem;
/** /**
* Class StatusCommand * Class StatusCommand
@ -15,13 +16,15 @@ class SetupCommand extends AbstractCommand
{ {
public $migrationFile = null; public $migrationFile = null;
/**
*
*/
protected function configure() protected function configure()
{ {
$this $this
->setName('chash:setup') ->setName('chash:setup')
->setDescription('Setups the migration.yml') ->setDescription('Setups the migration.yml')
->addOption('migration-yml-path', null, InputOption::VALUE_OPTIONAL, 'The path to the migration.yml file') ->addOption('temp-folder', null, InputOption::VALUE_OPTIONAL, 'The temp folder.', '/tmp');
->addOption('migration-class-path', null, InputOption::VALUE_OPTIONAL, 'The path to the migration class');
} }
/** /**
@ -34,41 +37,41 @@ class SetupCommand extends AbstractCommand
*/ */
protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output) protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
{ {
$path = $input->getOption('migration-yml-path'); $tempFolder = $input->getOption('temp-folder');
if (empty($path)) { $fs = new Filesystem();
$srcPath = realpath(__DIR__.'/../../../').'/Chash/Migrations/';
} else {
$srcPath = $path;
}
$migrationClassPath = $input->getOption('migration-class-path'); $migrationsFolder = $tempFolder.'/Migrations/';
if (empty($migrationClassPath)) { if (!$fs->exists($migrationsFolder)) {
$migrationClassPath = $srcPath; $fs->mkdir($migrationsFolder);
} }
$migrations = array( $migrations = array(
'name' => 'Chamilo Migrations', 'name' => 'Chamilo Migrations',
'migrations_namespace' => 'Chash\Migrations', 'migrations_namespace' => 'Chash\Migrations',
'table_name' => 'chamilo_migration_versions', 'table_name' => 'chamilo_migration_versions',
'migrations_directory' => $migrationClassPath 'migrations_directory' => $migrationsFolder
); );
// does not work because it need a callable function yml_emit
/*$config = new \Zend\Config\Config($migrations, true);
$writer = new \Zend\Config\Writer\Yaml();
$writer->toFile($srcPath.'/Chash/Migrations/migrations.ypl', $config);*/
$dumper = new Dumper(); $dumper = new Dumper();
$yaml = $dumper->dump($migrations, 1); $yaml = $dumper->dump($migrations, 1);
$file = $srcPath.'/migrations.yml'; $file = $migrationsFolder.'migrations.yml';
file_put_contents($file, $yaml); file_put_contents($file, $yaml);
$migrationPathSource = __DIR__.'/../../../Chash/Migrations/';
$fs->mirror($migrationPathSource, $migrationsFolder);
// migrations_directory // migrations_directory
$output->writeln("<comment>Chash migrations.yml saved: $file</comment>"); $output->writeln("<comment>Chash migrations.yml saved: $file</comment>");
$this->migrationFile = $file; $this->migrationFile = $file;
} }
/**
* Gets the migration file path
* @return string
*/
public function getMigrationFile() public function getMigrationFile()
{ {
return $this->migrationFile; return $this->migrationFile;

@ -10,7 +10,6 @@ use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Filesystem\Filesystem;
class GenerateTempFileStructureCommand extends CommonChamiloDatabaseCommand class GenerateTempFileStructureCommand extends CommonChamiloDatabaseCommand
{ {
/** /**
@ -37,7 +36,6 @@ class GenerateTempFileStructureCommand extends CommonChamiloDatabaseCommand
// Data folders // Data folders
$files = $this->getConfigurationHelper()->getTempFolderList(); $files = $this->getConfigurationHelper()->getTempFolderList();
$this->createFolders($output, $files, 0777); $this->createFolders($output, $files, 0777);
} }
/** /**

@ -6,7 +6,6 @@ use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console; use Symfony\Component\Console;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Yaml\Dumper; use Symfony\Component\Yaml\Dumper;
use Symfony\Component\Yaml\Parser; use Symfony\Component\Yaml\Parser;
@ -41,10 +40,10 @@ class UpgradeCommand extends CommonCommand
->addOption('dry-run', null, InputOption::VALUE_NONE, 'Execute the migration as a dry run.') ->addOption('dry-run', null, InputOption::VALUE_NONE, 'Execute the migration as a dry run.')
->addOption('update-installation', null, InputOption::VALUE_OPTIONAL, 'Updates the portal with the current zip file. http:// or /var/www/file.zip') ->addOption('update-installation', null, InputOption::VALUE_OPTIONAL, 'Updates the portal with the current zip file. http:// or /var/www/file.zip')
->addOption('temp-folder', null, InputOption::VALUE_OPTIONAL, 'The temp folder.', '/tmp') ->addOption('temp-folder', null, InputOption::VALUE_OPTIONAL, 'The temp folder.', '/tmp')
->addOption('migration-yml-path', null, InputOption::VALUE_OPTIONAL, 'The temp folder.')
->addOption('migration-class-path', null, InputOption::VALUE_OPTIONAL, 'The temp folder.')
->addOption('download-package', null, InputOption::VALUE_OPTIONAL, 'Downloads the chamilo package', 'true') ->addOption('download-package', null, InputOption::VALUE_OPTIONAL, 'Downloads the chamilo package', 'true')
->addOption('silent', null, InputOption::VALUE_NONE, 'Execute the migration with out asking questions.'); ->addOption('silent', null, InputOption::VALUE_NONE, 'Execute the migration with out asking questions.')
->addOption('linux-user', null, InputOption::VALUE_OPTIONAL, 'user', 'www-data')
->addOption('linux-group', null, InputOption::VALUE_OPTIONAL, 'group', 'www-data');
//->addOption('force', null, InputOption::VALUE_NONE, 'Force the update. Only for tests'); //->addOption('force', null, InputOption::VALUE_NONE, 'Force the update. Only for tests');
} }
@ -64,21 +63,15 @@ class UpgradeCommand extends CommonCommand
// Setting up Chash // Setting up Chash
$command = $this->getApplication()->find('chash:setup'); $command = $this->getApplication()->find('chash:setup');
$migrationPath = $input->getOption('migration-yml-path');
$migrationDir = $input->getOption('migration-class-path'); // User options
$linuxUser = $input->getOption('linux-user');
$linuxGroup = $input->getOption('linux-group');
$arguments = array( $arguments = array(
'command' => 'chash:setup' 'command' => 'chash:setup'
); );
if (!empty($migrationPath)) {
$arguments['--migration-yml-path'] = $migrationPath;
}
if (!empty($migrationDir)) {
$arguments['--migration-class-path'] = $migrationDir;
}
$inputSetup = new ArrayInput($arguments); $inputSetup = new ArrayInput($arguments);
$command->run($inputSetup, $output); $command->run($inputSetup, $output);
@ -131,6 +124,15 @@ class UpgradeCommand extends CommonCommand
} }
$this->setConfigurationPath($configurationPath); $this->setConfigurationPath($configurationPath);
// $_configuration['password_encryption'] must exists
if (isset($_configuration['password_encryption'])) {
$output->writeln("<comment> \$_configuration[password_encryption] value found: </comment><info>".$_configuration['password_encryption']."</info>");
} else {
$output->writeln("<error>\$_configuration['password_encryption'] not found. The key 'password_encryption' or the variable '\$userPasswordCrypted' must exists in the configuration.php file </error>");
return 0;
}
// In order to use Doctrine migrations // In order to use Doctrine migrations
// Setting configuration variable in order to get the doctrine version: // Setting configuration variable in order to get the doctrine version:
@ -318,7 +320,6 @@ class UpgradeCommand extends CommonCommand
if ($version == '1.10.0') { if ($version == '1.10.0') {
$this->removeUnUsedFiles($output, $path); $this->removeUnUsedFiles($output, $path);
$this->copyConfigFilesToNewLocation($output); $this->copyConfigFilesToNewLocation($output);
} }
} }
@ -338,6 +339,8 @@ class UpgradeCommand extends CommonCommand
$arguments = array( $arguments = array(
'command' => 'files:set_permissions_after_install', 'command' => 'files:set_permissions_after_install',
'--conf' => $this->getConfigurationHelper()->getConfigurationFilePath($path), '--conf' => $this->getConfigurationHelper()->getConfigurationFilePath($path),
'--linux-user' => $linuxUser,
'--linux-group' => $linuxGroup,
'--dry-run' => $dryRun '--dry-run' => $dryRun
); );

@ -1581,6 +1581,7 @@ CREATE TABLE c_student_publication (
id int(10) unsigned NOT NULL AUTO_INCREMENT, id int(10) unsigned NOT NULL AUTO_INCREMENT,
url varchar(255) DEFAULT NULL, url varchar(255) DEFAULT NULL,
title varchar(255) DEFAULT NULL, title varchar(255) DEFAULT NULL,
filename varchar(255) DEFAULT NULL,
description text, description text,
author varchar(255) DEFAULT NULL, author varchar(255) DEFAULT NULL,
active tinyint(4) DEFAULT NULL, active tinyint(4) DEFAULT NULL,
@ -2031,3 +2032,13 @@ CREATE TABLE c_student_publication_rel_user (
user_id INT NOT NULL, user_id INT NOT NULL,
c_id INT NOT NULL c_id INT NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS c_student_publication_comment;
CREATE TABLE c_student_publication_comment (
id INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
work_id INT NOT NULL,
c_id INT NOT NULL,
comment text,
user_id int NOT NULL,
sent_at datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

@ -180,6 +180,7 @@ CREATE TABLE IF NOT EXISTS course (
registration_code varchar(255) NOT NULL default '', registration_code varchar(255) NOT NULL default '',
legal TEXT NOT NULL, legal TEXT NOT NULL,
activate_legal INT NOT NULL DEFAULT 0, activate_legal INT NOT NULL DEFAULT 0,
add_teachers_to_sessions_courses tinyint NOT NULL default 0,
PRIMARY KEY (id), PRIMARY KEY (id),
UNIQUE KEY code (code) UNIQUE KEY code (code)
); );
@ -3580,4 +3581,4 @@ CREATE TABLE curriculum_rel_user (
-- Do not move this -- Do not move this
UPDATE settings_current SET selected_value = '1.10.0.044' WHERE variable = 'chamilo_database_version'; UPDATE settings_current SET selected_value = '1.10.0.047' WHERE variable = 'chamilo_database_version';

@ -20,6 +20,7 @@ CREATE TABLE IF NOT EXISTS course_field_options (id int NOT NULL auto_increment,
CREATE TABLE IF NOT EXISTS c_quiz_order( iid bigint unsigned NOT NULL auto_increment, c_id int unsigned NOT NULL, session_id int unsigned NOT NULL, exercise_id int NOT NULL, exercise_order INT NOT NULL, PRIMARY KEY (iid)); CREATE TABLE IF NOT EXISTS c_quiz_order( iid bigint unsigned NOT NULL auto_increment, c_id int unsigned NOT NULL, session_id int unsigned NOT NULL, exercise_id int NOT NULL, exercise_order INT NOT NULL, PRIMARY KEY (iid));
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); 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);
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); 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);
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, user_id int NOT NULL, sent_at datetime NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS gradebook_evaluation_type(id INT unsigned PRIMARY KEY NOT NULL AUTO_INCREMENT, name varchar(255), external_id INT unsigned NOT NULL DEFAULT 0); CREATE TABLE IF NOT EXISTS gradebook_evaluation_type(id INT unsigned PRIMARY KEY NOT NULL AUTO_INCREMENT, name varchar(255), external_id INT unsigned NOT NULL DEFAULT 0);
CREATE TABLE IF NOT EXISTS question_field (id int NOT NULL auto_increment, field_type int NOT NULL default 1, field_variable varchar(64) NOT NULL, field_display_text varchar(64), field_default_value text, field_order int, field_visible tinyint default 0, field_changeable tinyint default 0, field_filter tinyint default 0, tms DATETIME NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY(id)); CREATE TABLE IF NOT EXISTS question_field (id int NOT NULL auto_increment, field_type int NOT NULL default 1, field_variable varchar(64) NOT NULL, field_display_text varchar(64), field_default_value text, field_order int, field_visible tinyint default 0, field_changeable tinyint default 0, field_filter tinyint default 0, tms DATETIME NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY(id));
CREATE TABLE IF NOT EXISTS question_field_options(id int NOT NULL auto_increment, field_id int NOT NULL, option_value text, option_display_text varchar(255), option_order int, tms DATETIME NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (id)); CREATE TABLE IF NOT EXISTS question_field_options(id int NOT NULL auto_increment, field_id int NOT NULL, option_value text, option_display_text varchar(255), option_order int, tms DATETIME NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (id));
@ -42,6 +43,9 @@ CREATE TABLE IF NOT EXISTS branch_transaction (id bigint unsigned not null AUTO_
-- ALTER TABLE c_lp_item ADD INDEX idx_c_lp_item_cid_lp_id (c_id, lp_id); -- ALTER TABLE c_lp_item ADD INDEX idx_c_lp_item_cid_lp_id (c_id, lp_id);
-- ALTER TABLE c_lp_item_view ADD INDEX idx_c_lp_item_view_cid_lp_view_id_lp_item_id(c_id, lp_view_id, lp_item_id); -- ALTER TABLE c_lp_item_view ADD INDEX idx_c_lp_item_view_cid_lp_view_id_lp_item_id(c_id, lp_view_id, lp_item_id);
ALTER TABLE c_student_publication ADD COLUMN filename varchar(255) DEFAULT NULL;
ALTER TABLE course ADD COLUMN add_teachers_to_sessions_courses tinyint NOT NULL default 0;
ALTER TABLE c_tool_intro MODIFY COLUMN intro_text MEDIUMTEXT NOT NULL; ALTER TABLE c_tool_intro MODIFY COLUMN intro_text MEDIUMTEXT NOT NULL;
ALTER TABLE user MODIFY COLUMN hr_dept_id int unsigned default 0; ALTER TABLE user MODIFY COLUMN hr_dept_id int unsigned default 0;
ALTER TABLE session MODIFY COLUMN nbr_courses int unsigned NOT NULL default 0; ALTER TABLE session MODIFY COLUMN nbr_courses int unsigned NOT NULL default 0;
@ -152,4 +156,4 @@ INSERT INTO branch_transaction_status VALUES (1, 'To be executed'), (2, 'Execute
UPDATE course_field SET field_type = 3 WHERE field_variable = 'special_course'; UPDATE course_field SET field_type = 3 WHERE field_variable = 'special_course';
-- Do not move this -- Do not move this
UPDATE settings_current SET selected_value = '1.10.0.044' WHERE variable = 'chamilo_database_version'; UPDATE settings_current SET selected_value = '1.10.0.047' WHERE variable = 'chamilo_database_version';

@ -70,6 +70,9 @@ $update = function($_configuration, \Doctrine\DBAL\Connection $mainConnection, $
$sql = "SELECT id, code FROM $course_table"; $sql = "SELECT id, code FROM $course_table";
$result = $mainConnection->executeQuery($sql); $result = $mainConnection->executeQuery($sql);
$rows = $result->fetchAll(); $rows = $result->fetchAll();
$courseSettingtable = "$dbNameForm.c_course_setting";
foreach ($rows as $row) { foreach ($rows as $row) {
$courseId = $row['id']; $courseId = $row['id'];
$courseCode = $row['code']; $courseCode = $row['code'];
@ -97,6 +100,19 @@ $update = function($_configuration, \Doctrine\DBAL\Connection $mainConnection, $
$sql = "INSERT INTO $accessUrlRelCourseTable (access_url_id, course_code, c_id) VALUES ('1', '$courseCode', '$courseId')"; $sql = "INSERT INTO $accessUrlRelCourseTable (access_url_id, course_code, c_id) VALUES ('1', '$courseCode', '$courseId')";
$mainConnection->executeQuery($sql); $mainConnection->executeQuery($sql);
} }
$sql = "SELECT c_id FROM $courseSettingtable WHERE c_id = $courseId WHERE variable = 'show_course_system_documents'";
$result = $mainConnection->executeQuery($sql);
if ($result->rowCount() == 0) {
$mainConnection->executeQuery($sql);
$data = array(
'variable' => 'show_course_system_documents',
'c_id' => $courseId,
'category' => 'documents',
'value' => '0'
);
$mainConnection->insert($courseSettingtable, $data);
}
} }
// Updating c_quiz_order // Updating c_quiz_order

Loading…
Cancel
Save