X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;ds=sidebyside;f=modules%2Fsurvey%2Fsurvey.inc.php;h=7e715fd9fbc9d481c91212a2d34b0db63795b86f;hb=6c21094e45512da7fb1321a1df4335b1d48ed9bd;hp=3812d2e41640c6f55623381663cb8c8992d7b87f;hpb=b86e9a57515f7683112b917e8b235650759e93ec;p=platal.git diff --git a/modules/survey/survey.inc.php b/modules/survey/survey.inc.php index 3812d2e..7e715fd 100644 --- a/modules/survey/survey.inc.php +++ b/modules/survey/survey.inc.php @@ -1,6 +1,6 @@ fetchQuestions = true; + $this->questions = array(); + } + public function addQuestion(SurveyQuestion $question, $pos = null) { $question->parent = null; @@ -156,13 +162,24 @@ class Survey extends PlDBTableEntry implements SurveyQuestionContainer public function export() { $export = parent::export(); - $export['questions'] = array(); + $export['questions'] = $this->exportQuestions(); + return $export; + } + + public function exportQuestions() + { + $export = array(); foreach ($this->questions as $question) { - $export['questions'][] = $question->export(); + $export[] = $question->export(); } return $export; } + public function exportQuestionsToJSON() + { + return json_encode($this->exportQuestions()); + } + /* Return an indicator of the progression of the survey: * negative values means 'the survey is not started' * 0 means 'the survey is in progress'