X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fsurvey%2Fsurvey.inc.php;h=168a2261b4ec691dfda696d93f66f3516c0efbc5;hb=cd129064288dd23aa99e22adefe3c1900cf912d7;hp=f1f8fe54edc3a7a3952c06fbdf1a6652474bfc4c;hpb=4b8c8634135be601c610e69322bd9b5e95680f73;p=platal.git diff --git a/modules/survey/survey.inc.php b/modules/survey/survey.inc.php index f1f8fe5..168a226 100644 --- a/modules/survey/survey.inc.php +++ b/modules/survey/survey.inc.php @@ -41,8 +41,7 @@ class Survey 'textarea' => 'texte long', 'num' => 'numérique', 'radio' => 'radio', - 'checkbox' => 'checkbox', - 'personal' => 'informations personnelles'); + 'checkbox' => 'checkbox'); public static function getTypes() { @@ -82,8 +81,8 @@ class Survey } else { $this->end = (preg_match('#^\d{4}-\d{2}-\d{2}$#', $args['end']))? $args['end'] : '#'; } - $this->mode = $args['mode']; - if ($args['mode'] == 0) { + $this->mode = (isset($args['mode']))? $args['mode'] : self::MODE_ALL; + if ($this->mode == self::MODE_ALL) { $args['promos'] = ''; } $this->promos = ($args['promos'] == '' || preg_match('#^(\d{4}-?|(\d{4})?-\d{4})(,(\d{4}-?|(\d{4})?-\d{4}))*$#', $args['promos']))? $args['promos'] : '#'; @@ -266,6 +265,7 @@ class Survey // {{{ questions manipulation functions public function addQuestion($i, $c) { + $i = intval($i); if ($this->valid || $i > count($this->questions)) { return false; } else { @@ -276,6 +276,7 @@ class Survey public function delQuestion($i) { + $i = intval($i); if ($this->valid || !array_key_exists($i, $this->questions)) { return false; } else { @@ -684,45 +685,5 @@ class SurveyCheckbox extends SurveyList // }}} // }}} -// {{{ class SurveyPersonal extends SurveyQuestion : allows easy and verified access to user's personal data (promotion, name...) -// actually this type of question should be suppressed (non anonymous surveys are possible with survey modes) -// and anyway it is not finished (checkAnswer implementation) : currently it does not store anything when a user votes -class SurveyPersonal extends SurveyQuestion -{ - private $perm; - - public function update($args) - { - $args['question'] = "Informations personnelles"; - parent::update($args); - $this->perm['promo'] = isset($args['promo'])? 1 : 0; - $this->perm['name'] = isset($args['name'])? 1 : 0; - } - - public function checkAnswer($ans) - { - if (intval($ans) == 1) { - // requete mysql qvb - return null; - } else { - return null; - } - } - - protected function getQuestionType() - { - return "personal"; - } - - public function toArray() - { - $a = parent::toArray(); - $a['promo'] = $this->perm['promo']; - $a['name'] = $this->perm['name']; - return $a; - } -} -// }}} - // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: ?>