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;
 }
Example #2
0
    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;
    }
Example #3
0
 /**
  * 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;
 }
 /**
  * @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;
 }
Example #5
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $survey = new Survey();
     $survey->name = 'ibSurvey';
     $survey->school_id = 1;
     $survey->save();
 }
	/**
	 * 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;
  	 	}
   }
   
	
  }
Example #7
0
 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;
 }
Example #8
0
 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);
 }
Example #9
0
 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();
 }
Example #10
0
 /**
  * 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];
 }
Example #11
0
 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();
 }
Example #12
0
 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;
 }
 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()));
 }
Example #14
0
 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);
 }
Example #15
0
 public function __construct()
 {
     if (!self::$mysqli) {
         error_reporting(0);
         self::$mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
     }
 }
 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();
 }
Example #17
0
 /**
  * Routes to the correct sub-action
  *
  * @access public
  * @param int $iSurveyID
  * @return void
  */
 public function index($iSurveyID)
 {
     $iSurveyID = sanitize_int($iSurveyID);
     $sAction = Yii::app()->request->getPost('action');
     $languages = Survey::model()->findByPk($iSurveyID)->additionalLanguages;
     $surveyLanguage = Survey::model()->findByPk($iSurveyID)->language;
     Yii::app()->session['FileManagerContext'] = "edit:assessments:{$iSurveyID}";
     array_unshift($languages, $surveyLanguage);
     // makes an array with ALL the languages supported by the survey -> $assessmentlangs
     Yii::app()->setConfig("baselang", $surveyLanguage);
     Yii::app()->setConfig("assessmentlangs", $languages);
     if ($sAction == "assessmentadd") {
         $this->_add($iSurveyID);
     }
     if ($sAction == "assessmentupdate") {
         $this->_update($iSurveyID);
     }
     if ($sAction == "assessmentdelete") {
         $this->_delete($iSurveyID, $_POST['id']);
     }
     if (Permission::model()->hasSurveyPermission($iSurveyID, 'assessments', 'read')) {
         if ($iSurveyID == '') {
             show_error(gT("No SID Provided"));
             die;
         }
         $this->_showAssessments($iSurveyID, $sAction, $surveyLanguage);
     }
 }
 function SurveyDetails()
 {
     $params = $this->owner->request->allParams();
     $deployment_id = intval(Convert::raw2sql($params["ID"]));
     $range = Session::get("global_survey_range");
     //get survey version
     if (!empty($range) && $range === SurveyType::FALL_2015) {
         $survey = Survey::get()->byID($deployment_id);
         if ($survey->ClassName === 'EntitySurvey') {
             $survey = EntitySurvey::get()->byID($deployment_id);
         }
     } else {
         $survey = DeploymentSurvey::get()->byID($deployment_id);
     }
     if ($survey) {
         $back_url = $this->owner->request->getVar('BackUrl');
         if ($survey instanceof Survey) {
             $details_template = 'SangriaPage_SurveyBuilderSurveyDetails';
             $data = array("Survey" => $survey, "BackUrl" => $back_url);
         } else {
             $details_template = $survey->getSurveyType() == SurveyType::OLD ? "SangriaPage_SurveyDetailsOld" : "SangriaPage_SurveyDetails";
             $data = array("Survey" => $survey, "BackUrl" => $back_url);
         }
         if (empty($back_url)) {
             $back_url = "#";
         }
         return $this->owner->Customise($data)->renderWith(array($details_template, 'SangriaPage', 'SangriaPage'));
     }
     return $this->owner->httpError(404, 'Sorry that Survey could not be found!.');
 }
 /**
  * Check the Expression in quota
  * @param integer $iSurveyId : the survey id : can be sid/surveyid url GET parameters
  * @param integer $quota : the quota id
  * @param string $lang : the survey language, optional : if not set get all language of survey
  * 
  * @author Denis Chenu
  * @version 1.0
  */
 public function quota($iSurveyId, $quota, $lang = null)
 {
     if (!Permission::model()->hasSurveyPermission($iSurveyId, 'quotas', 'read')) {
         throw new CHttpException(401, "401 Unauthorized");
     }
     $iQuotaId = $quota;
     if (is_string($lang)) {
         $oValidator = new LSYii_Validators();
         $aLangs = array($oValidator->languageFilter($lang));
     } else {
         $aLangs = Survey::model()->findByPk($iSurveyId)->getAllLanguages();
     }
     $aExpressions = array();
     $this->iSurveyId = $iSurveyId;
     foreach ($aLangs as $sLang) {
         $oQuotaLanguageSetting = QuotaLanguageSetting::model()->find("quotals_quota_id =:quota_id and quotals_language=:language", array(':quota_id' => $iQuotaId, ':language' => $sLang));
         // We don't need to go to step since new feature #8823, maybe need to be fixed ?
         if ($oQuotaLanguageSetting) {
             $this->sLang = $sLang;
             $aExpressions['name_' . $sLang] = array('title' => sprintf("Quota name (%s)", $sLang), 'expression' => $this->getHtmlExpression($oQuotaLanguageSetting->quotals_name, array(), __METHOD__));
             $aExpressions['message_' . $sLang] = array('title' => sprintf("Quota message (%s)", $sLang), 'expression' => $this->getHtmlExpression($oQuotaLanguageSetting->quotals_message, array(), __METHOD__));
             $aExpressions['url_' . $sLang] = array('title' => sprintf("URL (%s)", $sLang), 'expression' => $this->getHtmlExpression($oQuotaLanguageSetting->quotals_url, array(), __METHOD__));
             $aExpressions['urldescrip_' . $sLang] = array('title' => sprintf("URL description (%s)", $sLang), 'expression' => $this->getHtmlExpression($oQuotaLanguageSetting->quotals_urldescrip, array(), __METHOD__));
         }
     }
     $aData = array('aExpressions' => $aExpressions);
     $this->getController()->layout = $this->layout;
     $this->getController()->pageTitle = gt("Validate quota");
     $this->getController()->render("/admin/expressions/validationList", $aData);
 }
 public static function sandbox()
 {
     // Testaa koodiasi täällä
     $eka = Survey::find(1);
     $kaikki = Survey::all();
     Kint::dump($eka);
     Kint::dump($kaikki);
 }
 public function delete($id)
 {
     $survey = new Survey($id);
     if (!$survey->exists()) {
         $this->message = "Survey not found";
         $this->status = 404;
         return;
     }
     if ($survey->ownerID != Session::$user['id']) {
         $this->message = "Unauthorized";
         $this->status = 403;
         return;
     }
     $survey->remove();
     $this->message = "Survey removed";
     $this->status = 204;
 }
 public function actionPublicList($lang = null)
 {
     $this->sessioncontrol();
     if (isset($lang)) {
         App()->setLang(new Limesurvey_lang($lang));
     }
     $this->render('publicSurveyList', array('publicSurveys' => Survey::model()->active()->open()->public()->with('languagesettings')->findAll(), 'futureSurveys' => Survey::model()->active()->registration()->public()->with('languagesettings')->findAll()));
 }
Example #23
0
 /**
  * Displays surveys.
  * 
  * @since 0.1
  */
 protected function displaySurveys()
 {
     $this->displayAddNewControl();
     $surveys = Survey::select(array('id', 'name', 'enabled', 'title'));
     if (count($surveys) > 0) {
         $this->displaySurveysTable($surveys);
     }
     $this->addModules('ext.survey.special.surveys');
 }
 public function actionPublicList($lang = null)
 {
     if (!empty($lang)) {
         App()->setLanguage(sanitize_languagecode($lang));
     } else {
         App()->setLanguage(App()->getConfig('defaultlang'));
     }
     $this->render('publicSurveyList', array('publicSurveys' => Survey::model()->active()->open()->public()->with('languagesettings')->findAll(), 'futureSurveys' => Survey::model()->active()->registration()->public()->with('languagesettings')->findAll()));
 }
Example #25
0
 public function createSurvey()
 {
     $this->validateSubtopicContent();
     $name = trim($this->data->name);
     if (empty($name)) {
         throw new \InvalidArgumentException("Debes enviar un nombre valido para la encuesta, debe contener entre 2 y 80 caracteres");
     }
     $survey = new \Survey();
     $survey->idAccount = 1;
     $survey->wizardOption = "draft";
     $survey->name = $name;
     $survey->idSubtopicContent = $this->data->subtopicContent;
     if (!$survey->save()) {
         foreach ($survey->getMessages() as $msg) {
             $this->logger->log("Error while saving survey draft: {$msg}");
         }
         throw new \InvalidArgumentException("Ocurrió un error mientras se guardaba la encuenta: {$msg}}");
     }
 }
Example #26
0
 function getLocalGroupsArray()
 {
     $localGroupsArray = array();
     try {
         $localGroupsArray = unserialize(parent::getLocalGroups());
     } catch (Exception $exc) {
         $error = new Error($exc->getMessage());
         $error->writeLog();
     }
     return $localGroupsArray;
 }
Example #27
0
 function actionLocal($surveyid, $token, $langcode = '')
 {
     Yii::app()->loadHelper('database');
     Yii::app()->loadHelper('sanitize');
     $sLanguageCode = $langcode;
     $iSurveyID = $surveyid;
     $sToken = $token;
     $sToken = sanitize_token($sToken);
     if (!$iSurveyID) {
         $this->redirect($this->getController()->createUrl('/'));
     }
     $iSurveyID = (int) $iSurveyID;
     //Check that there is a SID
     // Get passed language from form, so that we dont loose this!
     if (!isset($sLanguageCode) || $sLanguageCode == "" || !$sLanguageCode) {
         $baselang = Survey::model()->findByPk($iSurveyID)->language;
         Yii::import('application.libraries.Limesurvey_lang', true);
         $clang = new Limesurvey_lang($baselang);
     } else {
         $sLanguageCode = sanitize_languagecode($sLanguageCode);
         Yii::import('application.libraries.Limesurvey_lang', true);
         $clang = new Limesurvey_lang($sLanguageCode);
         $baselang = $sLanguageCode;
     }
     Yii::app()->lang = $clang;
     $thissurvey = getSurveyInfo($iSurveyID, $baselang);
     if ($thissurvey == false || Yii::app()->db->schema->getTable("{{tokens_{$iSurveyID}}}") == null) {
         $html = $clang->gT('This survey does not seem to exist.');
     } else {
         $row = Tokens_dynamic::getEmailStatus($iSurveyID, $sToken);
         if ($row == false) {
             $html = $clang->gT('You are not a participant in this survey.');
         } else {
             $usresult = $row['emailstatus'];
             if ($usresult == 'OptOut') {
                 $usresult = Tokens_dynamic::updateEmailStatus($iSurveyID, $sToken, 'OK');
                 $html = $clang->gT('You have been successfully added back to this survey.');
             } else {
                 if ($usresult == 'OK') {
                     $html = $clang->gT('You are already a part of this survey.');
                 } else {
                     $html = $clang->gT('You have been already removed from this survey.');
                 }
             }
         }
     }
     //PRINT COMPLETED PAGE
     if (!$thissurvey['templatedir']) {
         $thistpl = getTemplatePath(Yii::app()->getConfig("defaulttemplate"));
     } else {
         $thistpl = getTemplatePath($thissurvey['templatedir']);
     }
     $this->_renderHtml($html, $thistpl, $clang);
 }
 /**
  * Load your component.
  * 
  * @param \Cx\Core\ContentManager\Model\Entity\Page $page       The resolved page
  */
 public function load(\Cx\Core\ContentManager\Model\Entity\Page $page)
 {
     global $_CORELANG, $subMenuTitle, $objTemplate;
     switch ($this->cx->getMode()) {
         case \Cx\Core\Core\Controller\Cx::MODE_FRONTEND:
             $objSurvey = new Survey(\Env::get('cx')->getPage()->getContent());
             \Env::get('cx')->getPage()->setContent($objSurvey->getPage());
             break;
         case \Cx\Core\Core\Controller\Cx::MODE_BACKEND:
             $this->cx->getTemplate()->addBlockfile('CONTENT_OUTPUT', 'content_master', 'LegacyContentMaster.html');
             $objTemplate = $this->cx->getTemplate();
             \Permission::checkAccess(111, 'static');
             $subMenuTitle = $_CORELANG['TXT_SURVEY'];
             $objSurvey = new SurveyManager();
             $objSurvey->getPage();
             break;
         default:
             break;
     }
 }
Example #29
0
 private function _getData($params)
 {
     if (is_numeric($params)) {
         $iSurveyId = $params;
     } elseif (is_array($params)) {
         extract($params);
     }
     $aData = array();
     // Set the variables in an array
     $aData['surveyid'] = $aData['iSurveyId'] = (int) $iSurveyId;
     if (!empty($iId)) {
         $aData['iId'] = (int) $iId;
     }
     $aData['clang'] = $clang = $this->getController()->lang;
     $aData['imageurl'] = Yii::app()->getConfig('imageurl');
     $aData['action'] = Yii::app()->request->getParam('action');
     $aData['all'] = Yii::app()->request->getParam('all');
     $oCriteria = new CDbCriteria();
     $oCriteria->select = 'sid, active';
     $oCriteria->join = 'INNER JOIN {{surveys_languagesettings}} as b on (b.surveyls_survey_id=sid and b.surveyls_language=language)';
     $oCriteria->condition = 'sid=:survey';
     $oCriteria->params = array('survey' => $iSurveyId);
     $actresult = Survey::model()->findAll($oCriteria);
     if (count($actresult) > 0) {
         foreach ($actresult as $actrow) {
             if ($actrow['active'] == 'N') {
                 Yii::app()->session['flashmessage'] = $clang->gT("This survey has not been activated. There are no results to browse.");
                 $this->getController()->redirect($this->getController()->createUrl("/admin/survey/sa/view/surveyid/{$iSurveyId}"));
             }
         }
     } else {
         Yii::app()->session['flashmessage'] = $clang->gT("Invalid survey ID");
         $this->getController()->redirect($this->getController()->createUrl("admin/index"));
     }
     //OK. IF WE GOT THIS FAR, THEN THE SURVEY EXISTS AND IT IS ACTIVE, SO LETS GET TO WORK.
     $aData['surveyinfo'] = getSurveyInfo($iSurveyId);
     if (isset($browselang) && $browselang != '') {
         Yii::app()->session['browselang'] = $browselang;
         $aData['language'] = Yii::app()->session['browselang'];
     } elseif (isset(Yii::app()->session['browselang'])) {
         $aData['language'] = Yii::app()->session['browselang'];
         $aData['languagelist'] = $languagelist = Survey::model()->findByPk($iSurveyId)->additionalLanguages;
         $aData['languagelist'][] = Survey::model()->findByPk($iSurveyId)->language;
         if (!in_array($aData['language'], $languagelist)) {
             $aData['language'] = Survey::model()->findByPk($iSurveyId)->language;
         }
     } else {
         $aData['language'] = Survey::model()->findByPk($iSurveyId)->language;
     }
     $aData['qulanguage'] = Survey::model()->findByPk($iSurveyId)->language;
     $aData['surveyoptions'] = '';
     $aData['browseoutput'] = '';
     return $aData;
 }
 protected static function load_survey($id = null)
 {
     if (!$id) {
         $id = $_GET['survey_id'];
     }
     $object = Survey::find_by_id($id);
     if ($object) {
         return $object;
     } else {
         throw new Error404();
     }
 }