Ejemplo n.º 1
0
 function &fetchResultItem($question, $result_id, $metadata = false)
 {
     $result = eZPersistentObject::fetchObject(eZSurveyQuestionResult::definition(), 'text', array('question_id' => $question->attribute('id'), 'result_id' => $result_id), false);
     $returnArray = array('result' => $result['text']);
     return $returnArray;
 }
Ejemplo n.º 2
0
 function &fetchResultItem($question, $result_id, $metadata = false)
 {
     $labelArray = array();
     foreach ($question->Options as $option) {
         $labelArray[$option['value']] = $option['label'];
     }
     $result = eZPersistentObject::fetchObjectList(eZSurveyQuestionResult::definition(), 'text', array('question_id' => $question->attribute('id'), 'result_id' => $result_id), array(), null, false);
     $extraResult = eZPersistentObject::fetchObjectList(eZSurveyQuestionMetaData::definition(), 'text', array('question_id' => $question->attribute('id'), 'result_id' => $result_id), array(), null, false);
     $resultArray = array();
     foreach (array_keys($result) as $key) {
         $label = '';
         $extraValue = '';
         if (isset($result[$key]['text']) and isset($labelArray[$result[$key]['text']])) {
             $label = $labelArray[$result[$key]['text']];
         }
         if (isset($extraResult[0]['name']) and $extraResult[0]['name'] == $result[$key]['text']) {
             $extraValue = $extraResult[0]['value'];
             $label = $question->ExtraInfo['extra_info']['label'];
         }
         $resultArray[] = array('value' => $result[$key]['text'], 'label' => $label, 'extra_value' => $extraValue);
     }
     $result = array('result' => $resultArray);
     return $result;
 }
Ejemplo n.º 3
0
 function remove($conditions = null, $extraConditions = null)
 {
     eZPersistentObject::removeObject(eZSurveyQuestionResult::definition(), array('id' => $this->ID));
 }
Ejemplo n.º 4
0
 function &fetchQuestionResultList($asObject = false, $persistent = true)
 {
     $rows = eZPersistentObject::fetchObjectList(eZSurveyQuestionResult::definition(), null, array('result_id' => $this->attribute('id')), false, null, $asObject);
     if ($asObject) {
         return $rows;
     }
     $extraResultArray = array();
     if ($persistent === true) {
         $extraResults = eZPersistentObject::fetchObjectList(eZSurveyQuestionMetaData::definition(), null, array('result_id' => $this->attribute('id')), false, null, $asObject);
         if (count($extraResults) > 0) {
             foreach ($extraResults as $extraResult) {
                 $extraResultArray[$extraResult['question_id']] = $extraResult;
             }
         }
     }
     $resultRows = array();
     foreach ($rows as $row) {
         if (!isset($resultRows[(string) $row['question_id']])) {
             $resultRows[(string) $row['question_id']] = array();
         }
         $resultRows[(string) $row['question_id']]['content'][$row['text']] = $row['text'];
         $resultRows[(string) $row['question_id']]['text'] = $row['text'];
         if (isset($extraResultArray[(string) $row['question_id']])) {
             $resultRows[(string) $row['question_id']]['extra_info'] = $extraResultArray[(string) $row['question_id']];
         }
     }
     return $resultRows;
 }
Ejemplo n.º 5
0
 function storeResult($resultID, $params)
 {
     $http = eZHTTPTool::instance();
     $httpAnswer = $this->answer($params);
     if (!is_array($httpAnswer)) {
         if ($httpAnswer == '') {
             $httpAnswer = array();
         } else {
             $httpAnswer = array($httpAnswer);
         }
     }
     $questionResultArray = eZSurveyQuestionResult::instance($resultID, $this->ID, count($httpAnswer));
     $questionCount = 0;
     foreach ($httpAnswer as $answer) {
         $questionResultArray[$questionCount]->setAttribute('text', $answer);
         $questionResultArray[$questionCount]->store();
         ++$questionCount;
     }
 }