Skip to content

Commit

Permalink
Dev: inbetweenstate rendering of a few questiontypes working by object
Browse files Browse the repository at this point in the history
  • Loading branch information
lacrioque committed Dec 20, 2018
1 parent fb5b670 commit 47fe08b
Show file tree
Hide file tree
Showing 13 changed files with 1,311 additions and 511 deletions.
1 change: 1 addition & 0 deletions application/config/internal.php
Expand Up @@ -105,6 +105,7 @@
'application.helpers.*',
'application.controllers.*',
'application.modules.*',
'application.views.QuestionTypeRenderer.*',
'bootstrap.helpers.*',
'bootstrap.widgets.*',
'bootstrap.behaviors.*',
Expand Down
441 changes: 4 additions & 437 deletions application/helpers/qanda_helper.php

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions application/models/Answer.php
Expand Up @@ -53,12 +53,6 @@ public function primaryKey()
return 'aid';
}


public function defaultScope()
{
return array('order'=>'sortorder');
}

/** @inheritdoc */
public function relations()
{
Expand Down
37 changes: 20 additions & 17 deletions application/models/Question.php
Expand Up @@ -865,10 +865,24 @@ public function getQuestionAttributes()
{
$criteria = new CDbCriteria();
$criteria->addCondition('qid=:qid');
$criteria->addCondition('(language=:language OR language IS NULL)');
$criteria->params = [':qid'=>$this->qid];
$criteria->params = [':language'=>$this->language];
return QuestionAttribute::model()->findAll($criteria);
}

// /**
// * @return QuestionAttribute[]
// */
// public function getQuestionAttribute($sAttribute)
// {
// $criteria = new CDbCriteria();
// $criteria->addCondition('qid=:qid');
// $criteria->addCondition('attribute=:attribute');
// $criteria->params = [':qid'=>$this->qid, ':attribute' => $sAttribute];
// return QuestionAttribute::model()->find($criteria);
// }

/**
* @return null|QuestionType
*/
Expand All @@ -895,14 +909,16 @@ public function getAllSubQuestionIds()
return $result;
}

public function getQuestionTypeFolder(){
public function getRenderererObject($aFieldArray){
switch ($this->type) {
case Question::QT_1_ARRAY_MULTISCALE: return 'arrays/dualscale';
case Question::QT_5_POINT_CHOICE: return '5pointchoice';
case Question::QT_X_BOILERPLATE_QUESTION: return new RenderBoilerplate($aFieldArray);
case Question::QT_5_POINT_CHOICE: return new RenderFivePointChoice($aFieldArray);
case Question::QT_ASTERISK_EQUATION: return new RenderEquation($aFieldArray);
case Question::QT_D_DATE: return new RenderDate($aFieldArray);
case Question::QT_1_ARRAY_MULTISCALE: return new RenderArrayDual($aFieldArray);
case Question::QT_A_ARRAY_5_CHOICE_QUESTIONS: return 'arrays/5point';
case Question::QT_B_ARRAY_10_CHOICE_QUESTIONS: return 'arrays/10point';
case Question::QT_C_ARRAY_YES_UNCERTAIN_NO: return 'arrays/yesnouncertain';
case Question::QT_D_DATE: return 'date';
case Question::QT_E_ARRAY_OF_INC_SAME_DEC_QUESTIONS: return 'arrays/increasesamedecrease';
case Question::QT_F_ARRAY_FLEXIBLE_ROW: return 'arrays/multiflexi';
case Question::QT_G_GENDER_DROPDOWN: return 'gender';
Expand All @@ -919,19 +935,16 @@ public function getQuestionTypeFolder(){
case Question::QT_S_SHORT_FREE_TEXT: return 'shortfreetext';
case Question::QT_T_LONG_FREE_TEXT: return 'longfreetext';
case Question::QT_U_HUGE_FREE_TEXT: return 'longfreetext';
case Question::QT_X_BOILERPLATE_QUESTION: return 'boilerplate';
case Question::QT_Y_YES_NO_RADIO: return 'yesno';
case Question::QT_Z_LIST_RADIO_FLEXIBLE: return 'listradioflexible';
case Question::QT_EXCLAMATION_LIST_DROPDOWN: return 'list_dropdown';
case Question::QT_COLON_ARRAY_MULTI_FLEX_NUMBERS: return 'arrays/texts';
case Question::QT_SEMICOLON_ARRAY_MULTI_FLEX_TEXT: return 'arrays/texts';
case Question::QT_VERTICAL_FILE_UPLOAD: return 'file_upload';
case Question::QT_ASTERISK_EQUATION: return 'equation';
default: return 'generic_question'; // fallback
};
}


/**
* @param array $data
* @return boolean|null
Expand All @@ -948,14 +961,4 @@ public function insertRecords($data)
Yii::log(\CVarDumper::dumpAsString($oRecord->getErrors()), 'warning', 'application.models.Question.insertRecords');
}


public function getCurrentView(){
$baseView = '/survey/questions/answer/'. $this->questionTypeFolder;

}

public function getCurrentViewData(){

}

}
12 changes: 6 additions & 6 deletions application/models/QuestionAttribute.php
Expand Up @@ -64,12 +64,12 @@ public function relations()
);
}

/**
* This defaultScope indexes the ActiveRecords given back by attribute name
* Important: This does not work if you want to retrieve records for more than one question at a time.
* In that case disable the defaultScope by using MyModel::model()->resetScope()->findAll();
* @return array Scope that indexes the records by their attribute bane
*/
/**
* This defaultScope indexes the ActiveRecords given back by attribute name
* Important: This does not work if you want to retrieve records for more than one question at a time.
* In that case disable the defaultScope by using MyModel::model()->resetScope()->findAll();
* @return array Scope that indexes the records by their attribute bane
*/
public function defaultScope()
{
return array('index'=>'attribute');
Expand Down

0 comments on commit 47fe08b

Please sign in to comment.