public function showQuestion($data, $elemId = '', $elemSeq = null, $type = array(), $langId = '') { $html = ''; $htmlVal = ''; $htmlOpt = ''; $params = array(); $oValidation = new FormQuestionValidationTypeObject(); $oOptionsList = new FormResponseOptionObject(); // If loading an existing element (page loading) if (count($data) > 0) { // To simplify when settings registred values $question = $data[0]; //Load data for validation $valOpt = $this->_getValidator($question['FQ_ID'], $langId); $htmlVal = $valOpt['htmlVal']; $htmlOpt = $valOpt['htmlOpt']; // Load data for response options $this->_htmlList = $oOptionsList->getOptionsList($question['FQ_ID'], $langId); // set values from db to build the question $this->_formElemId = "element_" . $question['FQ_ElementID']; $this->_qTextId = "question_" . $question['FQ_ID']; $this->_qValidId = "questionValidation_" . $question['FQ_ID']; $this->_title = $question['FQTI_Title']; $this->_descr = $question['FQTI_Description']; $this->_icon = $this->_baseUrl . $question['FQT_ImageLink']; $this->_htmlVal = $htmlVal; $this->_htmlOpt = $htmlOpt; $this->_elemSeq = $elemSeq; $this->_label = $question['FQI_Title']; $this->_checked = ''; // render the question $html = $this->_render(); } else { $db = Zend_Registry::get('db'); $tableElem = new FormElement(); $tableQst = new FormQuestion(); // Set values to build the new question // Defined default values $this->_title = $type['FQTI_Title']; $this->_descr = $type['FQTI_Description']; $this->_icon = $this->_baseUrl . $type['FQT_ImageLink']; $this->_formElemId = "element_" . $this->_currentElmId; $this->_qTextId = "question_" . $this->_currentQstId; $this->_qValidId = "questionValidation_" . $this->_currentQstId; // Set the validation type for this type of question $this->_htmlVal = $oValidation->getValidationType(1, $langId); // Set the option for this question type // $this->_htmlOpt = $oValidation->getValidationType(2, $langId); // $this->_htmlOpt .= $oValidation->getValidationType(3, $langId); // Set the list to create options $this->_htmlList = $oOptionsList->selectValuesList(); // render the new question $html = $this->_render(); } return $html; }
/** * Get the validators on page loading * * @param int $questionId * @param int $langId * * @return array */ protected function _getValidator($questionId, $langId = 1) { $htmlVal = ''; $htmlOpt = ''; $data = array(); $oValidation = new FormQuestionValidationTypeObject(); $oValidator = new FormQuestionValidationObject(); //List of validators for the question. $validators = $oValidator->getValidators($questionId); foreach ($validators as $validator) { if ($validator['FQVT_Category'] == "VAL") { $htmlVal .= $oValidation->getValidationType($validator['FQV_TypeID'], $langId, $validator['FQV_Value']); } else { $htmlOpt .= $oValidation->getValidationType($validator['FQV_TypeID'], $langId, $validator['FQV_Value']); } } $data['htmlVal'] = $htmlVal; $data['htmlOpt'] = $htmlOpt; return $data; }