Skip to content

Commit

Permalink
Dev: Merge remote-tracking branch 'origin/develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisGac committed Aug 31, 2017
2 parents 119b2ff + b2c5563 commit 3bb8700
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 23 deletions.
4 changes: 2 additions & 2 deletions application/models/Question.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ public function relations()
return array(
'survey' => array(self::BELONGS_TO, 'Survey', 'sid'),
'groups' => array(self::BELONGS_TO, 'QuestionGroup', 'gid, language', 'together' => true),
'parents' => array(self::HAS_ONE, 'Question', '', 'on' => "$alias.parent_qid = parents.qid"),
'parents' => array(self::HAS_ONE, 'Question', array( "qid" => "parent_qid")),
'questionAttributes' => array(self::HAS_MANY, 'QuestionAttribute', 'qid'),
'subquestions' => array(self::HAS_MANY, 'Question', 'parent_qid', 'on' => "$alias.language = subquestions.language")
'subquestions' => array(self::HAS_MANY, 'Question', array('parent_qid'=>'qid', "language" => "language"))
);
}

Expand Down
2 changes: 1 addition & 1 deletion application/models/Survey.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ public function relations()
'defaultlanguage' => array(self::BELONGS_TO, 'SurveyLanguageSetting', array('language' => 'surveyls_language', 'sid' => 'surveyls_survey_id'), 'together' => true),
'correct_relation_defaultlanguage' => array(self::HAS_ONE, 'SurveyLanguageSetting', array('surveyls_language' => 'language', 'surveyls_survey_id' => 'sid'), 'together' => true),
'owner' => array(self::BELONGS_TO, 'User', 'owner_id', 'together' => true),
'groups' => array(self::HAS_MANY, 'QuestionGroup', 'sid', 'together' => true),
'groups' => array(self::HAS_MANY, 'QuestionGroup', 'sid', 'together' => true, 'order'=>'group_order ASC'),
'quotas' => array(self::HAS_MANY, 'Quota', 'sid','order'=>'name ASC'),
'surveymenus' => array(self::HAS_MANY, 'Surveymenu', array('survey_id' => 'sid')),
'surveygroup' => array(self::BELONGS_TO, 'SurveysGroups', array('gsid' => 'gsid'), 'together' => true),
Expand Down
47 changes: 36 additions & 11 deletions application/models/SurveyDynamic.php
Original file line number Diff line number Diff line change
Expand Up @@ -687,31 +687,56 @@ protected function filterColumns(CDbCriteria $criteria)
}
}

public function getQuestionArray($oQuestion, $oResponses, $bHonorConditions, $subquestion=false){
$attributes = QuestionAttribute::model()->getQuestionAttributes($oQuestion->qid);
if (!(LimeExpressionManager::QuestionIsRelevant($oQuestion->qid) || $bHonorConditions==false) && $attributes['hidden'] === 1){
return false;
}
$aQuestionAttributes = $oQuestion->attributes;
if(count($oQuestion->subquestions) > 0){
$aQuestionAttributes['subquestions'] = array();
foreach($oQuestion->subquestions as $oSubquestion){
$aQuestionAttributes['subquestions'][$oSubquestion->qid] = $this->getQuestionArray($oSubquestion,$oResponses,$bHonorConditions,true);
}
}
$fieldname= $oQuestion->sid."X".$oQuestion->gid."X";
if($subquestion){
$fieldname.=$oQuestion->parents['qid'].$oQuestion->title;
} else {
$fieldname.=$oQuestion->qid;
}
$aQuestionAttributes['fieldname'] = $fieldname;
$aQuestionAttributes['answervalue'] = isset($oResponses[$fieldname]) ? $oResponses[$fieldname] : null;
// $aQuestionAttributes['answervalue'] = Answer::model()->getAnswerFromCode($aQuestionAttributes['qid'],$fieldname,$sLanguageCode);
return $aQuestionAttributes;
}

public function getPrintAnswersArray($sSRID, $sLanguageCode, $bHonorConditions=true){

$oSurvey = $this->survey;
$oSurvey = self::$survey;
$aGroupArray = array();
$oResponses = SurveyDynamic::model($oSurvey->sid)->findByAttributes(array('id'=>$sSRID));
foreach ($oSurvey->groups as $oSurveyGroup)
$oResponses = SurveyDynamic::model($oSurvey->sid)->findByAttributes(array('id'=>$sSRID));
$oGroupList = $oSurvey->groups;

foreach ($oGroupList as $oSurveyGroup)
{
if (!(LimeExpressionManager::GroupIsRelevant($oSurveyGroup->gid) || $bHonorConditions==false)){
continue;
}
$aAnswersArray = array();
foreach ($oSurveyGroup->questions as $oQuestion){
$attributes = QuestionAttribute::model()->getQuestionAttributes($oQuestion->qid);
if (!(LimeExpressionManager::QuestionIsRelevant($oQuestion->qid) || $bHonorConditions==false) && $attributes['hidden'] === 1){
continue;
}
$aQuestionAttributes = $oQuestion->attributes;
$fieldname="{$aQuestionAttributes['sid']}X{$aQuestionAttributes['gid']}X{$aQuestionAttributes['qid']}";
$aQuestionAttributes['answervalue'] = (isset($oResponses[$fieldname]) ? $oResponses[$fieldname] : '');
$aAnswersArray[$oQuestion->qid] = $aQuestionAttributes;
$aQuestionArray = $this->getQuestionArray($oQuestion, $oResponses, $bHonorConditions);

if($aQuestionArray === false) continue;

$aAnswersArray[$oQuestion->qid] = $aQuestionArray;
}
$aGroupAttributes = $oSurveyGroup->attributes;
$aGroupAttributes['answerArray'] = $aAnswersArray;
$aGroupAttributes['debug'] = $oResponses->attributes;
$aGroupArray[$oSurveyGroup->gid] = $aGroupAttributes;
}

return $aGroupArray;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
</div>
</div>

Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
<pre>{{dump(question)}}</pre>
<div class="row">
<div class="col-md-4">
<b>{{question.question}} ({{question.qid}})</b>
</div>
<div class="col-md-8">
{{question.answervalue}}
</div>
</div>
{% if question.subquestions is empty %}
<div class="col-md-8">
{{question.answervalue}}
</div>
{% else %}
<div class="col-md-8">
{% for subquestionId, subquestion in question.subquestions %}
<div class="row">
<div class="col-md-4 text-right">
<b>{{subquestion.question}} ({{subquestion.qid}})</b>
</div>
<div class="col-md-8 text-left">
{{subquestion.answervalue}}
</div>
</div>
{% endfor %}
</div>
{% endif %}
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<h2>{{ gT("Survey name (ID):") }} {{aSurveyInfo.surveyls_title}} ({{aSurveyInfo.sid}})</h2>
</div>
</div>

{% for groupid,group in aSurveyInfo.groupArray %}
<div class="row">
<div class="col-xs-12">
Expand All @@ -14,8 +13,17 @@
<div class="row">
<div class="container-fluid col-xs-11 col-md-10 col-xs-offset-1 col-md-offset-2">
{% for questionId,question in group.answerArray %}
{{ include('./subviews/printanswers/printanswers_question.twig') }}
{{ include('./subviews/printanswers/printanswers_question.twig') }}
{% endfor %}
</div>
</div>
{% endfor %}

{% endfor %}








0 comments on commit 3bb8700

Please sign in to comment.