Skip to content

Commit

Permalink
Dev Upgrade from an earlier version should be fully working now. It l…
Browse files Browse the repository at this point in the history
…ooks like it is not necessary to rename fields in the result table (phew)

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_dev@8362 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
c-schmitz committed Feb 9, 2010
1 parent 298594e commit befa2b5
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 16 deletions.
24 changes: 12 additions & 12 deletions admin/importsurvey.php
Original file line number Diff line number Diff line change
Expand Up @@ -886,29 +886,29 @@
}
$oldqid=$qid;

if ($importversion<143) {
if ($importversion<143)
{
unset($oldlid1); unset($oldlid2);
if ((isset($questionrowdata['lid']) && $questionrowdata['lid']>0))
{
{
$oldlid1=$questionrowdata['lid'];
}
}
if ((isset($questionrowdata['lid1']) && $questionrowdata['lid1']>0))
{
{
$oldlid2=$questionrowdata['lid1'];
}
// unset($questionrowdata['lid']);
// unset($questionrowdata['lid1']);
unset($questionrowdata['lid']);
unset($questionrowdata['lid1']);
if ($questionrowdata['type']=='W')
{
{
$questionrowdata['type']='!';
}
}
elseif ($questionrowdata['type']=='Z')
{
{
$questionrowdata['type']='L';

}
}

}
}

if (!isset($questionrowdata["question_order"]) || $questionrowdata["question_order"]=='') {$questionrowdata["question_order"]=0;}
$other = $questionrowdata["other"]; //Get 'other' field value
Expand Down
13 changes: 11 additions & 2 deletions admin/questionhandling.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,17 @@
} else {
$questlangs[$esrow['language']] = 99;
}
if ($esrow['language'] == $baselang) $basesettings = array('lid' => $esrow['lid'], 'lid1' => $esrow['lid1'],'question_order' => $esrow['question_order'],'other' => $esrow['other'],'mandatory' => $esrow['mandatory'],'type' => $esrow['type'],'title' => $esrow['title'],'preg' => $esrow['preg'],'question' => $esrow['question'],'help' => $esrow['help']);

if ($esrow['language'] == $baselang)
{
$basesettings = array('question_order' => $esrow['question_order'],
'other' => $esrow['other'],
'mandatory' => $esrow['mandatory'],
'type' => $esrow['type'],
'title' => $esrow['title'],
'preg' => $esrow['preg'],
'question' => $esrow['question'],
'help' => $esrow['help']);
}
}


Expand Down
34 changes: 32 additions & 2 deletions admin/update/upgrade-mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -554,8 +554,9 @@ function upgrade_tables143()
{
global $modifyoutput,$dbprefix, $connect;


// Convert answers to subquestions
$answerquery = "select a.*, q.sid, q.gid from {$dbprefix}answers a,{$dbprefix}questions q where a.qid=q.qid and q.type in ('1','A','B','C','E','F','H',';',':','M','P','Q')";
$answerquery = "select a.*, q.sid, q.gid from {$dbprefix}answers a,{$dbprefix}questions q where a.qid=q.qid and q.type in ('1','A','B','C','E','F','H','K',';',':','M','P','Q')";
$answerresult = db_execute_assoc($answerquery);
if (!$answerresult) {return "Database Error";}
else
Expand All @@ -568,7 +569,7 @@ function upgrade_tables143()
modify_database("","delete {$dbprefix}answers from {$dbprefix}answers LEFT join {$dbprefix}questions ON {$dbprefix}answers.qid={$dbprefix}questions.qid where {$dbprefix}questions.type in ('1','A','B','C','E','F','H',';',':')"); echo $modifyoutput; flush();

// Convert labels to answers
$answerquery = "select qid ,type ,lid ,lid1, language from {$dbprefix}questions where parent_qid=0 and type in ('1','F','H','M','P',';',':','W','Z')";
$answerquery = "select qid ,type ,lid ,lid1, language from {$dbprefix}questions where parent_qid=0 and type in ('1','F','H','M','P','W','Z')";
$answerresult = db_execute_assoc($answerquery);
if (!$answerresult)
{
Expand All @@ -583,6 +584,7 @@ function upgrade_tables143()
while ( $lrow = $labelresult->FetchRow() )
{
modify_database("","INSERT INTO {$dbprefix}answers (qid, code, answer, sortorder, language) VALUES ({$row['qid']},".db_quoteall($lrow['code']).",".db_quoteall($lrow['title']).",{$lrow['sortorder']},".db_quoteall($lrow['language']).")"); echo $modifyoutput; flush();
//$labelids[]
}
if ($row['type']=='1')
{
Expand All @@ -595,5 +597,33 @@ function upgrade_tables143()
}
}
}

// Convert labels to subquestions
$answerquery = "select * from {$dbprefix}questions where parent_qid=0 and type in (';',':')";
$answerresult = db_execute_assoc($answerquery);
if (!$answerresult)
{
return "Database Error";
}
else
{
while ( $row = $answerresult->FetchRow() )
{
$labelquery="Select * from {$dbprefix}labels where lid={$row['lid']} and language=".db_quoteall($row['language']);
$labelresult = db_execute_assoc($labelquery);
while ( $lrow = $labelresult->FetchRow() )
{
modify_database("","INSERT INTO {$dbprefix}questions (sid, gid, parent_qid, title, question, question_order, language, scale_id) VALUES ({$row['sid']},{$row['gid']},{$row['qid']},".db_quoteall($lrow['code']).",".db_quoteall($lrow['title']).",{$lrow['sortorder']},".db_quoteall($lrow['language']).",1)"); echo $modifyoutput; flush();
}
}
}




$updatequery = "update {$dbprefix}questions set type='!' where type='W'";
modify_database("",$updatequery); echo $modifyoutput; flush();
$updatequery = "update {$dbprefix}questions set type='L' where type='Z'";
modify_database("",$updatequery); echo $modifyoutput; flush();

}

0 comments on commit befa2b5

Please sign in to comment.