Skip to content

Commit

Permalink
Add //AJS tags to all remaining references to the types: 179 referenc…
Browse files Browse the repository at this point in the history
…es remaining.

Port some of the basic references to types. At this point, the print answers, statistics, and import functions are the main big targets remaining.
  • Loading branch information
aaronschmitz committed Aug 16, 2012
1 parent 1f117b6 commit 851a83c
Show file tree
Hide file tree
Showing 54 changed files with 404 additions and 512 deletions.
2 changes: 1 addition & 1 deletion application/controllers/Statistics_userController.php
Expand Up @@ -217,7 +217,7 @@ function actionAction($surveyid,$postlang)
//store some column names in $filters array
$filters[]=array($row['qid'],
$row['gid'],
$row['type'],
$row['type'], //AJS
$row['title'],
$row['group_name'],
flattenText($row['question']));
Expand Down
255 changes: 126 additions & 129 deletions application/controllers/admin/conditionsaction.php

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions application/controllers/admin/database.php
Expand Up @@ -86,13 +86,13 @@ function index($sa = null)
}
}
}
if ($qproperties['subquestions']>0)
else if ($qproperties['subquestions']>0)
{

foreach ($questlangs as $language)
{

$sqresult = Questions::model()->findByAttributes(array('sid'=>$surveyid, 'gid'=>$gid, 'parent_qid'=>$qid, 'language'=>$language, 'scale_id'=>0));
$sqresult = Questions::model()->findAllByAttributes(array('sid'=>$surveyid, 'gid'=>$gid, 'parent_qid'=>$qid, 'language'=>$language, 'scale_id'=>0));

for ($scale_id=0;$scale_id<$qproperties['subquestions'];$scale_id++)
{
Expand All @@ -107,7 +107,7 @@ function index($sa = null)
}
}
}
if ($qproperties['answerscales']==0 && $qproperties['subquestions']==0)
else if ($qproperties['answerscales']==0 && $qproperties['subquestions']==0)
{
foreach ($questlangs as $language)
{
Expand Down Expand Up @@ -401,12 +401,12 @@ function index($sa = null)
$_POST['help_'.$baselang]=fixCKeditorText(Yii::app()->request->getPost('help_'.$baselang));
}

$type = Question_types::model()->findByPk(Yii::app()->request->getPost('type')); //AJS
$type = Question_types::model()->findByPk(Yii::app()->request->getPost('type')); //AJSL
$data = array(
'sid' => $surveyid,
'gid' => $gid,
'tid' => Yii::app()->request->getPost('type'),
'type' => $type['legacy'], //AJS
'type' => $type['legacy'], //AJSL
'title' => Yii::app()->request->getPost('title'),
'question' => Yii::app()->request->getPost('question_'.$baselang),
'preg' => Yii::app()->request->getPost('preg'),
Expand All @@ -431,7 +431,7 @@ function index($sa = null)
'sid' => $surveyid,
'gid' => $gid,
'tid' => Yii::app()->request->getPost('type'),
'type' => $type['legacy'], //AJS
'type' => $type['legacy'], //AJSL
'title' => Yii::app()->request->getPost('title'),
'question' => Yii::app()->request->getPost('question_'.$alang),
'preg' => Yii::app()->request->getPost('preg'),
Expand Down Expand Up @@ -707,10 +707,10 @@ function index($sa = null)

if (isset($qlang) && $qlang != "")
{ // ToDo: Sanitize the POST variables !
$type = Question_types::model()->findByPk(Yii::app()->request->getPost('type')); //AJS
$type = Question_types::model()->findByPk(Yii::app()->request->getPost('type')); //AJSL
$udata = array(
'tid' => Yii::app()->request->getPost('type'),
'type' => $type['legacy'],
'type' => $type['legacy'], //AJSL
'title' => Yii::app()->request->getPost('title'),
'question' => Yii::app()->request->getPost('question_'.$qlang),
'preg' => Yii::app()->request->getPost('preg'),
Expand Down Expand Up @@ -769,8 +769,8 @@ function index($sa = null)
}
if ($oldtid != Yii::app()->request->getPost('type'))
{
$type = Question_types::model()->findByPk(Yii::app()->request->getPost('type')); //AJS
Questions::model()->updateAll(array('tid'=>Yii::app()->request->getPost('type'), 'type'=>$type['legacy']), 'parent_qid=:qid', array(':qid'=>$qid));
$type = Question_types::model()->findByPk(Yii::app()->request->getPost('type')); //AJSL
Questions::model()->updateAll(array('tid'=>Yii::app()->request->getPost('type'), 'type'=>$type['legacy']), 'parent_qid=:qid', array(':qid'=>$qid)); //AJSL
}

Answers::model()->deleteAllByAttributes(array('qid' => $qid), 'scale_id >= :scale_id', array(':scale_id' => $iAnswerScales));
Expand Down
6 changes: 3 additions & 3 deletions application/controllers/admin/dataentry.php
Expand Up @@ -1332,7 +1332,7 @@ public function view($surveyid, $lang=NULL)

case "L": //LIST drop-down/radio-button list
case "!":
if ($deqrow['type']=='!' && trim($qidattributes['category_separator'])!='')
if (array_key_exists('category_separator', $qidattributes) && trim($qidattributes['category_separator'])!='')
{
$optCategorySeparator = $qidattributes['category_separator'];
}
Expand Down Expand Up @@ -1566,7 +1566,7 @@ public function view($surveyid, $lang=NULL)
break;
case "E": //ARRAY (YES/UNCERTAIN/NO) radio-buttons
$meaquery = "SELECT title, question FROM {{questions}} WHERE parent_qid={$deqrow['qid']} AND language='{$sDataEntryLanguage}' ORDER BY question_order";
$mearesult=dbExecuteAssoc($meaquery) or safeDie ("Couldn't get answers, Type \"E\"<br />$meaquery<br />");
$mearesult=dbExecuteAssoc($meaquery) or safeDie ("Couldn't get answers, Type \":\"<br />$meaquery<br />");
$cdata['mearesult'] = $mearesult->readAll();

break;
Expand Down Expand Up @@ -1627,7 +1627,7 @@ public function view($surveyid, $lang=NULL)
case "F": //ARRAY (Flexible Labels)
case "H":
$meaquery = "SELECT * FROM {{questions}} WHERE parent_qid={$deqrow['qid']} and language='{$sDataEntryLanguage}' ORDER BY question_order";
$mearesult=dbExecuteAssoc($meaquery) or safeDie ("Couldn't get answers, Type \"E\"<br />$meaquery<br />");
$mearesult=dbExecuteAssoc($meaquery) or safeDie ("Couldn't get answers, Type \":\"<br />$meaquery<br />");

$cdata['mearesult'] = $mearesult->readAll();

Expand Down
4 changes: 2 additions & 2 deletions application/controllers/admin/printablesurvey.php
Expand Up @@ -257,7 +257,7 @@ function index($surveyid, $lang = null)
// START doing questions

$qidattributes=getQuestionAttributeValues($deqrow['qid']);
if ($qidattributes['hidden'] == 1 && $deqrow['type'] != '*')
if ($qidattributes['hidden'] == 1 && $deqrow['type'] != '*') //AJS
{
continue;
}
Expand Down Expand Up @@ -351,7 +351,7 @@ function index($surveyid, $lang = null)
$question['QUESTION_CLASS'] ="max-chars-{$qidattributes['maximum_chars']} ".$question['QUESTION_CLASS'];
}

switch($deqrow['type'])
switch($deqrow['type']) //AJS
{
// ==================================================================
case "5": //5 POINT CHOICE
Expand Down
38 changes: 20 additions & 18 deletions application/controllers/admin/question.php
Expand Up @@ -120,26 +120,26 @@ public function editdefaultvalues($surveyid, $gid, $qid)
$baselang = Survey::model()->findByPk($surveyid)->language;
array_unshift($questlangs, $baselang);

$questionrow = Questions::model()->with('question_types')->findByAttributes(array(
$result = Questions::model()->with('question_types')->findByAttributes(array(
'qid' => $qid,
'gid' => $gid,
'language' => $baselang
))->attributes;
$q = createQuestion($questionrow->question_types['class']);
));
$questionrow=$result->attributes;
$q = createQuestion($result->question_types['class']);
$qproperties=$q->questionProperties();

$langopts = array();
foreach ($questlangs as $language)
{
$langopts[$language] = array();
$langopts[$language][$questionrow['type']] = array();

// If there are answerscales
if ($qproperties['answerscales'] > 0)
{
for ($scale_id = 0; $scale_id < $qproperties['answerscales']; $scale_id++)
{
$langopts[$language][$questionrow['type']][$scale_id] = array();
$langopts[$language][$scale_id] = array();

$defaultvalue = Defaultvalues::model()->findByAttributes(array(
'specialtype' => '',
Expand All @@ -150,13 +150,13 @@ public function editdefaultvalues($surveyid, $gid, $qid)

$defaultvalue = $defaultvalue != null ? $defaultvalue->defaultvalue : null;

$langopts[$language][$questionrow['type']][$scale_id]['defaultvalue'] = $defaultvalue;
$langopts[$language][$scale_id]['defaultvalue'] = $defaultvalue;

$answerresult = Answers::model()->findAllByAttributes(array(
'qid' => $qid,
'language' => $language
), array('order' => 'sortorder'));
$langopts[$language][$questionrow['type']][$scale_id]['answers'] = $answerresult;
$langopts[$language][$scale_id]['answers'] = $answerresult;

if ($questionrow['other'] == 'Y')
{
Expand All @@ -168,7 +168,7 @@ public function editdefaultvalues($surveyid, $gid, $qid)
));

$defaultvalue = $defaultvalue != null ? $defaultvalue->defaultvalue : null;
$langopts[$language][$questionrow['type']]['Ydefaultvalue'] = $defaultvalue;
$langopts[$language]['Ydefaultvalue'] = $defaultvalue;
}
}
}
Expand All @@ -179,7 +179,7 @@ public function editdefaultvalues($surveyid, $gid, $qid)
{
for ($scale_id = 0; $scale_id < $qproperties['subquestions']; $scale_id++)
{
$langopts[$language][$questionrow['type']][$scale_id] = array();
$langopts[$language][$scale_id] = array();

$sqresult = Questions::model()->findAllByAttributes(array(
'sid' => $surveyid,
Expand All @@ -189,10 +189,10 @@ public function editdefaultvalues($surveyid, $gid, $qid)
'scale_id' => 0
), array('order' => 'question_order'));

$langopts[$language][$questionrow['type']][$scale_id]['sqresult'] = array();
$langopts[$language][$scale_id]['sqresult'] = array();

$options = array();
if ($questionrow['type'] == 'M' || $questionrow['type'] == 'P')
if ($q->useCheckboxes())
$options = array('' => $clang->gT('<No default value>'), 'Y' => $clang->gT('Checked'));

foreach ($sqresult as $aSubquestion)
Expand All @@ -209,20 +209,20 @@ public function editdefaultvalues($surveyid, $gid, $qid)
$aSubquestion['defaultvalue'] = $defaultvalue;
$aSubquestion['options'] = $options;

$langopts[$language][$questionrow['type']][$scale_id]['sqresult'][] = $aSubquestion;
$langopts[$language][$scale_id]['sqresult'][] = $aSubquestion;
}
}
}
if ($qtproperties[$questionrow['type']]['answerscales'] == 0 &&
$qtproperties[$questionrow['type']]['subquestions'] == 0)
if ($qproperties['answerscales'] == 0 &&
$qproperties['subquestions'] == 0)
{
$defaultvalue = Defaultvalues::model()->findByAttributes(array(
'specialtype' => '',
'qid' => $qid,
'scale_id' => 0,
'language' => $language
));
$langopts[$language][$questionrow['type']][0] = $defaultvalue != null ? $defaultvalue->defaultvalue : null;
$langopts[$language][0] = $defaultvalue != null ? $defaultvalue->defaultvalue : null;
}

}
Expand All @@ -234,7 +234,7 @@ public function editdefaultvalues($surveyid, $gid, $qid)
'questionrow' => $questionrow,
'questlangs' => $questlangs,
'gid' => $gid,
'qtproperties' => $qtproperties,
'qproperties' => $qproperties,
'baselang' => $baselang,
);
$aData['display']['menu_bars']['surveysummary'] = 'editdefaultvalues';
Expand Down Expand Up @@ -694,7 +694,8 @@ public function index($sa, $surveyid, $gid, $qid=null)
'question_order' => $esrow['question_order'],
'other' => $esrow['other'],
'mandatory' => $esrow['mandatory'],
'type' => $esrow['type'], //AJS
'tid' => $esrow['tid'],
'type' => $esrow['type'], //AJSL
'title' => $esrow['title'],
'preg' => $esrow['preg'],
'question' => $esrow['question'],
Expand All @@ -714,7 +715,8 @@ public function index($sa, $surveyid, $gid, $qid=null)
'qid' => $qid,
'sid' => $surveyid,
'gid' => $gid,
'type' => $basesettings['type'], //AJS
'tid' => $basesettings['tid'],
'type' => $basesettings['type'], //AJSL
'title' => $basesettings['title'],
'question' => $basesettings['question'],
'preg' => $basesettings['preg'],
Expand Down
18 changes: 9 additions & 9 deletions application/controllers/admin/quotas.php
Expand Up @@ -362,7 +362,7 @@ function new_answer($iSurveyId, $sSubAction = 'new_answer')
$quota_name = $aQuotaDetails['name'];
}

$result = Questions::model()->findAllByAttributes(array('type' => array('G', 'M', 'Y', 'A', 'B', 'I', 'L', 'O', '!'), 'sid' => $iSurveyId, 'language' => $sBaseLang));
$result = Questions::model()->findAllByAttributes(array('type' => array('G', 'M', 'Y', 'A', 'B', 'I', 'L', 'O', '!'), 'sid' => $iSurveyId, 'language' => $sBaseLang)); //AJS
if (empty($result))
{
$aViewUrls[] = 'newanswererror_view';
Expand Down Expand Up @@ -421,9 +421,9 @@ function getQuotaAnswers($iQuestionId, $iSurveyId, $iQuotaId)
$clang = $aData['clang'];

$aQuestion = Questions::model()->findByPk(array('qid' => $iQuestionId, 'language' => $sBaseLang));
$aQuestionType = $aQuestion['type'];
$aQuestionType = $aQuestion['type']; //AJS

if ($aQuestionType == 'M')
if ($aQuestionType == 'M') //AJS
{
$aResults = Questions::model()->findAllByAttributes(array('parent_qid' => $iQuestionId));
$aAnswerList = array();
Expand All @@ -445,7 +445,7 @@ function getQuotaAnswers($iQuestionId, $iSurveyId, $iQuotaId)
$aResults = Quota_members::model()->findAllByAttributes(array('sid' => $iSurveyId, 'qid' => $iQuestionId, 'quota_id' => $iQuotaId));
}

if ($aQuestionType == 'G')
if ($aQuestionType == 'G') //AJS
{
$aAnswerList = array('M' => array('Title' => $aQuestion['title'], 'Display' => $clang->gT("Male"), 'code' => 'M'),
'F' => array('Title' => $aQuestion['title'], 'Display' => $clang->gT("Female"), 'code' => 'F'));
Expand All @@ -456,7 +456,7 @@ function getQuotaAnswers($iQuestionId, $iSurveyId, $iQuotaId)
}
}

if ($aQuestionType == 'L' || $aQuestionType == 'O' || $aQuestionType == '!')
if ($aQuestionType == 'L' || $aQuestionType == 'O' || $aQuestionType == '!') //AJS
{
$aAnsResults = Answers::model()->findAllByAttributes(array('qid' => $iQuestionId));

Expand All @@ -470,7 +470,7 @@ function getQuotaAnswers($iQuestionId, $iSurveyId, $iQuotaId)
}
}

if ($aQuestionType == 'A')
if ($aQuestionType == 'A') //AJS
{
$aAnsResults = Questions::model()->findAllByAttributes(array('parent_qid' => $iQuestionId));

Expand All @@ -491,7 +491,7 @@ function getQuotaAnswers($iQuestionId, $iSurveyId, $iQuotaId)
}
}

if ($aQuestionType == 'B')
if ($aQuestionType == 'B') //AJS
{
$aAnsResults = Answers::model()->findAllByAttributes(array('qid' => $iQuestionId));

Expand All @@ -512,7 +512,7 @@ function getQuotaAnswers($iQuestionId, $iSurveyId, $iQuotaId)
}
}

if ($aQuestionType == 'Y')
if ($aQuestionType == 'Y') //AJS
{
$aAnswerList = array('Y' => array('Title' => $aQuestion['title'], 'Display' => $clang->gT("Yes"), 'code' => 'Y'),
'N' => array('Title' => $aQuestion['title'], 'Display' => $clang->gT("No"), 'code' => 'N'));
Expand All @@ -523,7 +523,7 @@ function getQuotaAnswers($iQuestionId, $iSurveyId, $iQuotaId)
}
}

if ($aQuestionType == 'I')
if ($aQuestionType == 'I') //AJS
{
$slangs = Survey::model()->findByPk($iSurveyId)->additionalLanguages;
array_unshift($slangs, $sBaseLang);
Expand Down
8 changes: 4 additions & 4 deletions application/controllers/admin/remotecontrol.php
Expand Up @@ -1550,7 +1550,7 @@ public function set_question_properties($sSessionKey, $iQuestionID, $aQuestionDa
unset($aQuestionData['sid']);
unset($aQuestionData['parent_qid']);
unset($aQuestionData['language']);
unset($aQuestionData['type']);
unset($aQuestionData['class']);
// Remove invalid fields
$aDestinationFields=array_flip(Questions::model()->tableSchema->columnNames);
$aQuestionData=array_intersect_key($aQuestionData,$aDestinationFields);
Expand Down Expand Up @@ -1635,17 +1635,17 @@ public function list_questions($sSessionKey, $iSurveyID, $iGroupID=NULL, $sLangu
if($sGroupSurveyID != $iSurveyID)
return array('status' => 'Error: IMissmatch in surveyid and groupid');
else
$aQuestionList = Questions::model()->findAllByAttributes(array("sid"=>$iSurveyID, "gid"=>$iGroupID,"parent_qid"=>"0","language"=>$sLanguage));
$aQuestionList = Questions::model()->with('question_types')->findAllByAttributes(array("sid"=>$iSurveyID, "gid"=>$iGroupID,"parent_qid"=>"0","language"=>$sLanguage));
}
else
$aQuestionList = Questions::model()->findAllByAttributes(array("sid"=>$iSurveyID,"parent_qid"=>"0", "language"=>$sLanguage));
$aQuestionList = Questions::model()->with('question_types')->findAllByAttributes(array("sid"=>$iSurveyID,"parent_qid"=>"0", "language"=>$sLanguage));

if(count($aQuestionList)==0)
return array('status' => 'No questions found');

foreach ($aQuestionList as $oQuestion)
{
$aData[]= array('id'=>$oQuestion->primaryKey,'type'=>$oQuestion->attributes['type'], 'question'=>$oQuestion->attributes['question']);
$aData[]= array('id'=>$oQuestion->primaryKey,'class'=>$oQuestion->question_types['class', 'question'=>$oQuestion->attributes['question']);
}
return $aData;
}
Expand Down

0 comments on commit 851a83c

Please sign in to comment.