Skip to content

Commit

Permalink
Fixed creation of survey timings table
Browse files Browse the repository at this point in the history
  • Loading branch information
mennodekker committed May 2, 2012
1 parent c584f2f commit b5d9ab0
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions application/helpers/admin/activate_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,6 @@ function activateSurvey($surveyid, $simulate = false)
break;
case 'id':
$createsurvey[$arow['fieldname']] = "INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY";
$createsurveytimings .= " `{$arow['fieldname']}` INT NOT NULL PRIMARY,\n";
break;
case "startdate":
case "datestamp":
Expand Down Expand Up @@ -456,24 +455,32 @@ function activateSurvey($surveyid, $simulate = false)
}
}
}
}

if (isset($savetimings) && $savetimings=="TRUE")
{
$timingsfieldmap = createTimingsFieldMap($surveyid,"full",false,false,getBaseLanguageFromSurveyID($surveyid));
$createsurveytimings .= '`'.implode("` F DEFAULT '0',\n`",array_keys($timingsfieldmap)) . "` F DEFAULT '0'";

if (isset($savetimings) && $savetimings=="TRUE")
{
$timingsfieldmap = createTimingsFieldMap($surveyid,"full",false,false,getBaseLanguageFromSurveyID($surveyid));

$column = array();
$column['id'] = $createsurvey['id'];
foreach ($timingsfieldmap as $field=>$fielddata)
{
$column[$field] = 'FLOAT';
}

foreach ($timingsfieldmap as $field=>$fielddata)
{
$column[$field] = 'FLOAT';
}
$command = new CDbCommand(Yii::app()->db);
foreach($column as $name => $type)
{
$command->addColumn($tabname,$name,$type);
}
$command = new CDbCommand(Yii::app()->db);
$tabname = "{{survey_{$surveyid}}}_timings";
try
{
$execresult = $command->createTable($tabname,$column);
$execresult = true;
}
catch (CDbException $e)
{
echo $e->getMessage();
$execresult = false;
}

}

$activateoutput .= "<br />\n<div class='messagebox ui-corner-all'>\n";
Expand Down

0 comments on commit b5d9ab0

Please sign in to comment.