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


PHP Survey类代码示例

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


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

示例1: post

 public function post()
 {
     if (!isset($this->get['survey_id'], $this->get['question_id'], $this->post['answer'])) {
         $this->message = "Missing one or more required parameters";
         $this->status = 400;
         return;
     }
     $survey = new Survey($this->get['survey_id']);
     if (!$survey->exists()) {
         $this->message = "Survey does not exist";
         $this->status = 404;
         return;
     }
     $surveyData = $survey->apiData();
     if (!$surveyData['questions'][$this->get['question_id']]) {
         $this->message = "Question does not exist";
         $this->status = 404;
         return;
     }
     if (($answerID = $survey->addAnswer($this->get['question_id'], $this->post['answer'])) === false) {
         $this->message = 'Internal Server Error';
         $this->status = 500;
         return;
     }
     $surveyData = $survey->apiData();
     $this->response[$this->slug][] = $surveyData['questions'][$this->get['question_id']]['answers'][$answerID];
     return;
 }
开发者ID:nickyleach,项目名称:OSTSurvey,代码行数:28,代码来源:AnswersAPIController.php

示例2: watch

    function watch()
    {
        $returnStr = $this->showHeader(Language::messageSMSTitle());
        $returnStr .= $this->displayComboBox();
        $returnStr .= "<form method='post'>";
        $params = getSessionParams();
        //$params['reportpage'] = 'reportRes';
        $returnStr .= setSessionParamsPost($params);
        $returnStr .= '<div id="wrap">';
        $returnStr .= '<div class="container"><p>';
        $returnStr .= '<div class="panel panel-default">
                <div class="panel-heading">';
        $returnStr .= '<h4>' . Language::linkWatch() . '</h4>';
        $returnStr .= '                </div>
                <div class="panel-body">';
        require_once 'data.php';
        require_once 'display.php';
        $data = new Data();
        $values = $data->getRespondentData(getFromSessionParams('watchsuid'), getFromSessionParams('watchprimkey'));
        $returnStr .= '</div>
    <div role="panel" class="panel">';
        if (sizeof($values) == 0) {
            $returnStr .= "<br/>" . '<div class="alert alert-warning">' . Language::labelWatchNoData() . '</div>';
        } else {
            $returnStr .= $this->displayDataTablesScripts(array("colvis", "rowreorder"));
            $returnStr .= "<script type='text/javascript'>\n                        \$(document).ready(function(){\n                            \$('#issuetable').dataTable(\n                                {\n                                    \"iDisplayLength\": 5,\n                                    dom: 'C<\"clear\">lfrtip',\n                                    searching: false,\n                                    paging: true\n                                    }    \n                                );\n                                         \n                       });</script>\n\n                        ";
            //
            $returnStr .= "<br/><table id='issuetable' class='table table-bordered table-striped'><thead>";
            $returnStr .= "<th>" . Language::labelWatchVariable() . "</th><th>" . Language::labelWatchValue() . "</th><th>" . Language::labelWatchClean() . "</th><th>" . Language::labelWatchMode() . "</th><th>" . Language::labelWatchLanguage() . "</th><th>" . Language::labelWatchTime() . "</th></tr>";
            $returnStr .= "</thead><tbody>";
            $modes = Common::surveyModes();
            $languages = Language::getLanguagesArray();
            $sesid = session_id();
            require_once 'object.php';
            require_once 'component.php';
            require_once 'setting.php';
            require_once 'type.php';
            require_once 'variabledescriptive.php';
            $survey = new Survey(getFromSessionParams('watchsuid'));
            foreach ($values as $is) {
                $returnStr .= "<tr>";
                $returnStr .= "<td>" . $is["variablename"] . "</td>";
                $returnStr .= "<td>" . $this->getDisplayValue($survey->getVariableDescriptiveByName($is["variablename"]), $is["answer_dec"]) . "</td>";
                $returnStr .= "<td>" . $this->displayDirty([$is["dirty"]]) . "</td>";
                $returnStr .= "<td>" . $modes[$is["mode"]] . "</td>";
                $returnStr .= "<td>" . $languages[str_replace("_", "", getSurveyLanguagePostFix($is["language"]))]['name'] . "</td>";
                $returnStr .= "<td>" . $is["ts"] . "</td>";
                $returnStr .= "</tr>";
            }
            $returnStr .= "</tbody></table>";
        }
        $returnStr .= '</div>
  </div>
</div>';
        $returnStr .= '                </div></div>';
        $returnStr .= '</p></div>    </div>';
        //container and wrap
        $returnStr .= $this->showFooter(false);
        echo $returnStr;
    }
开发者ID:nubissurveying,项目名称:nubis,代码行数:60,代码来源:watchwindow.php

示例3: buildDomainObject

 /**
  * Builds a domain object from a DB row.
  * Must be overridden by child classes.
  */
 protected function buildDomainObject($row)
 {
     $survey = new Survey();
     $survey->setIdSurvey($row['id_sondage']);
     $survey->setLibelle($row['libelle']);
     return $survey;
 }
开发者ID:jdelvecchio,项目名称:forms,代码行数:11,代码来源:SurveyDAO.php

示例4: build

 /**
  * @param ISurveyTemplate $template
  * @param  $owner
  * @return ISurvey
  */
 public function build(ISurveyTemplate $template, $owner)
 {
     $survey = new Survey();
     $survey->TemplateID = $template->getIdentifier();
     $survey->CreatedByID = $owner->getIdentifier();
     $i = 0;
     foreach ($template->getSteps() as $step_template) {
         ++$i;
         $new_step = null;
         if ($step_template instanceof SurveyDynamicEntityStepTemplate) {
             $new_step = new SurveyDynamicEntityStep();
         } else {
             if ($step_template instanceof SurveyRegularStepTemplate) {
                 $new_step = new SurveyRegularStep();
             } else {
                 $new_step = new SurveyStep();
             }
         }
         $new_step->TemplateID = $step_template->getIdentifier();
         $survey->addStep($new_step);
         if ($i == 1) {
             $survey->registerCurrentStep($new_step);
             $survey->registerAllowedMaxStep($new_step);
         }
     }
     return $survey;
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:32,代码来源:SurveyBuilder.php

示例5: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $survey = new Survey();
     $survey->name = 'ibSurvey';
     $survey->school_id = 1;
     $survey->save();
 }
开发者ID:AlexLeung,项目名称:ibsurvey,代码行数:12,代码来源:seedSurveyTable.php

示例6: run

	/**
	 * Traite les données envoyées par le formulaire d'ajout de sondage.
	 *
	 * Si l'utilisateur n'est pas connecté, un message lui demandant de se connecter est affiché.
	 *
	 * Sinon, la fonction ajoute le sondage à la base de données. Elle transforme
	 * les réponses et la question à l'aide de la fonction PHP 'htmlentities' pour éviter
	 * que du code exécutable ne soit inséré dans la base de données et affiché par la suite.
	 *
	 * Un des messages suivants doivent être affichés à l'utilisateur :
	 * - "La question est obligatoire.";
	 * - "Il faut saisir au moins 2 réponses.";
	 * - "Merci, nous avons ajouté votre sondage.".
	 *
	 * Le visiteur est finalement envoyé vers le formulaire d'ajout de sondage en cas d'erreur
	 * ou vers une vue affichant le message "Merci, nous avons ajouté votre sondage.".
	 * 
	 * @see Action::run()
	 */
	public function run() {
	
	if ($this->getSessionLogin()===null) {
			$this->setMessageView("Vous devez être authentifié.", "alert-error");
			return;
		}
		

	       $question = htmlentities($_POST['questionSurvey']);
	  
			$reponse1 = htmlentities ($_POST['responseSurvey1']);
			$reponse2 = htmlentities ($_POST['responseSurvey2']);
  			$reponse3 = htmlentities ($_POST['responseSurvey3']);
	  		$reponse4 = htmlentities ($_POST['responseSurvey4']);
   		    $reponse5 = htmlentities ($_POST['responseSurvey5']);
   
  			$reponse = array($reponse1 ,$reponse2, $reponse3, $reponse4, $reponse5);
   
   	if(!isset($question) || trim($question)===''){
			$this->setAddSurveyFormView("La question est obligatoire !");
			return false;
   	}
  
  		$compteur = 0;
  
  		for($i = 0; $i < 5 ; $i++){
  			if(empty($reponse[$i]))
  		 	$compteur = $compteur+1;
     }
   
   
  		if($compteur > 3){
						$this->setAddSurveyFormView("Il faut saisir au moins 2 réponses");
			return;
  		}else{
  
   			$owner = $this->getSessionLogin();
   			$survey = new Survey($owner, $question);
   
   			$this->setMessageView("Merci, nous avons ajouté votre sondage.", "alert-success");
   
	 	for($i = 0; $i < 5 ; $i++){
			if(!empty($reponse[$i]))
				 $survey->addResponse(new Response($survey,$reponse[$i], 0));
	 	}
	 
      	$query = $this->database->saveSurvey($survey);
      
    	if(!$query){ 
     		$this->setAddSurveyFormView("Erreur lors de l'ajout de votre sondage dans la base de données.");
  	 		return false;
  	 	}
   }
   
	
  }
开发者ID:amirdine,项目名称:academic-projects,代码行数:75,代码来源:AddSurveyAction.inc.php

示例7: create

 public static function create($name, $userID)
 {
     $survey = new Survey();
     $survey->name = $name;
     $survey->ownerID = $userID;
     $survey->save();
     $user = $survey->owner();
     $user->addSurvey($survey->id);
     return $survey->id;
 }
开发者ID:nickyleach,项目名称:OSTSurvey,代码行数:10,代码来源:Survey.php

示例8: execute

 public function execute()
 {
     global $wgUser;
     if (!$wgUser->isAllowed('surveyadmin') || $wgUser->isBlocked()) {
         $this->dieUsageMsg(array('badaccess-groups'));
     }
     $params = $this->extractRequestParams();
     $everythingOk = true;
     foreach ($params['ids'] as $id) {
         $surey = new Survey(array('id' => $id));
         $everythingOk = $surey->removeFromDB() && $everythingOk;
     }
     $this->getResult()->addValue(null, 'success', $everythingOk);
 }
开发者ID:yusufchang,项目名称:app,代码行数:14,代码来源:ApiDeleteSurvey.php

示例9: remove

 public function remove()
 {
     if (!$this->exists()) {
         return false;
     }
     // Remove all of the user's surveys
     foreach ($this->surveys as $surveyID) {
         $survey = new Survey($surveyID);
         $survey->remove();
     }
     // And the container which references them
     Redis::del("User:{$this->id}:surveys");
     // And the username-userid reference
     Redis::set("User:username:{$this->username}");
     parent::remove();
 }
开发者ID:nickyleach,项目名称:OSTSurvey,代码行数:16,代码来源:User.php

示例10: getQuestionObj

 /**
  * Returns the SurveyQuestion for $this->getQuestionIndex()
  * @return null|SurveyQuestion
  */
 public function getQuestionObj()
 {
     if ($this->questionIndex >= count($this->survey->getQuestions())) {
         return null;
     }
     return $this->survey->getQuestions()[$this->questionIndex];
 }
开发者ID:sarhanm,项目名称:sms-survey,代码行数:11,代码来源:SurveyState.php

示例11: execute

 public function execute()
 {
     global $wgUser;
     if (!$wgUser->isAllowed('surveysubmit') || $wgUser->isBlocked()) {
         $this->dieUsageMsg(array('badaccess-groups'));
     }
     $params = $this->extractRequestParams();
     if (!(isset($params['id']) xor isset($params['name']))) {
         $this->dieUsage(wfMsg('survey-err-id-xor-name'), 'id-xor-name');
     }
     if (isset($params['name'])) {
         $survey = Survey::newFromName($params['name'], null, false);
         if ($survey === false) {
             $this->dieUsage(wfMsgExt('survey-err-survey-name-unknown', 'parsemag', $params['name']), 'survey-name-unknown');
         }
     } else {
         $survey = Survey::newFromId($params['id'], null, false);
         if ($survey === false) {
             $this->dieUsage(wfMsgExt('survey-err-survey-id-unknown', 'parsemag', $params['id']), 'survey-id-unknown');
         }
     }
     $submission = new SurveySubmission(array('survey_id' => $survey->getId(), 'page_id' => 0, 'user_name' => $GLOBALS['wgUser']->getName(), 'time' => wfTimestampNow()));
     foreach (FormatJson::decode($params['answers']) as $answer) {
         $submission->addAnswer(SurveyAnswer::newFromArray((array) $answer));
     }
     $submission->writeToDB();
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:27,代码来源:ApiSubmitSurvey.php

示例12: actionPublicList

 public function actionPublicList($lang = null)
 {
     if (!empty($lang)) {
         App()->setLanguage($lang);
     } else {
         App()->setLanguage(App()->getConfig('defaultlang'));
     }
     $oTemplate = Template::model()->getInstance(Yii::app()->getConfig("defaulttemplate"));
     if ($oTemplate->cssFramework == 'bootstrap') {
         // We now use the bootstrap package isntead of the Yiistrap TbApi::register() method
         // Then instead of using the composer dependency system for templates
         // We can use the package dependency system
         Yii::app()->getClientScript()->registerMetaTag('width=device-width, initial-scale=1.0', 'viewport');
         App()->bootstrap->registerAllScripts();
     }
     $aData = array('publicSurveys' => Survey::model()->active()->open()->public()->with('languagesettings')->findAll(), 'futureSurveys' => Survey::model()->active()->registration()->public()->with('languagesettings')->findAll());
     $htmlOut = $this->render('publicSurveyList', $aData, true);
     $event = new PluginEvent('beforeSurveysStartpageRender', $this);
     $event->set('aData', $aData);
     App()->getPluginManager()->dispatchEvent($event);
     if ($event->get('result')) {
         $htmlFromEvent = $event->get('result');
         $htmlOut = $htmlFromEvent['html'];
     }
     echo $htmlOut;
 }
开发者ID:mfavetti,项目名称:LimeSurvey,代码行数:26,代码来源:SurveysController.php

示例13: actionPublicList

 public function actionPublicList($sLanguage = null)
 {
     if (isset($sLanguage)) {
         App()->setLanguage($sLanguage);
     }
     $this->render('publicSurveyList', array('publicSurveys' => Survey::model()->active()->open()->public()->with('languagesettings')->findAll(), 'futureSurveys' => Survey::model()->active()->registration()->public()->with('languagesettings')->findAll()));
 }
开发者ID:krsandesh,项目名称:LimeSurvey,代码行数:7,代码来源:SurveysController.php

示例14: run

 public function run()
 {
     App()->loadHelper('surveytranslator');
     $aData['issuperadmin'] = false;
     if (Permission::model()->hasGlobalPermission('superadmin', 'read')) {
         $aData['issuperadmin'] = true;
     }
     // We get the last survey visited by user
     $setting_entry = 'last_survey_' . Yii::app()->user->getId();
     $lastsurvey = getGlobalSetting($setting_entry);
     $survey = Survey::model()->findByPk($lastsurvey);
     if ($lastsurvey != null && $survey) {
         $aData['showLastSurvey'] = true;
         $iSurveyID = $lastsurvey;
         $surveyinfo = $survey->surveyinfo;
         $aData['surveyTitle'] = $surveyinfo['surveyls_title'] . "(" . gT("ID") . ":" . $iSurveyID . ")";
         $aData['surveyUrl'] = $this->getController()->createUrl("admin/survey/sa/view/surveyid/{$iSurveyID}");
     } else {
         $aData['showLastSurvey'] = false;
     }
     // We get the last question visited by user
     $setting_entry = 'last_question_' . Yii::app()->user->getId();
     $lastquestion = getGlobalSetting($setting_entry);
     // the question group of this question
     $setting_entry = 'last_question_gid_' . Yii::app()->user->getId();
     $lastquestiongroup = getGlobalSetting($setting_entry);
     // the sid of this question : last_question_sid_1
     $setting_entry = 'last_question_sid_' . Yii::app()->user->getId();
     $lastquestionsid = getGlobalSetting($setting_entry);
     $survey = Survey::model()->findByPk($lastquestionsid);
     if ($lastquestion && $lastquestiongroup && $survey) {
         $baselang = $survey->language;
         $aData['showLastQuestion'] = true;
         $qid = $lastquestion;
         $gid = $lastquestiongroup;
         $sid = $lastquestionsid;
         $qrrow = Question::model()->findByAttributes(array('qid' => $qid, 'gid' => $gid, 'sid' => $sid, 'language' => $baselang));
         if ($qrrow) {
             $aData['last_question_name'] = $qrrow['title'];
             if ($qrrow['question']) {
                 $aData['last_question_name'] .= ' : ' . $qrrow['question'];
             }
             $aData['last_question_link'] = $this->getController()->createUrl("admin/questions/sa/view/surveyid/{$sid}/gid/{$gid}/qid/{$qid}");
         } else {
             $aData['showLastQuestion'] = false;
         }
     } else {
         $aData['showLastQuestion'] = false;
     }
     $aData['countSurveyList'] = count(getSurveyList(true));
     // We get the home page display setting
     $aData['bShowSurveyList'] = getGlobalSetting('show_survey_list') == "show";
     $aData['bShowSurveyListSearch'] = getGlobalSetting('show_survey_list_search') == "show";
     $aData['bShowLogo'] = getGlobalSetting('show_logo') == "show";
     $aData['oSurveySearch'] = new Survey('search');
     $aData['bShowLastSurveyAndQuestion'] = getGlobalSetting('show_last_survey_and_question') == "show";
     $aData['iBoxesByRow'] = (int) getGlobalSetting('boxes_by_row');
     $aData['sBoxesOffSet'] = (string) getGlobalSetting('boxes_offset');
     $this->_renderWrappedTemplate('super', 'welcome', $aData);
 }
开发者ID:mfavetti,项目名称:LimeSurvey,代码行数:60,代码来源:index.php

示例15: index

 function index()
 {
     $posts = $this->request->postVars();
     $filename = $posts['filename'];
     $surveyID = intval($posts['surveyID']);
     if (!$filename || !Member::currentUser() || !$surveyID || !($Survey = Survey::get()->filter('ID', $surveyID)->first())) {
         return false;
     }
     $folder = Folder::find_or_make('jsonFormFiles');
     $fullFileName = Director::baseFolder() . '/' . $folder->getRelativePath() . $filename . '.json';
     $jsonString = '{"name":"' . $Survey->Name . '","startDate": "' . $Survey->StartDate . '", "endDate": "' . $Survey->EndDate . '","sections": [';
     foreach ($Survey->Sections() as $Section) {
         $jsonString .= '{"Title": "' . $Section->Title . '","Descripton": "' . $Section->Description . '","sectionQuestions": [';
         foreach ($Section->SurveyQuestions() as $SQ) {
             $jsonString .= '{"number": "' . $SQ->Number . '","title": "' . $SQ->Title . '","description":"' . $SQ->Description . '","helpText": "' . $SQ->HelpText . '","questions": [';
             foreach ($SQ->Questions() as $Question) {
                 $jsonString .= $Question->renderJson();
             }
             $jsonString = rtrim($jsonString, ",");
             $jsonString .= ']},';
         }
         $jsonString = rtrim($jsonString, ",");
         $jsonString .= ']},';
     }
     $jsonString = rtrim($jsonString, ",");
     $jsonString .= ']}';
     file_put_contents($fullFileName, $jsonString);
     $Survey->LastJsonGenerated = SS_Datetime::now()->getValue();
     $Survey->write();
 }
开发者ID:helpfulrobot,项目名称:cbarberis-silverstripe-surveys,代码行数:30,代码来源:JsonFileGenerator.php


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