Skip to content

Commit

Permalink
Dev: New column extended_type for question objects
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Sep 5, 2016
1 parent f56f958 commit 9d705d1
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 5 deletions.
Expand Up @@ -7,6 +7,7 @@ class TestQuestionObject // extends QuestionObjectBase
{

/**
* HTML
* @return string
*/
public function getAnswer()
Expand All @@ -15,9 +16,18 @@ public function getAnswer()
}

/**
* All question codes for this question
* @return array
*/
public function getQuestionCodes()
{
}

/**
* @return array
*/
public function getQuestionAttributes()
{
}

}
13 changes: 12 additions & 1 deletion application/helpers/update/updatedb_helper.php
Expand Up @@ -1433,16 +1433,27 @@ function db_upgrade_all($iOldDBVersion, $bSilent=false) {
$oDB->createCommand()->createIndex('notif_index', '{{notifications}}', 'entity, entity_id, status', false);
$oDB->createCommand()->update('{{settings_global}}',array('stg_value'=>259),"stg_name='DBVersion'");
}

if ($iOldDBVersion < 260) {
alterColumn('{{participant_attribute_names}}','defaultname',"string(255)",false);
alterColumn('{{participant_attribute_names_lang}}','attribute_name',"string(255)",false);
$oDB->createCommand()->update('{{settings_global}}',array('stg_value'=>260),"stg_name='DBVersion'");
}

/**
* For question object types, add a new column called extended_type to question table
* @since 2016-09-05
*/
if ($iOldDBVersion < 261) {
Yii::app()->db->createCommand()->addColumn('{{questions}}','extended_type','string(63)');
$oDB->createCommand()->update('{{settings_global}}',array('stg_value'=>261),"stg_name='DBVersion'");
}

// Inform superadmin about update
$superadmins = User::model()->getSuperAdmins();
Notification::broadcast(array(
'title' => gT('Database update'),
'message' => sprintf(gT('The database has been updated from version %s to version %s.'), $iOldDBVersion, '260')
'message' => sprintf(gT('The database has been updated from version %s to version %s.'), $iOldDBVersion, '261')
), $superadmins);


Expand Down
5 changes: 4 additions & 1 deletion application/models/QuestionAttribute.php
Expand Up @@ -194,7 +194,10 @@ public function getQuestionAttributes($iQuestionID)

if ($sType == '?')
{
// TODO: Get attributes from question object
// TODO: Check extended_type
// $extendedType = $oQuestion->extended_type
$extendedQuestion = new TestQustionObject();
$aAttributeNames = $extendedQuestion->getAttributeNames();
}
else
{
Expand Down
3 changes: 2 additions & 1 deletion installer/sql/create-mssql.sql
Expand Up @@ -272,6 +272,7 @@ CREATE TABLE [prefix_questions] (
[sid] int NOT NULL default '0',
[gid] int NOT NULL default '0',
[type] varchar(1) NOT NULL default 'T',
[extended_type] varchar(31) NULL,
[title] nvarchar(20) NOT NULL default '',
[question] nvarchar(max) NOT NULL,
[preg] nvarchar(max) NULL,
Expand Down Expand Up @@ -610,4 +611,4 @@ CREATE INDEX [notif_index] ON [prefix_notifications] ([entity_id],[entity],[stat
--
-- Version Info
--
INSERT INTO [prefix_settings_global] VALUES ('DBVersion', '260');
INSERT INTO [prefix_settings_global] VALUES ('DBVersion', '261');
3 changes: 2 additions & 1 deletion installer/sql/create-mysql.sql
Expand Up @@ -273,6 +273,7 @@ CREATE TABLE `prefix_questions` (
`sid` int(11) NOT NULL default '0',
`gid` int(11) NOT NULL default '0',
`type` varchar(1) NOT NULL default 'T',
`extended_type` varchar(31) DEFAULT NULL,
`title` varchar(20) NOT NULL default '',
`question` text NOT NULL,
`preg` text,
Expand Down Expand Up @@ -616,4 +617,4 @@ CREATE TABLE IF NOT EXISTS `prefix_notifications` (
--
-- Version Info
--
INSERT INTO `prefix_settings_global` VALUES ('DBVersion', '260');
INSERT INTO `prefix_settings_global` VALUES ('DBVersion', '261');
3 changes: 2 additions & 1 deletion installer/sql/create-pgsql.sql
Expand Up @@ -277,6 +277,7 @@ CREATE TABLE prefix_questions (
"sid" integer DEFAULT 0 NOT NULL,
"gid" integer DEFAULT 0 NOT NULL,
"type" character varying(1) DEFAULT 'T' NOT NULL,
"extended_type" character varying(31) NULL,
"title" character varying(20) DEFAULT '' NOT NULL,
"question" text NOT NULL,
"preg" text,
Expand Down Expand Up @@ -619,4 +620,4 @@ CREATE INDEX prefix_index ON prefix_notifications USING btree (entity, entity_id
--
-- Version Info
--
INSERT INTO prefix_settings_global VALUES ('DBVersion', '260');
INSERT INTO prefix_settings_global VALUES ('DBVersion', '261');

2 comments on commit 9d705d1

@LouisGac
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should not use n+1 for db version in a different branch

@olleharstedt
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, will be merge conflict.

Please sign in to comment.