示例#1
0
<?php

require_once "../include/includes.php";
setContentType("text", "plain");
session_start();
$db = new SqlManager($fpConfig);
$postJson = getJsonPostData();
$action = reqParam("action");
if (!$action) {
    $action = @$postJson["action"];
}
$username = fpCurrentUsername();
$response = array();
switch ($action) {
    case "saveForm":
        //save form: insert,update,delete user_answers for this user
        $user_answers = $postJson["formData"];
        $result = saveAnswers($db, $username, $user_answers);
        $response = array("answers" => count($user_answers), "result" => $result);
        break;
    case "form_questions":
    default:
        $response["questions"] = getFormQuestions($db, $_REQUEST);
        if ($username) {
            $response["user_answers"] = $db->selectWhere(array("table" => "user_answer", "username" => $username));
        }
}
$db->disconnect();
$response["queries"] = $db->getLog();
$response["time"] = getTimer(true);
echo jsValue($response);
示例#2
0
<?php

$username = "";
$password = "";
$address = "localhost";
$database = "questionnaire_wearable";
header('Content-Type: text/html; charset=utf-8');
if (isset($_GET['function']) || isset($_POST['function'])) {
    if (isset($_POST['function']) && $_POST['function'] == "save") {
        saveAnswers();
    }
}
class Answer
{
    public $id = "";
    public $participant_id = "";
    public $participant_name = "";
    public $questionnarie_name = "";
    public $questionnarie_stage = "";
    public $section_id = "";
    public $question_id = "";
    public $question = "";
    public $answer_type = "";
    public $answer_value = "";
}
function saveAnswers()
{
    global $username;
    global $password;
    global $address;
    global $database;
示例#3
0
     $menu->addSubElement($mod, $lang->get('poll_state_change'), 'state_change', array('pollid' => $pollid));
 }
 $breadcrumbs->addElement($poll['title'], makeURL($mod, array('pollid' => $poll['detailedpollid'])));
 if (isset($_POST['send'])) {
     $sendOk = true;
     foreach ($_POST['values'] as $value) {
         if ($value == '') {
             $sendOk = false;
             break;
         }
     }
     if ($sendOk) {
         if (hasVoted($pollid, $login->currentUserId())) {
             $sendResult = updateAnswers($pollid, $login->currentUserId(), $_POST['values']);
         } else {
             $sendResult = saveAnswers($pollid, $login->currentUserId(), $_POST['values']);
         }
         if ($sendResult > 0) {
             $notify->add($lang->get('detailedpoll'), $lang->get('notify_send_successfull'));
             redirect(makeUrl('detailedpoll', array()));
         } else {
             $notify->add($lang->get('detailedpoll'), $lang->get('notify_send_unsuccessfull'));
         }
     } else {
         $notify->add($lang->get('detailedpoll'), $lang->get('notify_send_unsuccessfull_fields_missing'));
         $smarty->assign('values', $_POST['values']);
     }
 }
 if (hasVoted($pollid, $login->currentUserId())) {
     $smarty->assign('values', getMyAnswers($pollid, $login->currentUserId()));
 }