diff --git a/application/config/version.php b/application/config/version.php
index 6c777821381..99cc1f1d522 100644
--- a/application/config/version.php
+++ b/application/config/version.php
@@ -12,7 +12,7 @@
*
*/
-$config['versionnumber'] = "2.0RC8";
+$config['versionnumber'] = "2.0RC9";
$config['dbversionnumber'] = 162;
$config['buildnumber'] = '';
$config['updatable'] = false;
diff --git a/application/controllers/admin/database.php b/application/controllers/admin/database.php
index 718d6075fac..79689d98814 100644
--- a/application/controllers/admin/database.php
+++ b/application/controllers/admin/database.php
@@ -695,7 +695,7 @@ function index($sa = null)
// Moving question to a 'upper' group
// insert question at the end of the destination group
// this prevent breaking conditions if the target qid is in the dest group
- $insertorder = getMaxQuestionOrder($gid) + 1;
+ $insertorder = getMaxQuestionOrder($gid,$surveyid) + 1;
$udata = array_merge($udata,array('question_order' => $insertorder));
}
else
diff --git a/application/controllers/admin/statistics.php b/application/controllers/admin/statistics.php
index d182c0e19f0..8689a1caca8 100644
--- a/application/controllers/admin/statistics.php
+++ b/application/controllers/admin/statistics.php
@@ -453,7 +453,7 @@ public function run($surveyid = 0, $subaction = null)
Yii::app()->loadHelper('admin/statistics');
$showtextinline=isset($_POST['showtextinline']) ? 1 : 0;
$aData['showtextinline'] = $showtextinline;
-
+
//Show Summary results
if (isset($summary) && $summary)
{
@@ -497,6 +497,7 @@ public function run($surveyid = 0, $subaction = null)
function listcolumn($surveyid, $column, $sql, $sortby="", $sortmethod="", $sorttype="")
{
$search['condition']=$column." != ''";
+ if($sql != "") {$search['condition'].= " AND ($sql)";}
if($sorttype=='N') {$sortby = "($sortby * 1)";} //Converts text sorting into numerical sorting
if($sortby != "") $search['order']=$sortby.' '.$sortmethod;
$results=Survey_dynamic::model($surveyid)->findAll($search);
diff --git a/application/controllers/survey/index.php b/application/controllers/survey/index.php
index 2a95c10cf69..5d282c3c2ac 100644
--- a/application/controllers/survey/index.php
+++ b/application/controllers/survey/index.php
@@ -145,6 +145,7 @@ function action()
//CHECK FOR REQUIRED INFORMATION (sid)
if ($surveyid && $surveyExists)
{
+ LimeExpressionManager::SetSurveyId($surveyid); // must be called early - it clears internal cache if a new survey is being used
$clang = SetSurveyLanguage( $surveyid, $sTempLanguage);
UpdateSessionGroupList($surveyid, $sTempLanguage); // to refresh the language strings in the group list session variable
UpdateFieldArray(); // to refresh question titles and question text
diff --git a/application/helpers/admin/import_helper.php b/application/helpers/admin/import_helper.php
index 813105f52a8..f5816394264 100644
--- a/application/helpers/admin/import_helper.php
+++ b/application/helpers/admin/import_helper.php
@@ -4322,15 +4322,11 @@ function ExcelImportSurvey($sFullFilepath)
}
// Create the survey entry
- $iNewSID=GetNewSurveyID($iOldSID);
$surveyinfo['startdate']=NULL;
- $surveyinfo['sid']=$iNewSID;
$surveyinfo['active']='N';
- $surveyinfo['owner_id']=$_SESSION['loginID'];
- $surveyinfo['datecreated']= date('Y-m-d');
-
switchMSSQLIdentityInsert('surveys',true);
$iNewSID = Survey::model()->insertNewSurvey($surveyinfo) or safeDie($clang->gT("Error").": Failed to insert survey
");
+ $surveyinfo['sid']=$iNewSID;
$results['surveys']++;
switchMSSQLIdentityInsert('surveys',false);
$results['newsid']=$iNewSID;
diff --git a/application/helpers/frontend_helper.php b/application/helpers/frontend_helper.php
index d6459c87699..9b0dda156c1 100644
--- a/application/helpers/frontend_helper.php
+++ b/application/helpers/frontend_helper.php
@@ -1605,6 +1605,17 @@ function buildsurveysession($surveyid,$previewGroup=false)
$totalquestions = count($unique);
$_SESSION['survey_'.$surveyid]['totalquestions'] = $totalquestions - count($display);
+
+ // Fix totalquestions by substracting Test Display questions
+ $iNumberofQuestions=dbExecuteAssoc("SELECT count(*)\n"
+ ." FROM {{questions}}"
+ ." WHERE type in ('X','*')\n"
+ ." AND sid={$surveyid}"
+ ." AND language='".$_SESSION['survey_'.$surveyid]['s_lang']."'"
+ ." AND parent_qid=0")->read();
+
+ $_SESSION['survey_'.$surveyid]['totalquestions'] = $totalquestions - (int) reset($iNumberofQuestions);
+
//2. SESSION VARIABLE: totalsteps
//The number of "pages" that will be presented in this survey
//The number of pages to be presented will differ depending on the survey format
diff --git a/application/libraries/admin/excel/excel_reader2.php b/application/libraries/admin/excel/excel_reader2.php
index a935f402e4d..522d4c606f6 100644
--- a/application/libraries/admin/excel/excel_reader2.php
+++ b/application/libraries/admin/excel/excel_reader2.php
@@ -858,7 +858,7 @@ function dump($row_numbers=false,$col_letters=false,$sheet=0,$table_class='excel
function read16bitstring($data, $start) {
$len = 0;
while (ord($data[$start + $len]) + ord($data[$start + $len + 1]) > 0) $len++;
- return substr($data, $start, $len);
+ return substr($data, $start, $len+1);
}
// ADDED by Matt Kruse for better formatting
diff --git a/application/models/Conditions.php b/application/models/Conditions.php
index 04e0d71eff7..d7fc01aba3a 100644
--- a/application/models/Conditions.php
+++ b/application/models/Conditions.php
@@ -96,7 +96,34 @@ public function deleteRecords($condition=FALSE)
}
+ /**
+ * Updates the group ID for all conditions
+ *
+ * @param integer $iSurveyID
+ * @param integer $iQuestionID
+ * @param integer $iOldGroupID
+ * @param integer $iNewGroupID
+ */
+ public function updateCFieldName($iSurveyID, $iQuestionID, $iOldGroupID, $iNewGroupID)
+ {
+ $oResults=$this->findAllByAttributes(array('cqid'=>$iQuestionID));
+ foreach ($oResults as $oRow)
+ {
+
+ $cfnregs='';
+ if (preg_match('/'.$surveyid."X".$iOldGroupID."X".$iQuestionID."(.*)/", $oRow->cfieldname, $cfnregs) > 0)
+ {
+ $newcfn=$surveyid."X".$iNewGroupID."X".$iQuestionID.$cfnregs[1];
+ $c2query="UPDATE ".db_table_name('conditions')
+ ." SET cfieldname='{$newcfn}' WHERE cid={$oRow->cid}";
+
+ Yii::app()->db->createCommand($c2query)->query();
+ }
+ }
+ }
+
+
public function insertRecords($data, $update=FALSE, $condition=FALSE)
{
$record = new self;
@@ -126,6 +153,7 @@ public function insertRecords($data, $update=FALSE, $condition=FALSE)
else
return $record->save();
}
+
function getScenarios($qid)
{
@@ -133,6 +161,7 @@ function getScenarios($qid)
return Yii::app()->db->createCommand($scenarioquery)->query();
}
+
function getSomeConditions($fields, $condition, $order, $group){
$record = Yii::app()->db->createCommand()
->select($fields)
diff --git a/application/views/admin/checkintegrity/check_view.php b/application/views/admin/checkintegrity/check_view.php
index 2d24709064b..46c16734e84 100644
--- a/application/views/admin/checkintegrity/check_view.php
+++ b/application/views/admin/checkintegrity/check_view.php
@@ -32,7 +32,7 @@
-