예제 #1
0
<?php

require_once 'models/Answer.php';
use RedBean_Facade as R;
$payload = $app->request()->getBody();
$params = array('userid' => 'userid', 'questionid' => 'questionid', 'answer' => 'answer');
$payload = array_intersect_key($payload, $params);
if (empty($payload['questionid'])) {
    throw new \Exception('questionid is required!', 412);
}
$quetion = R::findOne('question', '`id` = ?', array($payload['questionid']));
if (!$quetion) {
    throw new \Exception('Question not found', 404);
}
$answer = new Answer($payload, $quetion);
$answer->validateAnswer();
R::exec('INSERT INTO `answer` (`userid`, `questionid`, `answer`) VALUES (:userid, :questionid, :answer)', array(':userid' => $answer->getValue('userid'), ':questionid' => $answer->getValue('questionid'), ':answer' => $answer->getValue('answer')));
$app->result = $answer->getValues();
예제 #2
0
foreach ($survey_questions as $survey_question_id) {
    $question = new Question();
    $question->get_from_db($survey_question_id);
    $question_title = $question->getTitle();
    $question_answers = $question->get_answers();
    // Add question title
    $objPHPExcel->setActiveSheetIndex($sheetId)->mergeCells('A1:N1');
    $objPHPExcel->setActiveSheetIndex($sheetId)->setCellValue('A1', $question_title);
    // list answers
    $columnId = 2;
    $alphabetIteration = 0;
    foreach ($question_answers as $question_answer_id) {
        $answer = new Answer();
        $answer->get_from_db($question_answer_id);
        $cell = divideBy26($columnId) . "2";
        $cell_value = $answer->getValue();
        // Add some data
        $objPHPExcel->setActiveSheetIndex($sheetId)->setCellValue($cell, $cell_value);
        $objPHPExcel->getActiveSheet()->getColumnDimension(divideBy26($columnId))->setWidth(15);
        $objPHPExcel->getActiveSheet()->getStyle($cell)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
        $columnId++;
    }
    // list users by question
    $row_id = 3;
    foreach ($voted_users as $voted_user_id) {
        $user = new User();
        $user->get_from_db($voted_user_id);
        $cell = 'A' . $row_id;
        $user_number = $row_id - 2;
        $cell_value = 'User' . $user_number;
        // Add some data
예제 #3
0
                    $vote_id = 0;
                    $user_vote_by_answer = array();
                    $user_vote_by_answer = get_user_vote_by_answer($user_id, $answer_id);
                    if (!empty($user_vote_by_answer)) {
                        $vote_id = $user_vote_by_answer[0];
                        $vote->get_from_db($vote_id);
                    }
                    ?>
                                            <label for = "formSurvey<?php 
                    print_r($question->getId());
                    ?>
Answer<?php 
                    print_r($answer->getId());
                    ?>
"><?php 
                    print_r($answer->getValue());
                    ?>
                                                <small><?php 
                    print_r($answer->getDescription());
                    ?>
</small>
                                            </label>
                                            <input 
                                                id="formSurvey<?php 
                    print_r($question->getId());
                    ?>
Answer<?php 
                    print_r($answer->getId());
                    ?>
" 
                                                <?php 
예제 #4
0
// Multicell test
$txt = '№';
$pdf->MultiCell(10, '', $txt, 1, 'C', 1, 0, '', '', true);
$txt = 'Отговор';
$pdf->MultiCell(140, '', $txt, 1, 'C', 1, 0, '', '', true);
$txt = 'Тип';
$pdf->MultiCell(30, '', $txt, 1, 'C', 1, 1, '', '', true);
// set color for background
$pdf->SetFillColor(255, 255, 255);
$number_answer = 1;
foreach ($answers as $answer_id) {
    $answer = new Answer();
    $answer->get_from_db($answer_id);
    $txt = $number_answer;
    $pdf->MultiCell(10, '', $txt, 1, 'C', 1, 0, '', '', true);
    $txt = $answer->getValue();
    $pdf->MultiCell(140, '', $txt, 1, 'C', 1, 0, '', '', true);
    $txt = $answer->getType();
    $pdf->MultiCell(30, '', $txt, 1, 'C', 1, 1, '', '', true);
    $number_answer++;
}
$pdf->Ln(5);
// set font
$pdf->SetFont('freeserif', 'B', 14);
$txt = 'Групи';
$pdf->Write(0, $txt, '', 0, 'C', true, 0, false, false, 0);
// set color for background
$pdf->SetFillColor(225, 225, 225);
// set font
$pdf->SetFont('freeserif', '', 12);
// Multicell test