/** *通过题号获取相关信息 * @param int $num题号 * @return string $q_html */ function getOneQuestionPage($num) { if (!$num) { return false; } global $openid; require_once 'question_list_cache.php'; $q_list = getQuestionList(); $count = count($q_list); //总共多少道 if (empty($q_list)) { return false; } $q_info = $q_list[$num - 1]; $q_html = ''; $q_html = <<<EOF \t\t<!DOCTYPE html> <html > <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">\t <link rel="stylesheet" href="./css/jquery.mobile-1.4.3.min.css" /> <link href="css/style.css" rel="stylesheet" type="text/css"> <style type="text/css"> </style> <script src="js/jquery-1.11.1.min.js"></script> <script src="js/jquery.mobile-1.4.3.js"></script> <title>调查问卷</title> </head>\t <body > <div data-role="page" data-dom-cache="true" id="pageQuestion" > <!--<script src="js/validate_q.js" ></script>--> <script type="text/javascript"> //\$(document).ready(function (){ \$(document).on("pageinit","#pageQuestion",function(){ \t//\t其他用户输入选项 \t\$('.qita_tmp').bind('focus', function (){ \t\tvar pre_id = \$(this).attr("pre_id"); \t\$("#"+pre_id).attr("checked","checked").checkboxradio("refresh"); \t \t}).bind('focusout',function (){ \t\tvar pre_id = \$(this).attr("pre_id"); \t\tvar qita_tmp_val = \$(this).val();\t\t\t\t\t\t\t \t\t\$("#"+pre_id).val(qita_tmp_val); \t}) \t \t }) //选项必需填写 function check_form(){ \tvar nameid = \$("#nameid").val();\t \tvar input_type = \$("#input_type").val();\t\t \tif(input_type == "checkbox"){ \t\tnameid = nameid+"[]"; \t\tif(!checkbox_val(nameid)){ \t\t\t\$("#err_msg").html('请给出选择..'); \t\t\treturn false;\t\t\t \t\t} \t}else if(input_type == "radio"){ \t\tif(!check_radio(nameid)){\t\t \t\t\t\$("#err_msg").html('请给出选择..'); \t\t\treturn false;\t\t \t\t} \t} \treturn true; } //获取复选框选中的值 function checkbox_val(name){ var str=document.getElementsByName(name); var objarray=str.length; var chestr=""; for (i=0;i<objarray;i++){ if(str[i].checked == true){ chestr+=str[i].value+","; } } return chestr; } //radio验证 function check_radio(name) { var obj = \$('input:radio[name='+name+']:checked'); if (obj.val()) { return true; } else { return false; } } </script> <div data-role="header"> <h1>调查问卷</h1> </div> <div data-role="content" > <form method="post" action="./index.php" onsubmit="return check_form();" data-ajax="false"> <input type="hidden" value="" name="openid" id="openid"/> <input type="hidden" value="addanswer" name="oprtype" /> <input type="hidden" value="{$q_info['name']}" name="nameid" id="nameid" /> <input type="hidden" value="{$num}" name="num" /> <input type="hidden" value="{$openid}" name="openid" /> <input type="hidden" value="{$q_info['input_type']}" id="input_type" name="input_type"/> <div data-role="fieldcontain"> \t\t\t<legend>{$num}、{$q_info['shuoming']}: </legend> <fieldset data-role="controlgroup"> EOF; $option_html = null; if ($q_info['input_type'] == 'checkbox') { $q_info['name'] = $q_info['name'] . '[]'; } foreach ($q_info['options'] as $o_info) { if ($o_info['value'] == '其他') { $option_html .= <<<EOF \t\t\t<label for="oid_{$o_info['id']}"> \t <em></em>其他: </label> \t\t\t <input type='{$q_info['input_type']}' name='{$q_info['name']}' id="oid_{$o_info['id']}" value=""> \t <input type="text" class="qita_tmp" pre_id="oid_{$o_info['id']}" placeholder="请输入..."> \t EOF; } else { $option_html .= <<<EOF \t\t\t<label for="oid_{$o_info['id']}">{$o_info['value']}</label> <input type='{$q_info['input_type']}' name='{$q_info['name']}' id="oid_{$o_info['id']}" value="{$o_info['value']}"> EOF; } } $done_num = $num - 1; $left_num = $count - $done_num; $option_html .= <<<EOF \t \t\t\t</fieldset> \t\t\t</div> \t\t\t<p class="pic_box3" style="color:red;" id="err_msg"> </p><br/> <p class="pic_box3" >您已答了<span style="color:red;">{$done_num}</span>道题,还剩<span style="color:red;">{$left_num}</span>道,加油加油:)</p> <input type="submit" data-inline="true" style="align:center;" value="下一步"> \t</form> \t</div> <div data-role="footer"> </div> </div> </body> </html> EOF; return $q_html . $option_html; }
case "update-question": if (!updateQuestion($v, $r['text'], $r['display'], $r['answers'], $r['search'])) { echo 'fehler beim bearbeiten der frage'; } else { echo "änderungen wurden gespeichert"; } echoQuestionList(getQuestionList()); break; case "delete-question": if ($r['accept'] && $r['submit'] == "ja") { deleteQuestion($v); echo "frage wurde gelöscht"; echoQuestionList(getQuestionList()); } else { if ($v && $r['submit'] == "nein") { echoQuestionList(getQuestionList()); } else { $question = getQuestionByID($v); $id = "<ins style='background-color:#FA8D18'>" . $v . "</ins>"; $frage = "<ins style='background-color:#FA8D18'>" . $question['question'] . "</ins>"; areyousure("?delete-question=" . $v . "&accept=true", "Frage (" . $frage . ") mit der Id " . $id . " löschen?", "Achtung! Diese Frage wird gelöscht. Ist diese Frage Teil eines Fragebogens kann dies zu Systemfehlern führen!"); } } break; break; case "choose-form": chooseFormForm(); break; case "choose-form2": chooseFormForm2(); break;
} } } } } } } } } } } } } } } else { $questions = getQuestionList(); include 'tpl/main.php'; } function getOneUser($username, $password = null) { $db = new DB(); if ($password) { $userinfo = $db->selectBySql("select * from member where username=? and password=? ", array($username, $password)); } else { $userinfo = $db->selectBySql("select * from member where username=? ", array($username)); } if ($userinfo) { $qeston = $db->selectBySql("select count(*) as total from question where authorid=? ", array($userinfo[0]['id'])); $userinfo[0]['qcount'] = !empty($qeston[0]['total']) ? $qeston[0]['total'] : 0; $aqeston = $db->selectBySql("select count(*) as total from answer where authorid=? ", array($userinfo[0]['id'])); $userinfo[0]['acount'] = !empty($aqeston[0]['total']) ? $aqeston[0]['total'] : 0;