当前位置: 首页>>代码示例>>PHP>>正文


PHP getQuestionAttributeValues函数代码示例

本文整理汇总了PHP中getQuestionAttributeValues函数的典型用法代码示例。如果您正苦于以下问题:PHP getQuestionAttributeValues函数的具体用法?PHP getQuestionAttributeValues怎么用?PHP getQuestionAttributeValues使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了getQuestionAttributeValues函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: view

 /**
  * View a single response in detail
  *
  * @param mixed $iSurveyID
  * @param mixed $iId
  * @param mixed $sBrowseLang
  */
 public function view($iSurveyID, $iId, $sBrowseLang = '')
 {
     if (Permission::model()->hasSurveyPermission($iSurveyID, 'responses', 'read')) {
         $aData = $this->_getData(array('iId' => $iId, 'iSurveyId' => $iSurveyID, 'browselang' => $sBrowseLang));
         $sBrowseLanguage = $aData['language'];
         extract($aData);
         $aViewUrls = array();
         $fieldmap = createFieldMap($iSurveyID, 'full', false, false, $aData['language']);
         $bHaveToken = $aData['surveyinfo']['anonymized'] == "N" && tableExists('tokens_' . $iSurveyID);
         // Boolean : show (or not) the token
         if (!Permission::model()->hasSurveyPermission($iSurveyID, 'tokens', 'read')) {
             unset($fieldmap['token']);
             $bHaveToken = false;
         }
         //add token to top of list if survey is not private
         if ($bHaveToken) {
             $fnames[] = array("token", gT("Token ID"), 'code' => 'token');
             $fnames[] = array("firstname", gT("First name"), 'code' => 'firstname');
             // or token:firstname ?
             $fnames[] = array("lastname", gT("Last name"), 'code' => 'lastname');
             $fnames[] = array("email", gT("Email"), 'code' => 'email');
         }
         $fnames[] = array("submitdate", gT("Submission date"), gT("Completed"), "0", 'D', 'code' => 'submitdate');
         $fnames[] = array("completed", gT("Completed"), "0");
         foreach ($fieldmap as $field) {
             if ($field['fieldname'] == 'lastpage' || $field['fieldname'] == 'submitdate') {
                 continue;
             }
             if ($field['type'] == 'interview_time') {
                 continue;
             }
             if ($field['type'] == 'page_time') {
                 continue;
             }
             if ($field['type'] == 'answer_time') {
                 continue;
             }
             //$question = $field['question'];
             $question = viewHelper::getFieldText($field);
             if ($field['type'] != "|") {
                 $fnames[] = array($field['fieldname'], viewHelper::getFieldText($field), 'code' => viewHelper::getFieldCode($field, array('LEMcompat' => true)));
             } elseif ($field['aid'] !== 'filecount') {
                 $qidattributes = getQuestionAttributeValues($field['qid']);
                 for ($i = 0; $i < $qidattributes['max_num_of_files']; $i++) {
                     $filenum = sprintf(gT("File %s"), $i + 1);
                     if ($qidattributes['show_title'] == 1) {
                         $fnames[] = array($field['fieldname'], "{$filenum} - {$question} (" . gT('Title') . ")", 'code' => viewHelper::getFieldCode($field) . '(title)', "type" => "|", "metadata" => "title", "index" => $i);
                     }
                     if ($qidattributes['show_comment'] == 1) {
                         $fnames[] = array($field['fieldname'], "{$filenum} - {$question} (" . gT('Comment') . ")", 'code' => viewHelper::getFieldCode($field) . '(comment)', "type" => "|", "metadata" => "comment", "index" => $i);
                     }
                     $fnames[] = array($field['fieldname'], "{$filenum} - {$question} (" . gT('File name') . ")", 'code' => viewHelper::getFieldCode($field) . '(name)', "type" => "|", "metadata" => "name", "index" => $i);
                     $fnames[] = array($field['fieldname'], "{$filenum} - {$question} (" . gT('File size') . ")", 'code' => viewHelper::getFieldCode($field) . '(size)', "type" => "|", "metadata" => "size", "index" => $i);
                     //$fnames[] = array($field['fieldname'], "File ".($i+1)." - ".$field['question']." (extension)", "type"=>"|", "metadata"=>"ext",     "index"=>$i);
                 }
             } else {
                 $fnames[] = array($field['fieldname'], gT("File count"));
             }
         }
         $nfncount = count($fnames) - 1;
         if ($iId < 1) {
             $iId = 1;
         }
         $exist = SurveyDynamic::model($iSurveyID)->exist($iId);
         $next = SurveyDynamic::model($iSurveyID)->next($iId, true);
         $previous = SurveyDynamic::model($iSurveyID)->previous($iId, true);
         $aData['exist'] = $exist;
         $aData['next'] = $next;
         $aData['previous'] = $previous;
         $aData['id'] = $iId;
         $aViewUrls[] = 'browseidheader_view';
         if ($exist) {
             $oPurifier = new CHtmlPurifier();
             //SHOW INDIVIDUAL RECORD
             $oCriteria = new CDbCriteria();
             if ($bHaveToken) {
                 $oCriteria = SurveyDynamic::model($iSurveyID)->addTokenCriteria($oCriteria);
             }
             $oCriteria->addCondition("id = {$iId}");
             $iIdresult = SurveyDynamic::model($iSurveyID)->findAllAsArray($oCriteria);
             foreach ($iIdresult as $iIdrow) {
                 $iId = $iIdrow['id'];
                 $rlanguage = $iIdrow['startlanguage'];
             }
             $aData['bHasFile'] = false;
             if (isset($rlanguage)) {
                 $aData['rlanguage'] = $rlanguage;
             }
             foreach ($iIdresult as $iIdrow) {
                 $highlight = false;
                 for ($i = 0; $i < $nfncount + 1; $i++) {
                     if ($fnames[$i][0] != 'completed' && is_null($iIdrow[$fnames[$i][0]])) {
                         continue;
//.........这里部分代码省略.........
开发者ID:mfavetti,项目名称:LimeSurvey,代码行数:101,代码来源:responses.php

示例2: displayResults


//.........这里部分代码省略.........
             $this->pdf->headTable($headPDF2, $tablePDF2);
         }
     }
     if ($outputType == 'xls' && (isset($headXLS) || isset($tableXLS))) {
         if (isset($headXLS)) {
             $this->xlsRow++;
             $this->xlsRow++;
             foreach ($headXLS as $aRow) {
                 $this->xlsRow++;
                 $iColumn = 0;
                 foreach ($aRow as $sValue) {
                     $this->sheet->write($this->xlsRow, $iColumn, $sValue, $this->formatBold);
                     $iColumn++;
                 }
             }
         }
         if (isset($tableXLS)) {
             foreach ($tableXLS as $aRow) {
                 $this->xlsRow++;
                 $iColumn = 0;
                 foreach ($aRow as $sValue) {
                     $this->sheet->write($this->xlsRow, $iColumn, $sValue);
                     $iColumn++;
                 }
             }
         }
     }
     if ($outputType == 'html') {
         $statisticsoutput .= "<tr><td colspan='4' style=\"text-align:center\" id='statzone_{$rt}'>";
     }
     //-------------------------- PCHART OUTPUT ----------------------------
     list($qsid, $qgid, $qqid) = explode("X", $rt, 3);
     $qsid = $surveyid;
     $aattr = getQuestionAttributeValues($outputs['parentqid'], substr($rt, 0, 1));
     //PCHART has to be enabled and we need some data
     if ($usegraph == 1) {
         $bShowGraph = $aattr["statistics_showgraph"] == "1";
         $bAllowPieChart = $outputs['qtype'] != "M" && $outputs['qtype'] != "P";
         $bAllowMap = isset($aattr["location_mapservice"]) && $aattr["location_mapservice"] == "1";
         $bShowMap = $bAllowMap && $aattr["statistics_showmap"] == "1";
         $bShowPieChart = $bAllowPieChart && (isset($aattr["statistics_graphtype"]) && $aattr["statistics_graphtype"] == "1");
         $astatdata[$rt] = array('id' => $rt, 'sg' => $bShowGraph, 'ap' => $bAllowPieChart, 'am' => $bAllowMap, 'sm' => $bShowMap, 'sp' => $bShowPieChart);
         $stats = Yii::app()->session['stats'];
         $stats[$rt] = array('lbl' => $lbl, 'gdata' => $gdata, 'grawdata' => $grawdata);
         Yii::app()->session['stats'] = $stats;
         if ($bShowGraph == true) {
             $cachefilename = createChart($qqid, $qsid, $bShowPieChart, $lbl, $gdata, $grawdata, $MyCache, $sLanguage, $outputs['qtype']);
             if ($cachefilename) {
                 //introduce new counter
                 if (!isset($ci)) {
                     $ci = 0;
                 }
                 //increase counter, start value -> 1
                 $ci++;
                 switch ($outputType) {
                     case 'xls':
                         /**
                          * No Image for Excel...
                          */
                         break;
                     case 'pdf':
                         $this->pdf->AddPage('P', 'A4');
                         $this->pdf->titleintopdf($pdfTitle, $titleDesc);
                         $this->pdf->Image($tempdir . "/" . $cachefilename, 0, 70, 180, 0, '', Yii::app()->getController()->createUrl("admin/survey/sa/view/surveyid/" . $surveyid), 'B', true, 150, 'C', false, false, 0, true);
                         break;
                     case 'html':
开发者ID:jgianpiere,项目名称:lime-survey,代码行数:67,代码来源:statistics_helper.php

示例3: do_array_dual

function do_array_dual($ia)
{
    global $thissurvey;
    $aLastMoveResult = LimeExpressionManager::GetLastMoveResult();
    $aMandatoryViolationSubQ = $aLastMoveResult['mandViolation'] && $ia[6] == 'Y' ? explode("|", $aLastMoveResult['unansweredSQs']) : array();
    $repeatheadings = Yii::app()->getConfig("repeatheadings");
    $minrepeatheadings = Yii::app()->getConfig("minrepeatheadings");
    $extraclass = "";
    $answertypeclass = "";
    // Maybe not
    $caption = "";
    // Just leave empty, are replaced after
    $inputnames = array();
    $labelans1 = array();
    $labelans = array();
    $aQuestionAttributes = getQuestionAttributeValues($ia[0]);
    if ($aQuestionAttributes['random_order'] == 1) {
        $ansquery = "SELECT * FROM {{questions}} WHERE parent_qid={$ia['0']} AND language='" . $_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang'] . "' and scale_id=0 ORDER BY " . dbRandom();
    } else {
        $ansquery = "SELECT * FROM {{questions}} WHERE parent_qid={$ia['0']} AND language='" . $_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang'] . "' and scale_id=0 ORDER BY question_order";
    }
    $ansresult = dbExecuteAssoc($ansquery);
    //Checked
    $aSubQuestions = $ansresult->readAll();
    $anscount = count($aSubQuestions);
    $lquery = "SELECT * FROM {{answers}} WHERE scale_id=0 AND qid={$ia[0]} AND language='" . $_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang'] . "' ORDER BY sortorder, code";
    $lresult = dbExecuteAssoc($lquery);
    //Checked
    $aAnswersScale0 = $lresult->readAll();
    $lquery1 = "SELECT * FROM {{answers}} WHERE scale_id=1 AND qid={$ia[0]} AND language='" . $_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang'] . "' ORDER BY sortorder, code";
    $lresult1 = dbExecuteAssoc($lquery1);
    //Checked
    $aAnswersScale1 = $lresult1->readAll();
    if ($aQuestionAttributes['use_dropdown'] == 1) {
        $useDropdownLayout = true;
        $extraclass .= " dropdown-list";
        $answertypeclass .= " dropdown";
        $doDualScaleFunction = "doDualScaleDropDown";
        // javascript funtion to lauch at end of answers
        $caption = gT("An array with sub-question on each line, with 2 answers to provide on each line. You have to select the answer.");
    } else {
        $useDropdownLayout = false;
        $extraclass .= " radio-list";
        $answertypeclass .= " radio";
        $doDualScaleFunction = "doDualScaleRadio";
        $caption = gT("An array with sub-question on each line, with 2 answers to provide on each line. The answers are contained in the table header. ");
    }
    if (ctype_digit(trim($aQuestionAttributes['repeat_headings'])) && trim($aQuestionAttributes['repeat_headings'] != "")) {
        $repeatheadings = intval($aQuestionAttributes['repeat_headings']);
        $minrepeatheadings = 0;
    }
    if (trim($aQuestionAttributes['dualscale_headerA'][$_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang']]) != '') {
        $leftheader = $aQuestionAttributes['dualscale_headerA'][$_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang']];
    } else {
        $leftheader = '';
    }
    if (trim($aQuestionAttributes['dualscale_headerB'][$_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang']]) != '') {
        $rightheader = $aQuestionAttributes['dualscale_headerB'][$_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang']];
    } else {
        $rightheader = '';
    }
    if (trim($aQuestionAttributes['answer_width']) != '') {
        $answerwidth = $aQuestionAttributes['answer_width'];
    } else {
        $answerwidth = 20;
    }
    // Find if we have rigth and center text
    // TODO move "|" to attribute
    $sQuery = "SELECT count(question) FROM {{questions}} WHERE parent_qid=" . $ia[0] . " and scale_id=0 AND question like '%|%'";
    $rigthCount = Yii::app()->db->createCommand($sQuery)->queryScalar();
    $rightexists = $rigthCount > 0;
    // $right_exists: flag to find out if there are any right hand answer parts. leaving right column but don't force with
    $sQuery = "SELECT count(question) FROM {{questions}} WHERE parent_qid=" . $ia[0] . " and scale_id=0 AND question like '%|%|%'";
    $centerCount = Yii::app()->db->createCommand($sQuery)->queryScalar();
    $centerexists = $centerCount > 0;
    // $center_exists: flag to find out if there are any center hand answer parts. leaving center column but don't force with
    // Label and code for input
    foreach ($aAnswersScale0 as $lrow) {
        $labels0[] = array('code' => $lrow['code'], 'title' => $lrow['answer']);
    }
    foreach ($aAnswersScale1 as $lrow) {
        $labels1[] = array('code' => $lrow['code'], 'title' => $lrow['answer']);
    }
    if (count($aAnswersScale0) > 0 && $anscount) {
        $answer = "";
        $fn = 1;
        // Used by repeat_heading
        if ($useDropdownLayout === false) {
            $columnswidth = 100 - $answerwidth;
            foreach ($aAnswersScale0 as $lrow) {
                $labelans0[] = $lrow['answer'];
                $labelcode0[] = $lrow['code'];
            }
            foreach ($aAnswersScale1 as $lrow) {
                $labelans1[] = $lrow['answer'];
                $labelcode1[] = $lrow['code'];
            }
            $numrows = count($labelans0) + count($labelans1);
            // Add needed row and fill some boolean: shownoanswer, rightexists, centerexists
            $shownoanswer = $ia[6] != "Y" && SHOW_NO_ANSWER == 1;
//.........这里部分代码省略.........
开发者ID:segfault,项目名称:LimeSurvey,代码行数:101,代码来源:qanda_helper.php

示例4: getFullResponseTable

/**
* Creates an array with details on a particular response for display purposes
* Used in Print answers, Detailed response view and Detailed admin notification email
*
* @param mixed $iSurveyID
* @param mixed $iResponseID
* @param mixed $sLanguageCode
* @param boolean $bHonorConditions Apply conditions
*/
function getFullResponseTable($iSurveyID, $iResponseID, $sLanguageCode, $bHonorConditions = true)
{
    $aFieldMap = createFieldMap($iSurveyID, 'full', false, false, $sLanguageCode);
    //Get response data
    $idrow = SurveyDynamic::model($iSurveyID)->findByAttributes(array('id' => $iResponseID));
    // Create array of non-null values - those are the relevant ones
    $aRelevantFields = array();
    foreach ($aFieldMap as $sKey => $fname) {
        if (LimeExpressionManager::QuestionIsRelevant($fname['qid']) || $bHonorConditions == false) {
            $aRelevantFields[$sKey] = $fname;
        }
    }
    $aResultTable = array();
    $oldgid = 0;
    $oldqid = 0;
    foreach ($aRelevantFields as $sKey => $fname) {
        if (!empty($fname['qid'])) {
            $attributes = getQuestionAttributeValues($fname['qid']);
            if (getQuestionAttributeValue($attributes, 'hidden') == 1) {
                continue;
            }
        }
        $question = $fname['question'];
        $subquestion = '';
        if (isset($fname['gid']) && !empty($fname['gid'])) {
            //Check to see if gid is the same as before. if not show group name
            if ($oldgid !== $fname['gid']) {
                $oldgid = $fname['gid'];
                if (LimeExpressionManager::GroupIsRelevant($fname['gid']) || $bHonorConditions == false) {
                    $aResultTable['gid_' . $fname['gid']] = array($fname['group_name'], QuestionGroup::model()->getGroupDescription($fname['gid'], $sLanguageCode));
                }
            }
        }
        if (!empty($fname['qid'])) {
            if ($oldqid !== $fname['qid']) {
                $oldqid = $fname['qid'];
                if (isset($fname['subquestion']) || isset($fname['subquestion1']) || isset($fname['subquestion2'])) {
                    $aResultTable['qid_' . $fname['sid'] . 'X' . $fname['gid'] . 'X' . $fname['qid']] = array($fname['question'], '', '');
                } else {
                    $answer = getExtendedAnswer($iSurveyID, $fname['fieldname'], $idrow[$fname['fieldname']], $sLanguageCode);
                    $aResultTable[$fname['fieldname']] = array($question, '', $answer);
                    continue;
                }
            }
        } else {
            $answer = getExtendedAnswer($iSurveyID, $fname['fieldname'], $idrow[$fname['fieldname']], $sLanguageCode);
            $aResultTable[$fname['fieldname']] = array($question, '', $answer);
            continue;
        }
        if (isset($fname['subquestion'])) {
            $subquestion = "[{$fname['subquestion']}]";
        }
        if (isset($fname['subquestion1'])) {
            $subquestion = "[{$fname['subquestion1']}]";
        }
        if (isset($fname['subquestion2'])) {
            $subquestion .= "[{$fname['subquestion2']}]";
        }
        $answer = getExtendedAnswer($iSurveyID, $fname['fieldname'], $idrow[$fname['fieldname']], $sLanguageCode);
        $aResultTable[$fname['fieldname']] = array($question, $subquestion, $answer);
    }
    return $aResultTable;
}
开发者ID:GuillaumeSmaha,项目名称:LimeSurvey,代码行数:72,代码来源:common_helper.php

示例5: doAssessment

/**
* Caculate assessement scores
*
* @param mixed $surveyid
* @param mixed $returndataonly - only returns an array with data
*/
function doAssessment($surveyid, $returndataonly = false)
{
    $clang = Yii::app()->lang;
    $baselang = Survey::model()->findByPk($surveyid)->language;
    if (Survey::model()->findByPk($surveyid)->assessments != "Y") {
        return false;
    }
    $total = 0;
    if (!isset($_SESSION['survey_' . $surveyid]['s_lang'])) {
        $_SESSION['survey_' . $surveyid]['s_lang'] = $baselang;
    }
    $query = "SELECT * FROM {{assessments}}\n    WHERE sid={$surveyid} and language='" . $_SESSION['survey_' . $surveyid]['s_lang'] . "'\n    ORDER BY scope, id";
    if ($result = dbExecuteAssoc($query)) {
        $aResultSet = $result->readAll();
        if (count($aResultSet) > 0) {
            foreach ($aResultSet as $row) {
                if ($row['scope'] == "G") {
                    $assessment['group'][$row['gid']][] = array("name" => $row['name'], "min" => $row['minimum'], "max" => $row['maximum'], "message" => $row['message']);
                } else {
                    $assessment['total'][] = array("name" => $row['name'], "min" => $row['minimum'], "max" => $row['maximum'], "message" => $row['message']);
                }
            }
            $fieldmap = createFieldMap($surveyid, "full", false, false, $_SESSION['survey_' . $surveyid]['s_lang']);
            $i = 0;
            $total = 0;
            $groups = array();
            foreach ($fieldmap as $field) {
                if (in_array($field['type'], array('1', 'F', 'H', 'W', 'Z', 'L', '!', 'M', 'O', 'P'))) {
                    $fieldmap[$field['fieldname']]['assessment_value'] = 0;
                    if (isset($_SESSION['survey_' . $surveyid][$field['fieldname']])) {
                        if ($field['type'] == "M" || $field['type'] == "P") {
                            if ($_SESSION['survey_' . $surveyid][$field['fieldname']] == "Y") {
                                $aAttributes = getQuestionAttributeValues($field['qid'], $field['type']);
                                $fieldmap[$field['fieldname']]['assessment_value'] = (int) $aAttributes['assessment_value'];
                                $total = $total + (int) $aAttributes['assessment_value'];
                            }
                        } else {
                            $usquery = "SELECT assessment_value FROM {{answers}} where qid=" . $field['qid'] . " and language='{$baselang}' and code=" . dbQuoteAll($_SESSION['survey_' . $surveyid][$field['fieldname']]);
                            $usresult = dbExecuteAssoc($usquery);
                            //Checked
                            if ($usresult) {
                                $usrow = $usresult->read();
                                $fieldmap[$field['fieldname']]['assessment_value'] = $usrow['assessment_value'];
                                $total = $total + $usrow['assessment_value'];
                            }
                        }
                    }
                    $groups[] = $field['gid'];
                }
                $i++;
            }
            $groups = array_unique($groups);
            foreach ($groups as $group) {
                $grouptotal = 0;
                foreach ($fieldmap as $field) {
                    if ($field['gid'] == $group && isset($field['assessment_value'])) {
                        //$grouptotal=$grouptotal+$field['answer'];
                        if (isset($_SESSION['survey_' . $surveyid][$field['fieldname']])) {
                            $grouptotal = $grouptotal + $field['assessment_value'];
                        }
                    }
                }
                $subtotal[$group] = $grouptotal;
            }
        }
        $assessments = "";
        if (isset($subtotal) && is_array($subtotal)) {
            foreach ($subtotal as $key => $val) {
                if (isset($assessment['group'][$key])) {
                    foreach ($assessment['group'][$key] as $assessed) {
                        if ($val >= $assessed['min'] && $val <= $assessed['max'] && $returndataonly === false) {
                            $assessments .= "\t<!-- GROUP ASSESSMENT: Score: {$val} Min: " . $assessed['min'] . " Max: " . $assessed['max'] . "-->\n                            <table class='assessments'>\n                            <tr>\n                            <th>" . str_replace(array("{PERC}", "{TOTAL}"), array($val, $total), $assessed['name']) . "\n                            </th>\n                            </tr>\n                            <tr>\n                            <td>" . str_replace(array("{PERC}", "{TOTAL}"), array($val, $total), $assessed['message']) . "\n                            </td>\n                            </tr>\n                            </table><br />\n";
                        }
                    }
                }
            }
        }
        if (isset($assessment['total'])) {
            foreach ($assessment['total'] as $assessed) {
                if ($total >= $assessed['min'] && $total <= $assessed['max'] && $returndataonly === false) {
                    $assessments .= "\t\t\t<!-- TOTAL ASSESSMENT: Score: {$total} Min: " . $assessed['min'] . " Max: " . $assessed['max'] . "-->\n                    <table class='assessments' align='center'>\n                    <tr>\n                    <th>" . str_replace(array("{PERC}", "{TOTAL}"), array($val, $total), stripslashes($assessed['name'])) . "\n                    </th>\n                    </tr>\n                    <tr>\n                    <td>" . str_replace(array("{PERC}", "{TOTAL}"), array($val, $total), stripslashes($assessed['message'])) . "\n                    </td>\n                    </tr>\n                    </table>\n";
                }
            }
        }
        if ($returndataonly == true) {
            return array('total' => $total);
        } else {
            return $assessments;
        }
    }
}
开发者ID:elcharlygraf,项目名称:Encuesta-YiiFramework,代码行数:97,代码来源:frontend_helper.php

示例6: graph

 function graph()
 {
     Yii::app()->loadHelper('admin/statistics');
     Yii::app()->loadHelper("surveytranslator");
     // Initialise PCHART
     require_once Yii::app()->basePath . '/third_party/pchart/pchart/pChart.class';
     require_once Yii::app()->basePath . '/third_party/pchart/pchart/pData.class';
     require_once Yii::app()->basePath . '/third_party/pchart/pchart/pCache.class';
     Yii::import('application.third_party.ar-php.Arabic', true);
     $tempdir = Yii::app()->getConfig("tempdir");
     $MyCache = new pCache($tempdir . '/');
     $aData['success'] = 1;
     $sStatisticsLanguage = sanitize_languagecode($_POST['sStatisticsLanguage']);
     $oStatisticsLanguage = new Limesurvey_lang($sStatisticsLanguage);
     if (isset($_POST['cmd']) && isset($_POST['id'])) {
         list($qsid, $qgid, $qqid) = explode("X", substr($_POST['id'], 0), 3);
         if (!is_numeric(substr($qsid, 0, 1))) {
             // Strip first char when not numeric (probably T or D)
             $qsid = substr($qsid, 1);
         }
         $aFieldmap = createFieldMap($qsid, 'full', false, false, $sStatisticsLanguage);
         $qtype = $aFieldmap[$_POST['id']]['type'];
         $qqid = $aFieldmap[$_POST['id']]['qid'];
         $aattr = getQuestionAttributeValues($qqid);
         $field = substr($_POST['id'], 1);
         switch ($_POST['cmd']) {
             case 'showmap':
                 if (isset($aattr['location_mapservice'])) {
                     $aData['mapdata'] = array("coord" => getQuestionMapData($field, $qsid), "zoom" => $aattr['location_mapzoom'], "width" => $aattr['location_mapwidth'], "height" => $aattr['location_mapheight']);
                     QuestionAttribute::model()->setQuestionAttribute($qqid, 'statistics_showmap', 1);
                 } else {
                     $aData['success'] = 0;
                 }
                 break;
             case 'hidemap':
                 if (isset($aattr['location_mapservice'])) {
                     $aData['success'] = 1;
                     QuestionAttribute::model()->setQuestionAttribute($qqid, 'statistics_showmap', 0);
                 } else {
                     $aData['success'] = 0;
                 }
                 break;
             case 'showgraph':
                 if (isset($aattr['location_mapservice'])) {
                     $aData['mapdata'] = array("coord" => getQuestionMapData($field, $qsid), "zoom" => $aattr['location_mapzoom'], "width" => $aattr['location_mapwidth'], "height" => $aattr['location_mapheight']);
                 }
                 $bChartType = $qtype != "M" && $qtype != "P" && $aattr["statistics_graphtype"] == "1";
                 $adata = Yii::app()->session['stats'][$_POST['id']];
                 $aData['chartdata'] = createChart($qqid, $qsid, $bChartType, $adata['lbl'], $adata['gdata'], $adata['grawdata'], $MyCache, $oStatisticsLanguage, $qtype);
                 QuestionAttribute::model()->setQuestionAttribute($qqid, 'statistics_showgraph', 1);
                 break;
             case 'hidegraph':
                 QuestionAttribute::model()->setQuestionAttribute($qqid, 'statistics_showgraph', 0);
                 break;
             case 'showbar':
                 if ($qtype == "M" || $qtype == "P") {
                     $aData['success'] = 0;
                     break;
                 }
                 QuestionAttribute::model()->setQuestionAttribute($qqid, 'statistics_graphtype', 0);
                 $adata = Yii::app()->session['stats'][$_POST['id']];
                 $aData['chartdata'] = createChart($qqid, $qsid, 0, $adata['lbl'], $adata['gdata'], $adata['grawdata'], $MyCache, $oStatisticsLanguage, $qtype);
                 break;
             case 'showpie':
                 if ($qtype == "M" || $qtype == "P") {
                     $aData['success'] = 0;
                     break;
                 }
                 QuestionAttribute::model()->setQuestionAttribute($qqid, 'statistics_graphtype', 1);
                 $adata = Yii::app()->session['stats'][$_POST['id']];
                 $aData['chartdata'] = createChart($qqid, $qsid, 1, $adata['lbl'], $adata['gdata'], $adata['grawdata'], $MyCache, $oStatisticsLanguage, $qtype);
                 break;
             default:
                 $aData['success'] = 0;
                 break;
         }
     } else {
         $aData['success'] = 0;
     }
     //$this->_renderWrappedTemplate('export', 'statistics_graph_view', $aData);
     $this->getController()->renderPartial('export/statistics_graph_view', $aData);
 }
开发者ID:josetorerobueno,项目名称:test_repo,代码行数:82,代码来源:statistics.php

示例7: displayResults


//.........这里部分代码省略.........
         $this->pdf->headTable($headPDF, $tablePDF);
         //$this->pdf->tableintopdf($tablePDF);
         //                if(isset($footPDF))
         //                foreach($footPDF as $foot)
         //                {
         //                    $footA = array($foot);
         //                    $this->pdf->tablehead($footA);
         //                }
         if (isset($headPDF2)) {
             $this->pdf->headTable($headPDF2, $tablePDF2);
         }
     }
     if ($outputType == 'xls' && (isset($headXLS) || isset($tableXLS))) {
         if (isset($headXLS)) {
             $this->xlsRow++;
             $this->xlsRow++;
             foreach ($headXLS as $aRow) {
                 $this->xlsRow++;
                 $iColumn = 0;
                 foreach ($aRow as $sValue) {
                     $this->sheet->write($this->xlsRow, $iColumn, $sValue, $this->formatBold);
                     $iColumn++;
                 }
             }
         }
         if (isset($tableXLS)) {
             foreach ($tableXLS as $aRow) {
                 $this->xlsRow++;
                 $iColumn = 0;
                 foreach ($aRow as $sValue) {
                     $this->sheet->write($this->xlsRow, $iColumn, $sValue);
                     $iColumn++;
                 }
             }
         }
     }
     if ($outputType == 'html') {
         $statisticsoutput .= "<tr><td colspan='4' style=\"text-align:center\" id='statzone_{$rt}'>";
     }
     //-------------------------- PCHART OUTPUT ----------------------------
     list($qsid, $qgid, $qqid) = explode("X", $rt, 3);
     $qsid = $surveyid;
     $aattr = getQuestionAttributeValues($outputs['parentqid'], substr($rt, 0, 1));
     //PCHART has to be enabled and we need some data
     if ($usegraph == 1) {
         $bShowGraph = $aattr["statistics_showgraph"] == "1";
         $bAllowPieChart = $outputs['qtype'] != "M" && $outputs['qtype'] != "P";
         $bAllowMap = isset($aattr["location_mapservice"]) && $aattr["location_mapservice"] == "1";
         $bShowMap = $bAllowMap && $aattr["statistics_showmap"] == "1";
         $bShowPieChart = $bAllowPieChart && (isset($aattr["statistics_graphtype"]) && $aattr["statistics_graphtype"] == "1");
         $astatdata[$rt] = array('id' => $rt, 'sg' => $bShowGraph, 'ap' => $bAllowPieChart, 'am' => $bAllowMap, 'sm' => $bShowMap, 'sp' => $bShowPieChart);
         $stats = Yii::app()->session['stats'];
         $stats[$rt] = array('lbl' => $lbl, 'gdata' => $gdata, 'grawdata' => $grawdata);
         Yii::app()->session['stats'] = $stats;
         if ($bShowGraph == true) {
             $cachefilename = createChart($qqid, $qsid, $bShowPieChart, $lbl, $gdata, $grawdata, $MyCache, $sLanguage, $outputs['qtype']);
             if ($cachefilename) {
                 //introduce new counter
                 if (!isset($ci)) {
                     $ci = 0;
                 }
                 //increase counter, start value -> 1
                 $ci++;
                 switch ($outputType) {
                     case 'xls':
                         /**
                          * No Image for Excel...
                          */
                         break;
                     case 'pdf':
                         $this->pdf->AddPage('P', 'A4');
                         $this->pdf->titleintopdf($pdfTitle, $titleDesc);
                         $this->pdf->Image($tempdir . "/" . $cachefilename, 0, 70, 180, 0, '', Yii::app()->getController()->createUrl("admin/survey/sa/view/surveyid/" . $surveyid), 'B', true, 150, 'C', false, false, 0, true);
                         break;
                     case 'html':
                         $statisticsoutput .= "<img src=\"{$tempurl}/" . $cachefilename . "\" border='1' />";
                         $aattr = getQuestionAttributeValues($qqid, $firstletter);
                         if ($bShowMap) {
                             $statisticsoutput .= "<div id=\"statisticsmap_{$rt}\" class=\"statisticsmap\"></div>";
                             $agmapdata[$rt] = array("coord" => getQuestionMapData(substr($rt, 1), $qsid), "zoom" => $aattr['location_mapzoom'], "width" => $aattr['location_mapwidth'], "height" => $aattr['location_mapheight']);
                         }
                         break;
                     default:
                         break;
                 }
             }
         }
     }
     //close table/output
     if ($outputType == 'html') {
         // show this block only when we show graphs and are not in the public statics controller
         // this is because the links don't work from that controller
         if ($usegraph == 1 && get_class(Yii::app()->getController()) !== 'Statistics_userController') {
             $sImgUrl = Yii::app()->getConfig('adminimageurl');
             $statisticsoutput .= "</td></tr><tr><td colspan='4'><div id='stats_{$rt}' class='graphdisplay' style=\"text-align:center\">" . "<img class='stats-hidegraph' src='{$sImgUrl}/chart_disabled.png' title='" . gT("Disable chart") . "' />" . "<img class='stats-showgraph' src='{$sImgUrl}/chart.png' title='" . gT("Enable chart") . "' />" . "<img class='stats-showbar' src='{$sImgUrl}/chart_bar.png' title='" . gT("Display as bar chart") . "' />" . "<img class='stats-showpie' src='{$sImgUrl}/chart_pie.png' title='" . gT("Display as pie chart") . "' />" . "<img class='stats-showmap' src='{$sImgUrl}/map_disabled.png' title='" . gT("Disable map display") . "' />" . "<img class='stats-hidemap' src='{$sImgUrl}/map.png' title='" . gT("Enable map display") . "' />" . "</div></td></tr>";
         }
         $statisticsoutput .= "</td></tr></table><br /> \n";
     }
     return array("statisticsoutput" => $statisticsoutput, "pdf" => $this->pdf, "astatdata" => $astatdata);
 }
开发者ID:krsandesh,项目名称:LimeSurvey,代码行数:101,代码来源:statistics_helper.php

示例8: run


//.........这里部分代码省略.........
           $thissurvey['anonymized'] == "N" &&
           isset($_SESSION[$LEMsessid]['srid']) &&
           $thissurvey['active'] == "Y")
           {
           loadanswers();
           }
           */
        //******************************************************************************************************
        //PRESENT SURVEY
        //******************************************************************************************************
        $okToShowErrors = !$previewgrp && (isset($invalidLastPage) || $_SESSION[$LEMsessid]['prevstep'] == $_SESSION[$LEMsessid]['step']);
        Yii::app()->getController()->loadHelper('qanda');
        setNoAnswerMode($thissurvey);
        //Iterate through the questions about to be displayed:
        $inputnames = array();
        foreach ($_SESSION[$LEMsessid]['grouplist'] as $gl) {
            $gid = $gl[0];
            $qnumber = 0;
            if ($surveyMode != 'survey') {
                $onlyThisGID = $stepInfo['gid'];
                if ($onlyThisGID != $gid) {
                    continue;
                }
            }
            // TMSW - could iterate through LEM::currentQset instead
            foreach ($_SESSION[$LEMsessid]['fieldarray'] as $key => $ia) {
                ++$qnumber;
                $ia[9] = $qnumber;
                // incremental question count;
                if (isset($ia[10]) && $ia[10] == $gid || !isset($ia[10]) && $ia[5] == $gid) {
                    if ($surveyMode == 'question' && $ia[0] != $stepInfo['qid']) {
                        continue;
                    }
                    $qidattributes = getQuestionAttributeValues($ia[0], $ia[4]);
                    if ($ia[4] != '*' && ($qidattributes === false || !isset($qidattributes['hidden']) || $qidattributes['hidden'] == 1)) {
                        continue;
                    }
                    //Get the answers/inputnames
                    // TMSW - can content of retrieveAnswers() be provided by LEM?  Review scope of what it provides.
                    // TODO - retrieveAnswers is slow - queries database separately for each question. May be fixed in _CI or _YII ports, so ignore for now
                    list($plus_qanda, $plus_inputnames) = retrieveAnswers($ia, $surveyid);
                    if ($plus_qanda) {
                        $plus_qanda[] = $ia[4];
                        $plus_qanda[] = $ia[6];
                        // adds madatory identifyer for adding mandatory class to question wrapping div
                        $qanda[] = $plus_qanda;
                    }
                    if ($plus_inputnames) {
                        $inputnames = addtoarray_single($inputnames, $plus_inputnames);
                    }
                    //Display the "mandatory" popup if necessary
                    // TMSW - get question-level error messages - don't call **_popup() directly
                    if ($okToShowErrors && $stepInfo['mandViolation']) {
                        list($mandatorypopup, $popup) = mandatory_popup($ia, $notanswered);
                    }
                    //Display the "validation" popup if necessary
                    if ($okToShowErrors && !$stepInfo['valid']) {
                        list($validationpopup, $vpopup) = validation_popup($ia, $notvalidated);
                    }
                    // Display the "file validation" popup if necessary
                    if ($okToShowErrors && isset($filenotvalidated)) {
                        list($filevalidationpopup, $fpopup) = file_validation_popup($ia, $filenotvalidated);
                    }
                }
                if ($ia[4] == "|") {
                    $upload_file = TRUE;
开发者ID:ryu1inaba,项目名称:LimeSurvey,代码行数:67,代码来源:SurveyRuntimeHelper.php

示例9: view

 /**
  * dataentry::view()
  * view a dataentry
  * @param mixed $surveyid
  * @param mixed $lang
  * @return
  */
 public function view($surveyid, $lang = NULL)
 {
     $surveyid = sanitize_int($surveyid);
     $lang = isset($_GET['lang']) ? $_GET['lang'] : NULL;
     if (isset($lang)) {
         $lang = sanitize_languagecode($lang);
     }
     $aViewUrls = array();
     if (Permission::model()->hasSurveyPermission($surveyid, 'responses', 'create')) {
         $sDataEntryLanguage = Survey::model()->findByPk($surveyid)->language;
         $surveyinfo = getSurveyInfo($surveyid);
         $slangs = Survey::model()->findByPk($surveyid)->additionalLanguages;
         $baselang = Survey::model()->findByPk($surveyid)->language;
         array_unshift($slangs, $baselang);
         if (is_null($lang) || !in_array($lang, $slangs)) {
             $sDataEntryLanguage = $baselang;
         } else {
             $sDataEntryLanguage = $lang;
         }
         $langlistbox = languageDropdown($surveyid, $sDataEntryLanguage);
         $thissurvey = getSurveyInfo($surveyid);
         //This is the default, presenting a blank dataentry form
         LimeExpressionManager::StartSurvey($surveyid, 'survey', NULL, false, LEM_PRETTY_PRINT_ALL_SYNTAX);
         $moveResult = LimeExpressionManager::NavigateForwards();
         $aData['thissurvey'] = $thissurvey;
         $aData['langlistbox'] = $langlistbox;
         $aData['surveyid'] = $surveyid;
         $aData['sDataEntryLanguage'] = $sDataEntryLanguage;
         $aData['site_url'] = Yii::app()->homeUrl;
         LimeExpressionManager::StartProcessingPage(true, Yii::app()->baseUrl);
         // means that all variables are on the same page
         $aViewUrls[] = 'caption_view';
         Yii::app()->loadHelper('database');
         // SURVEY NAME AND DESCRIPTION TO GO HERE
         $degquery = "SELECT * FROM {{groups}} WHERE sid={$surveyid} AND language='{$sDataEntryLanguage}' ORDER BY {{groups}}.group_order";
         $degresult = dbExecuteAssoc($degquery);
         // GROUP NAME
         $aDataentryoutput = '';
         foreach ($degresult->readAll() as $degrow) {
             LimeExpressionManager::StartProcessingGroup($degrow['gid'], $thissurvey['anonymized'] != "N", $surveyid);
             $deqquery = "SELECT * FROM {{questions}} WHERE sid={$surveyid} AND parent_qid=0 AND gid={$degrow['gid']} AND language='{$sDataEntryLanguage}'";
             $deqrows = (array) dbExecuteAssoc($deqquery)->readAll();
             $aDataentryoutput .= "\t<tr class='info'>\n" . "<!-- Inside controller dataentry.php -->" . "<td colspan='3'><h4>" . flattenText($degrow['group_name'], true) . "</h4></td>\n" . "\t</tr>\n";
             $gid = $degrow['gid'];
             $aDataentryoutput .= "\t<tr class='data-entry-separator'><td colspan='3'></td></tr>\n";
             // Perform a case insensitive natural sort on group name then question title of a multidimensional array
             usort($deqrows, 'groupOrderThenQuestionOrder');
             $bgc = 'odd';
             foreach ($deqrows as $deqrow) {
                 $cdata = array();
                 $qidattributes = getQuestionAttributeValues($deqrow['qid']);
                 $cdata['qidattributes'] = $qidattributes;
                 $hidden = isset($qidattributes['hidden']) ? $qidattributes['hidden'] : 0;
                 // TODO - can questions be hidden?  Are JavaScript variables names used?  Consistently with everywhere else?
                 //                    LimeExpressionManager::ProcessRelevance($qidattributes['relevance'],$deqrow['qid'],NULL,$deqrow['type'],$hidden);
                 // TMSW Condition->Relevance:  Show relevance equation instead of conditions here - better yet, have data entry use survey-at-a-time but with different view
                 $qinfo = LimeExpressionManager::GetQuestionStatus($deqrow['qid']);
                 $relevance = trim($qinfo['info']['relevance']);
                 $explanation = trim($qinfo['relEqn']);
                 $validation = trim($qinfo['prettyValidTip']);
                 $qidattributes = getQuestionAttributeValues($deqrow['qid']);
                 $array_filter_help = flattenText($this->_array_filter_help($qidattributes, $sDataEntryLanguage, $surveyid));
                 if ($relevance != '' && $relevance != '1' || $validation != '' || $array_filter_help != '') {
                     $showme = '<div class="alert alert-warning col-sm-8 col-sm-offset-2" role="alert">';
                     if ($bgc == "even") {
                         $bgc = "odd";
                     } else {
                         $bgc = "even";
                     }
                     //Do no alternate on explanation row
                     if ($relevance != '' && $relevance != '1') {
                         $showme = '<strong>' . gT("Only answer this if the following conditions are met:", 'html', $sDataEntryLanguage) . "</strong><br />{$explanation}\n";
                     }
                     if ($validation != '') {
                         $showme .= '<strong>' . gT("The answer(s) must meet these validation criteria:", 'html', $sDataEntryLanguage) . "</strong><br />{$validation}\n";
                     }
                     if ($showme != '' && $array_filter_help != '') {
                         $showme .= '<br/>';
                     }
                     if ($array_filter_help != '') {
                         $showme .= '<strong>' . gT("The answer(s) must meet these array_filter criteria:", 'html', $sDataEntryLanguage) . "</strong><br />{$array_filter_help}\n";
                     }
                     $showme .= '</div>';
                     $cdata['explanation'] = "<tr class ='data-entry-explanation'><td class='data-entry-small-text' colspan='3' align='left'>{$showme}</td></tr>\n";
                 }
                 //END OF GETTING CONDITIONS
                 //Alternate bgcolor for different groups
                 if (!isset($bgc)) {
                     $bgc = "even";
                 }
                 if ($bgc == "even") {
                     $bgc = "odd";
                 } else {
//.........这里部分代码省略.........
开发者ID:mfavetti,项目名称:LimeSurvey,代码行数:101,代码来源:dataentry.php

示例10: do_array_dual

function do_array_dual($ia)
{
    global $thissurvey;
    global $notanswered;
    $repeatheadings = Yii::app()->getConfig("repeatheadings");
    $minrepeatheadings = Yii::app()->getConfig("minrepeatheadings");
    $extraclass = "";
    $answertypeclass = "";
    // Maybe not
    $clang = Yii::app()->lang;
    $checkconditionFunction = "checkconditions";
    $inputnames = array();
    $labelans1 = array();
    $labelans = array();
    $qquery = "SELECT other FROM {{questions}} WHERE qid=" . $ia[0] . " AND language='" . $_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang'] . "'";
    $other = dbExecuteAssoc($qquery)->read();
    $other = reset($other);
    //Checked
    $lquery = "SELECT * FROM {{answers}} WHERE scale_id=0 AND qid={$ia[0]} AND language='" . $_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang'] . "' ORDER BY sortorder, code";
    $lquery1 = "SELECT * FROM {{answers}} WHERE scale_id=1 AND qid={$ia[0]} AND language='" . $_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang'] . "' ORDER BY sortorder, code";
    $aQuestionAttributes = getQuestionAttributeValues($ia[0], $ia[4]);
    if ($aQuestionAttributes['use_dropdown'] == 1) {
        $useDropdownLayout = true;
        $extraclass .= " dropdown-list";
        $answertypeclass .= " dropdown";
    } else {
        $useDropdownLayout = false;
        $extraclass .= " radio-list";
        $answertypeclass .= " radio";
    }
    if (ctype_digit(trim($aQuestionAttributes['repeat_headings'])) && trim($aQuestionAttributes['repeat_headings'] != "")) {
        $repeatheadings = intval($aQuestionAttributes['repeat_headings']);
        $minrepeatheadings = 0;
    }
    if (trim($aQuestionAttributes['dualscale_headerA'][$_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang']]) != '') {
        $leftheader = $clang->gT($aQuestionAttributes['dualscale_headerA'][$_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang']]);
    } else {
        $leftheader = '';
    }
    if (trim($aQuestionAttributes['dualscale_headerB'][$_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang']]) != '') {
        $rightheader = $clang->gT($aQuestionAttributes['dualscale_headerB'][$_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang']]);
    } else {
        $rightheader = '';
    }
    $lresult = dbExecuteAssoc($lquery);
    //Checked
    $aAnswersScale1 = $lresult->readAll();
    if ($useDropdownLayout === false && count($aAnswersScale1) > 0) {
        if (trim($aQuestionAttributes['answer_width']) != '') {
            $answerwidth = $aQuestionAttributes['answer_width'];
        } else {
            $answerwidth = 20;
        }
        $columnswidth = 100 - $answerwidth;
        foreach ($aAnswersScale1 as $lrow) {
            $labelans[] = $lrow['answer'];
            $labelcode[] = $lrow['code'];
        }
        $lresult1 = dbExecuteAssoc($lquery1);
        //Checked
        foreach ($lresult1->readAll() as $lrow1) {
            $labelans1[] = $lrow1['answer'];
            $labelcode1[] = $lrow1['code'];
        }
        $numrows = count($labelans) + count($labelans1);
        if ($ia[6] != "Y" && SHOW_NO_ANSWER == 1) {
            $numrows++;
        }
        $cellwidth = $columnswidth / $numrows;
        $cellwidth = sprintf("%02d", $cellwidth);
        $sQuery = "SELECT count(question) FROM {{questions}} WHERE parent_qid=" . $ia[0] . " and scale_id=0 AND question like '%|%'";
        $iCount = Yii::app()->db->createCommand($sQuery)->queryScalar();
        $right_exists = $iCount > 0;
        // $right_exists is a flag to find out if there are any right hand answer parts. If there aren't we can leave out the right td column
        if ($aQuestionAttributes['random_order'] == 1) {
            $ansquery = "SELECT * FROM {{questions}} WHERE parent_qid={$ia['0']} AND language='" . $_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang'] . "' and scale_id=0 ORDER BY " . dbRandom();
        } else {
            $ansquery = "SELECT * FROM {{questions}} WHERE parent_qid={$ia['0']} AND language='" . $_SESSION['survey_' . Yii::app()->getConfig('surveyID')]['s_lang'] . "' and scale_id=0 ORDER BY question_order";
        }
        $ansresult = dbExecuteAssoc($ansquery);
        //Checked
        $aQuestionsRight = $ansresult->readAll();
        $anscount = count($aQuestionsRight);
        $fn = 1;
        // unselect second scale when using "no answer"
        $answer = "<script type='text/javascript'>\n" . "<!--\n" . "function noanswer_checkconditions(value, name, type)\n" . "{\n" . "\tvar vname;\n" . "\tvname = name.replace(/#.*\$/,\"\");\n" . "\t\$('input[name^=\"' + vname + '\"]').attr('checked',false);\n" . "\t\$('input[id=\"answer' + vname + '#0-\"]').attr('checked',true);\n" . "\t\$('input[name^=\"java' + vname + '\"]').val('');\n" . "\t{$checkconditionFunction}(value, name, type);\n" . "}\n" . "function secondlabel_checkconditions(value, name, type)\n" . "{\n" . "\tvar vname;\n" . "\tvname = \"answer\"+name.replace(/#1/g,\"#0-\");\n" . "\tif(document.getElementById(vname))\n" . "\t{\n" . "\tdocument.getElementById(vname).checked=false;\n" . "\t}\n" . "\t{$checkconditionFunction}(value, name, type);\n" . "}\n" . " //-->\n" . " </script>\n";
        // Header row and colgroups
        $mycolumns = "\t<colgroup class=\"col-responses group-1\">\n" . "\t<col class=\"col-answers\" width=\"{$answerwidth}%\" />\n";
        $answer_head_line = "\t<th class=\"header_answer_text\">&nbsp;</th>\n\n";
        $odd_even = '';
        foreach ($labelans as $ld) {
            $answer_head_line .= "\t<th>" . $ld . "</th>\n";
            $odd_even = alternation($odd_even);
            $mycolumns .= "<col class=\"{$odd_even}\" width=\"{$cellwidth}%\" />\n";
        }
        $mycolumns .= "\t</colgroup>\n";
        if (count($labelans1) > 0) {
            $mycolumns .= "\t<colgroup class=\"col-responses group-2\">\n" . "\t<col class=\"seperator\" />\n";
            $answer_head_line .= "\n\t<td class=\"header_separator\">&nbsp;</td>\n\n";
            // Separator
//.........这里部分代码省略.........
开发者ID:rawaludin,项目名称:LimeSurvey,代码行数:101,代码来源:qanda_helper.php

示例11: browse


//.........这里部分代码省略.........
     $fnames[] = array("submitdate", $clang->gT("Completed"), $clang->gT("Completed"), "0", 'D');
     $fields = createFieldMap($iSurveyID, 'full', false, false, $aData['language']);
     foreach ($fields as $fielddetails) {
         if ($fielddetails['fieldname'] == 'lastpage' || $fielddetails['fieldname'] == 'submitdate') {
             continue;
         }
         $question = $fielddetails['question'];
         if ($fielddetails['type'] != "|") {
             if ($fielddetails['fieldname'] == 'lastpage' || $fielddetails['fieldname'] == 'submitdate' || $fielddetails['fieldname'] == 'token') {
                 continue;
             }
             // no headers for time data
             if ($fielddetails['type'] == 'interview_time') {
                 continue;
             }
             if ($fielddetails['type'] == 'page_time') {
                 continue;
             }
             if ($fielddetails['type'] == 'answer_time') {
                 continue;
             }
             if (isset($fielddetails['subquestion']) && $fielddetails['subquestion'] != '') {
                 $question .= ' (' . $fielddetails['subquestion'] . ')';
             }
             if (isset($fielddetails['subquestion1']) && isset($fielddetails['subquestion2'])) {
                 $question .= ' (' . $fielddetails['subquestion1'] . ':' . $fielddetails['subquestion2'] . ')';
             }
             if (isset($fielddetails['scale_id'])) {
                 $question .= '[' . $fielddetails['scale'] . ']';
             }
             $fnames[] = array($fielddetails['fieldname'], $question);
         } else {
             if ($fielddetails['aid'] !== 'filecount') {
                 $qidattributes = getQuestionAttributeValues($fielddetails['qid']);
                 for ($i = 0; $i < $qidattributes['max_num_of_files']; $i++) {
                     if ($qidattributes['show_title'] == 1) {
                         $fnames[] = array($fielddetails['fieldname'], "File " . ($i + 1) . " - " . $fielddetails['question'] . "(Title)", "type" => "|", "metadata" => "title", "index" => $i);
                     }
                     if ($qidattributes['show_comment'] == 1) {
                         $fnames[] = array($fielddetails['fieldname'], "File " . ($i + 1) . " - " . $fielddetails['question'] . "(Comment)", "type" => "|", "metadata" => "comment", "index" => $i);
                     }
                     $fnames[] = array($fielddetails['fieldname'], "File " . ($i + 1) . " - " . $fielddetails['question'] . "(File name)", "type" => "|", "metadata" => "name", "index" => $i);
                     $fnames[] = array($fielddetails['fieldname'], "File " . ($i + 1) . " - " . $fielddetails['question'] . "(File size)", "type" => "|", "metadata" => "size", "index" => $i);
                     //$fnames[] = array($fielddetails['fieldname'], "File ".($i+1)." - ".$fielddetails['question']."(extension)", "type"=>"|", "metadata"=>"ext",     "index"=>$i);
                 }
             } else {
                 $fnames[] = array($fielddetails['fieldname'], "File count");
             }
         }
     }
     $fncount = count($fnames);
     $start = Yii::app()->request->getParam('start', 0);
     $limit = Yii::app()->request->getParam('limit', 50);
     if (!$limit) {
         $limit = 50;
     }
     $oCriteria = new CDbCriteria();
     //Create the query
     if ($aData['surveyinfo']['anonymized'] == "N" && tableExists("{{tokens_{$iSurveyID}}}")) {
         $oCriteria = Survey_dynamic::model($iSurveyID)->addTokenCriteria($oCriteria);
     }
     if (incompleteAnsFilterState() == "incomplete") {
         $oCriteria->addCondition("submitdate IS NULL");
     } elseif (incompleteAnsFilterState() == "complete") {
         $oCriteria->addCondition("submitdate IS NOT NULL");
     }
开发者ID:ryu1inaba,项目名称:LimeSurvey,代码行数:67,代码来源:responses.php

示例12: getFullAnswer

 /**
  * Returns the full answer for the question that matches $fieldName
  * and the answer that matches the $answerCode.  If a match cannot
  * be made then false is returned.
  *
  * The name of the variable $answerCode is not strictly an answerCode
  * but could also be a comment entered by a participant.
  *
  * @param string $fieldName
  * @param string $answerCode
  * @param Translator $translator
  * @param string $sLanguageCode
  * @return string (or false)
  */
 public function getFullAnswer($fieldName, $answerCode, Translator $translator, $sLanguageCode)
 {
     $fullAnswer = null;
     $fieldType = $this->fieldMap[$fieldName]['type'];
     $question = $this->fieldMap[$fieldName];
     $questionId = $question['qid'];
     $answer = null;
     if ($questionId) {
         $answers = $this->getAnswers($questionId);
         if (isset($answers[$answerCode])) {
             $answer = $answers[$answerCode]['answer'];
         }
     }
     //echo "\n$fieldName: $fieldType = $answerCode";
     switch ($fieldType) {
         case 'K':
         case 'N':
             $fullAnswer = $answerCode;
             if (trim($fullAnswer) != '') {
                 if (strpos($fullAnswer, ".") !== false) {
                     $fullAnswer = rtrim(rtrim($fullAnswer, "0"), ".");
                 }
                 $qidattributes = getQuestionAttributeValues($questionId);
                 if (isset($qidattributes['num_value_int_only']) && $qidattributes['num_value_int_only']) {
                     $fullAnswer = number_format($fullAnswer, 0, '', '');
                 }
             }
             break;
         case 'R':
             //RANKING TYPE
             $fullAnswer = $answer;
             break;
         case '1':
             //Array dual scale
             if (mb_substr($fieldName, -1) == 0) {
                 $answers = $this->getAnswers($questionId, 0);
             } else {
                 $answers = $this->getAnswers($questionId, 1);
             }
             if (array_key_exists($answerCode, $answers)) {
                 $fullAnswer = $answers[$answerCode]['answer'];
             } else {
                 $fullAnswer = null;
             }
             break;
         case 'L':
             //DROPDOWN LIST
         //DROPDOWN LIST
         case '!':
             if (mb_substr($fieldName, -5, 5) == 'other') {
                 $fullAnswer = $answerCode;
             } else {
                 if ($answerCode == '-oth-') {
                     $fullAnswer = $translator->translate('Other', $sLanguageCode);
                 } else {
                     $fullAnswer = $answer;
                 }
             }
             break;
         case 'O':
             //DROPDOWN LIST WITH COMMENT
             if (isset($answer)) {
                 //This is one of the dropdown list options.
                 $fullAnswer = $answer;
             } else {
                 //This is a comment.
                 $fullAnswer = $answerCode;
             }
             break;
         case 'Y':
             //YES/NO
             switch ($answerCode) {
                 case 'Y':
                     $fullAnswer = $translator->translate('Yes', $sLanguageCode);
                     break;
                 case 'N':
                     $fullAnswer = $translator->translate('No', $sLanguageCode);
                     break;
                 default:
                     $fullAnswer = $translator->translate('N/A', $sLanguageCode);
             }
             break;
         case 'G':
             switch ($answerCode) {
                 case 'M':
                     $fullAnswer = $translator->translate('Male', $sLanguageCode);
//.........这里部分代码省略.........
开发者ID:mfavetti,项目名称:LimeSurvey,代码行数:101,代码来源:SurveyObj.php

示例13: graph

 function graph()
 {
     Yii::app()->loadHelper('admin/statistics');
     Yii::app()->loadHelper("surveytranslator");
     // Initialise PCHART
     require_once Yii::app()->basePath . '/third_party/pchart/pchart/pChart.class';
     require_once Yii::app()->basePath . '/third_party/pchart/pchart/pData.class';
     require_once Yii::app()->basePath . '/third_party/pchart/pchart/pCache.class';
     $tempdir = Yii::app()->getConfig("tempdir");
     $MyCache = new pCache($tempdir . '/');
     $aData['success'] = 1;
     if (isset($_POST['cmd']) && isset($_POST['id'])) {
         list($qsid, $qgid, $qqid) = explode("X", substr($_POST['id'], 0), 3);
         $qtype = substr($_POST['id'], 0, 1);
         $aattr = getQuestionAttributeValues($qqid, substr($_POST['id'], 0, 1));
         $field = substr($_POST['id'], 1);
         switch ($_POST['cmd']) {
             case 'showmap':
                 if (isset($aattr['location_mapservice'])) {
                     $aData['mapdata'] = array("coord" => getQuestionMapData($field, $qsid), "zoom" => $aattr['location_mapzoom'], "width" => $aattr['location_mapwidth'], "height" => $aattr['location_mapheight']);
                     Question_attributes::model()->setAttribute($qqid, 'statistics_showmap', 1);
                 } else {
                     $aData['success'] = 0;
                 }
                 break;
             case 'hidemap':
                 if (isset($aattr['location_mapservice'])) {
                     $aData['success'] = 1;
                     Question_attributes::model()->setAttribute($qqid, 'statistics_showmap', 0);
                 } else {
                     $aData['success'] = 0;
                 }
                 break;
             case 'showgraph':
                 if (isset($aattr['location_mapservice'])) {
                     $aData['mapdata'] = array("coord" => getQuestionMapData($field, $qsid), "zoom" => $aattr['location_mapzoom'], "width" => $aattr['location_mapwidth'], "height" => $aattr['location_mapheight']);
                 }
                 $bChartType = $qtype != "M" && $qtype != "P" && $aattr["statistics_graphtype"] == "1";
                 $adata = Yii::app()->session['stats'][$_POST['id']];
                 $aData['chartdata'] = createChart($qqid, $qsid, $bChartType, $adata['lbl'], $adata['gdata'], $adata['grawdata'], $MyCache);
                 Question_attributes::model()->setAttribute($qqid, 'statistics_showgraph', 1);
                 break;
             case 'hidegraph':
                 Question_attributes::model()->setAttribute($qqid, 'statistics_showgraph', 0);
                 break;
             case 'showbar':
                 if ($qtype == "M" || $qtype == "P") {
                     $aData['success'] = 0;
                     break;
                 }
                 Question_attributes::model()->setAttribute($qqid, 'statistics_graphtype', 0);
                 $adata = Yii::app()->session['stats'][$_POST['id']];
                 $aData['chartdata'] = createChart($qqid, $qsid, 0, $adata['lbl'], $adata['gdata'], $adata['grawdata'], $MyCache);
                 break;
             case 'showpie':
                 if ($qtype == "M" || $qtype == "P") {
                     $aData['success'] = 0;
                     break;
                 }
                 Question_attributes::model()->setAttribute($qqid, 'statistics_graphtype', 1);
                 $adata = Yii::app()->session['stats'][$_POST['id']];
                 $aData['chartdata'] = createChart($qqid, $qsid, 1, $adata['lbl'], $adata['gdata'], $adata['grawdata'], $MyCache);
                 break;
             default:
                 $aData['success'] = 0;
                 break;
         }
     } else {
         $aData['success'] = 0;
     }
     //$this->_renderWrappedTemplate('export', 'statistics_graph_view', $aData);
     $this->getController()->render('export/statistics_graph_view', $aData);
 }
开发者ID:rawaludin,项目名称:LimeSurvey,代码行数:73,代码来源:statistics.php

示例14: getAdvancedSettingsWithValues

 /**
  * This function returns an array of the advanced attributes for the particular question
  * including their values set in the database
  *
  * @access public
  * @param int $iQuestionID  The question ID - if 0 then all settings will use the default value
  * @param string $sQuestionType  The question type
  * @param int $iSurveyID
  * @param string $sLanguage  If you give a language then only the attributes for that language are returned
  * @return array
  */
 public function getAdvancedSettingsWithValues($iQuestionID, $sQuestionType, $iSurveyID, $sLanguage = null)
 {
     if (is_null($sLanguage)) {
         $aLanguages = array_merge(array(Survey::model()->findByPk($iSurveyID)->language), Survey::model()->findByPk($iSurveyID)->additionalLanguages);
     } else {
         $aLanguages = array($sLanguage);
     }
     if ($iQuestionID != 0) {
         $aAttributeValues = getQuestionAttributeValues($iQuestionID, $sQuestionType);
     }
     $aAttributeNames = questionAttributes();
     $aAttributeNames = $aAttributeNames[$sQuestionType];
     uasort($aAttributeNames, 'categorySort');
     foreach ($aAttributeNames as $iKey => $aAttribute) {
         if ($aAttribute['i18n'] == false) {
             if (isset($aAttributeValues[$aAttribute['name']])) {
                 $aAttributeNames[$iKey]['value'] = $aAttributeValues[$aAttribute['name']];
             } else {
                 $aAttributeNames[$iKey]['value'] = $aAttribute['default'];
             }
         } else {
             foreach ($aLanguages as $sLanguage) {
                 if (isset($aAttributeValues[$aAttribute['name']][$sLanguage])) {
                     $aAttributeNames[$iKey][$sLanguage]['value'] = $aAttributeValues[$aAttribute['name']][$sLanguage];
                 } else {
                     $aAttributeNames[$iKey][$sLanguage]['value'] = $aAttribute['default'];
                 }
             }
         }
     }
     return $aAttributeNames;
 }
开发者ID:pmaonline,项目名称:limesurvey-quickstart,代码行数:43,代码来源:Questions.php

示例15: do_multiplechoice

function do_multiplechoice($ia)
{
    //// Init variables
    // General variables
    global $thissurvey;
    $kpclass = testKeypad($thissurvey['nokeyboard']);
    // Virtual keyboard (probably obsolete today)
    $inputnames = array();
    // TODO : check if really used
    $checkconditionFunction = "checkconditions";
    // name of the function to check condition TODO : check is used more than once
    $iSurveyId = Yii::app()->getConfig('surveyID');
    // survey id
    $sSurveyLang = $_SESSION['survey_' . $iSurveyId]['s_lang'];
    // survey language
    // Question attribute variables
    $aQuestionAttributes = getQuestionAttributeValues($ia[0]);
    // Question attributes
    $othertext = trim($aQuestionAttributes['other_replace_text'][$sSurveyLang]) != '' ? $aQuestionAttributes['other_replace_text'][$sSurveyLang] : gT('Other:');
    // text for 'other'
    $iNbCols = trim($aQuestionAttributes['display_columns']) != '' ? $aQuestionAttributes['display_columns'] : 1;
    // number of columns
    if ($aQuestionAttributes['other_numbers_only'] == 1) {
        $sSeparator = getRadixPointData($thissurvey['surveyls_numberformat']);
        $sSeparator = $sSeparator['separator'];
        $oth_checkconditionFunction = "fixnum_checkconditions";
    } else {
        $oth_checkconditionFunction = "checkconditions";
    }
    //// Retrieving datas
    // Getting question
    $oQuestion = Question::model()->findByPk(array('qid' => $ia[0], 'language' => $sSurveyLang));
    $other = $oQuestion->other;
    // Getting answers
    $ansresult = $oQuestion->getOrderedSubQuestions($aQuestionAttributes['random_order'], $aQuestionAttributes['exclude_all_others']);
    $anscount = count($ansresult);
    $anscount = $other == 'Y' ? $anscount + 1 : $anscount;
    //COUNT OTHER AS AN ANSWER FOR MANDATORY CHECKING!
    //// Columns containing answer rows, set by user in question attribute
    /// TODO : move to a dedicated function
    // setting variables
    $iMaxRowsByColumn = 0;
    // How many answer rows by column
    $iRowCount = 0;
    $isOpen = false;
    // Is a column opened
    // TODO: check if still used
    if ($iNbCols > 1) {
        // First we calculate the width of each column
        // Max number of column is 12 http://getbootstrap.com/css/#grid
        $iColumnWidth = round(12 / $iNbCols);
        $iColumnWidth = $iColumnWidth >= 1 ? $iColumnWidth : 1;
        $iColumnWidth = $iColumnWidth <= 12 ? $iColumnWidth : 12;
        // Then, we calculate how many answer rows in each column
        $iMaxRowsByColumn = ceil($anscount / $iNbCols);
        $first = true;
        // The very first item will open a bootstrap row containing the columns
    }
    /// Generate answer rows
    $i = 0;
    $sRows = '';
    foreach ($ansresult as $ansrow) {
        $i++;
        // general count of loop, to check if the item is the last one for column process. Never reset.
        $iRowCount++;
        // counter of number of row by column. Is reset to zero each time a column is full.
        $myfname = $ia[1] . $ansrow['title'];
        $extra_class = "";
        /* Check for array_filter */
        $sDisplayStyle = return_display_style($ia, $aQuestionAttributes, $thissurvey, $myfname);
        $checkedState = '';
        /* If the question has already been ticked, check the checkbox */
        if (isset($_SESSION['survey_' . Yii::app()->getConfig('surveyID')][$myfname])) {
            if ($_SESSION['survey_' . Yii::app()->getConfig('surveyID')][$myfname] == 'Y') {
                $checkedState = 'CHECKED';
            }
        }
        $sCheckconditionFunction = $checkconditionFunction . '(this.value, this.name, this.type)';
        $sValue = isset($_SESSION['survey_' . Yii::app()->getConfig('surveyID')][$myfname]) ? $sValue = $_SESSION['survey_' . Yii::app()->getConfig('surveyID')][$myfname] : '';
        $inputnames[] = $myfname;
        ////
        // Open Column
        // The column is opened if user set more than one column in question attribute
        // and if this is the first answer row, or if the column has been closed and the row count reset before.
        if ($iNbCols > 1 && $iRowCount == 1) {
            $sRows .= doRender('/survey/questions/multiplechoice/columns/column_header', array('iColumnWidth' => isset($iColumnWidth) ? $iColumnWidth : '', 'first' => isset($first) ? $first : ''), true);
            $isOpen = true;
            // If a column is not closed, it will be closed at the end of the process
            $first = false;
            // The row containing the column has been opened at the first call.
        }
        ////
        // Insert row
        // Display the answer row
        $sRows .= doRender('/survey/questions/multiplechoice/rows/answer_row', array('extra_class' => $extra_class, 'sDisplayStyle' => $sDisplayStyle, 'name' => $ia[1], 'title' => $ansrow['title'], 'question' => $ansrow['question'], 'ansrow' => $ansrow, 'checkedState' => $checkedState, 'sCheckconditionFunction' => $sCheckconditionFunction, 'myfname' => $myfname, 'sValue' => $sValue), true);
        ////
        // Close column
        // The column is closed if the user set more than one column in question attribute
        // and if the max answer rows by column is reached.
        // If max answer rows by column is not reached while there is no more answer,
//.........这里部分代码省略.........
开发者ID:mfavetti,项目名称:LimeSurvey,代码行数:101,代码来源:qanda_helper.php


注:本文中的getQuestionAttributeValues函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。