コード例 #1
0
 /**
  * Wyświetlenie ankiety do wypełnienia
  */
 public function pokazAction()
 {
     $pool = new Ankiety();
     $question = new Pytania();
     $answer = new Odpowiedzi();
     $variants = new WariantyOdpowiedzi();
     $filledPool = new WypelnioneAnkiety();
     $db = $question->getAdapter();
     unset($_POST['send']);
     if (strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
         $data = array('id_ankieta' => $this->_getParam('ankieta'));
         $idFilledPool = $filledPool->insert($data);
         foreach ($_POST as $questionId => $answerT) {
             if (is_array($answerT)) {
                 foreach ($answerT as $answerId => $value) {
                     $data = array('id_wypelniona_ankieta' => $idFilledPool, 'id_pytanie' => $questionId, 'odpowiedz' => $answerId);
                     $id = $answer->insert($data);
                 }
             } else {
                 $data = array('id_wypelniona_ankieta' => $idFilledPool, 'id_pytanie' => $questionId, 'odpowiedz' => $answerT);
                 $id = $answer->insert($data);
             }
             echo '<br>';
         }
     }
     $this->view->pool = $pool->find($this->_getParam('ankieta'));
     $temp = $question->findAllWithAnkietaId($this->_getParam('ankieta'));
     $var = array();
     foreach ($temp as $row) {
         $where = $db->quoteInto('id_pytanie = ?', $row->idPytanie);
         $order = 'kolejnosc';
         $var[$row->idPytanie] = $variants->fetchAll($where, $order);
     }
     $this->view->questions = $temp;
     $this->view->variants = $var;
     $this->view->message = 'Dziękujemy za wypełnienie ankiety';
     $this->display();
 }
コード例 #2
0
 /**
  * Ustala nową kolejność wariantów odpowiedzi
  */
 public function ajaxswapanswerAction()
 {
     $post = new Zend_Filter_Input($_POST);
     $obj = new Hamster_JQuery_Sortables();
     $obj->setHash($post->getRaw('hash'));
     $list = $obj->getSortArray();
     $variants = new WariantyOdpowiedzi();
     $ranking = 1;
     if (isset($list)) {
         foreach ($list as $answer_id) {
             $row = $variants->find($answer_id);
             $row->kolejnosc = $ranking;
             $row->save();
             $ranking++;
         }
     }
 }