mirror of
https://github.com/pierre42100/ComunicAPI
synced 2025-06-19 00:25:18 +00:00
Implemented Survey Object
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -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){
|
||||
|
Reference in New Issue
Block a user