Exemplo n.º 1
0
 private function receiveText($object)
 {
     $keyword = trim($object->Content);
     if ($keyword == "答题" || preg_match("/^[A-Fa-f]\$/", $keyword)) {
         include "question.php";
         $content = getQuestionInfo($object->FromUserName, $keyword == "答题" ? $keyword : strtoupper(trim($object->Content)));
     }
     $result = $this->transmitText($object, $content);
     return $result;
 }
Exemplo n.º 2
0
function giveMeRawDataFromFieldNames($surveyid, $gid, $qid, $fieldlimiters = array(), $output = "full")
{
    //Builds output data for question $surveyid$gid$qid, limiting with $fieldlimiters array
    $questionfields = buildQuestionFields($surveyid, $qid);
    $sql = buildSqlFromFieldnamesArray($fieldlimiters);
    $tablename = "survey_" . $surveyid;
    $fieldmap = createFieldMap($surveyid, "full");
    //echo "<pre>"; print_r($answers); echo "</pre>";
    list($questioninfo, $results) = returnQuestionResults($surveyid, $questionfields, $sql);
    //echo "<pre>"; print_r($questioninfo); echo "</pre>";
    if (count($results) < 1) {
        return array();
    }
    foreach ($questioninfo as $qi) {
        $questiontype = $qi['type'];
    }
    //	echo "[$questiontype]<br />";
    if ($output == "full") {
        GetBaseLanguageFromSurveyID($surveyid);
        //echo "<pre>"; print_r($answers); echo "</pre>";
        switch ($questiontype) {
            case "L":
            case "!":
            case "O":
            case "D":
            case "E":
            case "M":
            case "P":
            case "C":
            case "B":
            case "A":
            case "F":
            case "H":
            case "1":
                $answers = getAnswersSingle($surveyid, $gid, $qid);
                break;
            case "Y":
                $answers[] = array("code" => "Y", "answer" => $clang->gT("Yes"));
                $answers[] = array("code" => "N", "answer" => $clang->gT("No"));
                break;
            case "G":
                $answers[] = array("code" => "M", "answer" => $clang->gT("Male"));
                $answers[] = array("code" => "F", "answer" => $clang->gT("Female"));
                break;
        }
        // switch
        $answers[] = array("code" => "", "answer" => $clang->gT("No answer"));
        $answers[] = array("code" => "-oth-", "answer" => $clang->gT("Other"));
        switch ($questiontype) {
            case "A":
                for ($i = 1; $i <= 5; $i++) {
                    $values[] = array("code" => $i, "answer" => $i);
                }
                break;
            case "B":
                for ($i = 1; $i <= 10; $i++) {
                    $values[] = array("code" => $i, "answer" => $i);
                }
                break;
            case "E":
                $values[] = array("code" => "I", "answer" => $clang->gT("Increase"));
                $values[] = array("code" => "S", "answer" => $clang->gT("Same"));
                $values[] = array("code" => "D", "answer" => $clang->gT("Decrease"));
                break;
            case "C":
            case "M":
            case "P":
                $values[] = array("code" => "Y", "answer" => $clang->gT("Yes"));
                $values[] = array("code" => "U", "answer" => $clang->gT("Uncertain"));
                $values[] = array("code" => "N", "answer" => $clang->gT("No"));
                break;
            case "F":
            case "H":
                $thisquestion = getQuestionInfo($qid);
                $values = getLabelSet($thisquestion['lid']);
                break;
        }
        $values[] = array("code" => "", "answer" => $clang->gT("No answer"));
        switch ($questiontype) {
            case "L":
            case "!":
            case "O":
            case "Y":
            case "G":
            case "S":
            case "T":
            case "H":
            case "N":
            case "5":
            case "D":
                //The first key needs to be expanded
                $firstkey = array_keys($results[0]);
                $firstkey = $firstkey[0];
                $questions = arraySearchByKey($firstkey, $fieldmap, "fieldname", 1);
                //echo $firstkey;
                $i = 0;
                foreach ($results as $result) {
                    $results[$i][$firstkey] = array($questions['question'], arraySubstitute($result[$firstkey], $answers));
                    $i++;
                }
                break;
            case "A":
            case "B":
            case "C":
            case "E":
            case "F":
            case "H":
            case "M":
            case "P":
            case "Q":
            case "1":
                $i = 0;
                foreach ($results as $result) {
                    foreach ($result as $key => $val) {
                        $questions = arraySearchByKey($key, $fieldmap, "fieldname", 1);
                        if (substr($key, -7, 7) != "comment") {
                            $code = substr($key, strlen($surveyid . "X" . $gid . "X" . $qid), strlen($key) - strlen($surveyid . "X" . $gid . "X" . $qid));
                            //echo $code;
                            $results[$i][$key] = array($questions['question'], arraySubstitute($val, $values));
                        }
                    }
                    $i++;
                }
                break;
        }
        // switch
    }
    return $results;
}