Implemented SurveyChoice object

This commit is contained in:
Pierre
2018-04-22 08:31:34 +02:00
parent e3f3f8e516
commit 22f8ab582c
3 changed files with 34 additions and 11 deletions

View File

@ -103,9 +103,32 @@ class SurveysController {
$data["creation_time"] = $survey->get_time_sent();
$data["question"] = $survey->get_question();
$data["user_choice"] = $survey->get_user_choice();
$data["choices"] = $survey->get_choices();
//Process survey choices
$data["choices"] = array();
foreach($survey->get_choices() as $choice)
$data["choices"][$choice->get_id()] = self::SurveyChoiceToAPI($choice);
return $data;
}
/**
* Turn a SurveyChoice object into an API array
*
* @param SurveyChoice $choice The choice to convert
* @return array Generated array
*/
public static function SurveyChoiceToAPI(SurveyChoice $choice) : array {
$data = array();
$data["choiceID"] = $choice->get_id();
$data["name"] = $choice->get_name();
$data["responses"] = $choice->get_responses();
return $data;
}
}