Implemented Survey Object

This commit is contained in:
Pierre
2018-04-21 20:24:05 +02:00
parent b00e401ada
commit 23d1761bef
3 changed files with 47 additions and 25 deletions

View File

@ -7,7 +7,7 @@
* @author Pierre HUBERT
*/
class surveysController {
class SurveysController {
/**
* Cancel a response to a survey
@ -87,4 +87,25 @@ class surveysController {
}
/**
* Parse a survey object into a valid API entry
*
* @param Survey $survey The survey object to convert
* @return array Generated API entry
*/
public static function SurveyToAPI(Survey $survey) : array {
$data = array();
$data["ID"] = $survey->get_id();
$data["userID"] = $survey->get_userID();
$data["postID"] = $survey->get_postID();
$data["creation_time"] = $survey->get_time_sent();
$data["question"] = $survey->get_question();
$data["user_choice"] = $survey->get_user_choice();
$data["choices"] = $survey->get_choices();
return $data;
}
}

View File

@ -528,6 +528,10 @@ class postsController {
//Update visibility level
$infos['visibility_level'] = $this::VISIBILITY_LEVELS_API[$infos['visibility_level']];
//Turn survey into API entry (if any)
if($infos["data_survey"] != null)
$infos["data_survey"] = SurveysController::SurveyToAPI($infos["data_survey"]);
//Parse comments if required
if(isset($infos['comments'])){
if($infos['comments'] != null){