Skip to content

Commit

Permalink
Frontend fixes for activating a survey.
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronschmitz committed Aug 15, 2012
1 parent 8d3d9ef commit dc5ba90
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
10 changes: 5 additions & 5 deletions application/helpers/admin/activate_helper.php
Expand Up @@ -102,7 +102,7 @@ function checkQuestions($postsid, $iSurveyID)
//CHECK TO MAKE SURE ALL QUESTION TYPES THAT REQUIRE ANSWERS HAVE ACTUALLY GOT ANSWERS

$chkquery = "SELECT qid, question, gid, type FROM {{questions}} WHERE sid={$iSurveyID} and parent_qid=0";
$chkresult = Questions::model()->with('question_types')->findAllByAttributes(array('sid' => $surveyid, 'parent_qid' => 0));
$chkresult = Questions::model()->with('question_types')->findAllByAttributes(array('sid' => $iSurveyID, 'parent_qid' => 0));

foreach ($chkresult as $chkrow)
{
Expand Down Expand Up @@ -203,7 +203,7 @@ function checkQuestions($postsid, $iSurveyID)
}

//CHECK THAT ALL THE CREATED FIELDS WILL BE UNIQUE
$fieldmap = createFieldMap($iSurveyID,'full',false,false,getBaseLanguageFromSurveyID($surveyid)); //AJS#
$fieldmap = createFieldMap($iSurveyID,'full',false,false,getBaseLanguageFromSurveyID($iSurveyID)); //AJS#
if (isset($fieldmap))
{
foreach($fieldmap as $fielddata)
Expand Down Expand Up @@ -252,7 +252,7 @@ function activateSurvey($iSurveyID, $simulate = false)
$prow = Survey::model()->findByAttributes(array('sid' => $iSurveyID));

//Get list of questions for the base language
$fieldmap = createFieldMap($iSurveyID,'full',true,false,getBaseLanguageFromSurveyID($surveyid)); //AJS
$fieldmap = createFieldMap($iSurveyID,'full',true,false,getBaseLanguageFromSurveyID($iSurveyID)); //AJS

$createsurvey = array();
foreach ($fieldmap as $arow) //With each question, create the appropriate field(s)
Expand Down Expand Up @@ -294,7 +294,7 @@ function activateSurvey($iSurveyID, $simulate = false)
$createsurvey[$q->fieldname] = $q->getDBField();
}

if ($q->fileUpload()) $createsurveydirectory = true;
if (is_a($q, 'QuestionModule') && $q->fileUpload()) $createsurveydirectory = true;

if ($simulate){
$tempTrim = trim($createsurvey);
Expand Down Expand Up @@ -356,7 +356,7 @@ function activateSurvey($iSurveyID, $simulate = false)

if ($prow->savetimings == "Y")
{
$timingsfieldmap = createFieldMap($iSurveyID,"short",false,false,getBaseLanguageFromSurveyID($surveyid)); //AJS#
$timingsfieldmap = createFieldMap($iSurveyID,"short",false,false,getBaseLanguageFromSurveyID($iSurveyID)); //AJS#

$column['id'] = $createsurvey['id'];
$column['interviewtime'] = 'FLOAT';
Expand Down
5 changes: 3 additions & 2 deletions application/helpers/common_helper.php
Expand Up @@ -2054,7 +2054,7 @@ function createFieldMap($surveyid, $style='short', $force_refresh=false, $questi
{
$cond.=" AND {{questions}}.qid=$questionid";
}
$aresult = Questions::model()->with('groups')->with('question_types')->findAll(array('condition'=>$cond, 'order'=>'groups.group_order, question_order'));
$aresult = Questions::model()->with('groups')->with('question_types')->findAll(array('condition'=>$cond, 'order'=>'groups.group_order, question_order', 'index' => 'qid'));
$questionSeq=-1; // this is incremental question sequence across all groups
$groupSeq=-1;
$_groupOrder=-1;
Expand All @@ -2079,7 +2079,8 @@ function createFieldMap($surveyid, $style='short', $force_refresh=false, $questi
// Implicit (subqestion intermal to a question type ) or explicit qubquestions/answer count starts at 1

$fieldname="{$arow['sid']}X{$arow['gid']}X{$arow['qid']}";
$pq = createQuestion($arow->question_types['class'], array('surveyid'=>$surveyid,
$class = empty($arow->question_types['class']) ? $aresult[$arow->parent_qid]->question_types['class'] : $arow->question_types['class'];
$pq = createQuestion($class, array('surveyid'=>$surveyid,
'id'=>$arow['qid'], 'fieldname'=>$fieldname,
'title'=>$arow['title'], 'text'=>$arow['question'],
'gid'=>$arow['gid'], 'mandatory'=>$arow['mandatory'],
Expand Down

0 comments on commit dc5ba90

Please sign in to comment.