mirror of
https://framagit.org/tykayn/date-poll-api
synced 2023-08-25 08:23:11 +02:00
save kind of poll
This commit is contained in:
parent
e86606b543
commit
cc74a08603
@ -216,6 +216,7 @@ class PollController extends EmailsController {
|
||||
$newpoll
|
||||
->setModificationPolicy( $data[ 'modification_policy' ] )
|
||||
->setTitle( $data[ 'title' ] )
|
||||
->setKind( $data[ 'kind' ] )
|
||||
->setCustomUrl( $data[ 'custom_url' ] );
|
||||
if ( count( $data[ 'allowed_answers' ] ) ) {
|
||||
$newpoll->setAllowedAnswers( $data[ 'allowed_answers' ] );
|
||||
@ -257,7 +258,7 @@ class PollController extends EmailsController {
|
||||
$newpoll->setDescription( $data['description'] );
|
||||
$newpoll->setHideResults( false );
|
||||
// possible answers
|
||||
$newpoll->setAllowedAnswers( [ 'yes' ] );
|
||||
$newpoll->setAllowedAnswers( $data[ 'allowed_answers' ] );
|
||||
$newpoll->setVotesMax( $data[ 'maxCountOfAnswers' ] );
|
||||
$newpoll->setCommentsAllowed( $data['allowComments'] );
|
||||
|
||||
|
@ -295,21 +295,22 @@ class Poll {
|
||||
foreach ( $this->getChoices() as $choice ) {
|
||||
$boom = explode( ' >>> ', $choice->getName() );
|
||||
|
||||
if(count($boom) ==2){
|
||||
if ( count( $boom ) == 2 ) {
|
||||
|
||||
|
||||
if ( ! isset( $grouped_dates[ $boom[ 0 ] ] ) ) {
|
||||
if ( ! isset( $grouped_dates[ $boom[ 0 ] ] ) ) {
|
||||
|
||||
$grouped_dates[ $boom[ 0 ] ] = [
|
||||
$grouped_dates[ $boom[ 0 ] ] = [
|
||||
|
||||
"date_string" => $boom[ 0 ],
|
||||
"choices" => [],
|
||||
"date_string" => $boom[ 0 ],
|
||||
"choices" => [],
|
||||
];
|
||||
}
|
||||
$grouped_dates[ $boom[ 0 ] ][ "choices" ][] = [
|
||||
"choice_id" => $choice->getId(),
|
||||
"name" => $boom[ 1 ],
|
||||
];
|
||||
}
|
||||
$grouped_dates[ $boom[ 0 ] ][ "choices" ][] = [
|
||||
"choice_id" => $choice->getId(),
|
||||
"name" => $boom[ 1 ] ];
|
||||
}
|
||||
}
|
||||
}
|
||||
$scoreInfos = [
|
||||
@ -380,18 +381,18 @@ class Poll {
|
||||
}
|
||||
$groupsOfDates = [];
|
||||
foreach ( $grouped_dates as $group ) {
|
||||
$ii =0;
|
||||
foreach ( $group["choices"] as $slice ) {
|
||||
$slice['score'] = $computedArray[ $slice['choice_id'] ]['score'];
|
||||
$slice['yes'] = $computedArray[ $slice['choice_id'] ]['yes'];
|
||||
$slice['maybe'] = $computedArray[ $slice['choice_id'] ]['maybe'];
|
||||
$slice['no'] = $computedArray[ $slice['choice_id'] ]['no'];
|
||||
$slice['id'] = $slice['choice_id'];
|
||||
$group["choices"][$ii] = $slice;
|
||||
$ii++;
|
||||
$ii = 0;
|
||||
foreach ( $group[ "choices" ] as $slice ) {
|
||||
$slice[ 'score' ] = $computedArray[ $slice[ 'choice_id' ] ][ 'score' ];
|
||||
$slice[ 'yes' ] = $computedArray[ $slice[ 'choice_id' ] ][ 'yes' ];
|
||||
$slice[ 'maybe' ] = $computedArray[ $slice[ 'choice_id' ] ][ 'maybe' ];
|
||||
$slice[ 'no' ] = $computedArray[ $slice[ 'choice_id' ] ][ 'no' ];
|
||||
$slice[ 'id' ] = $slice[ 'choice_id' ];
|
||||
$group[ "choices" ][ $ii ] = $slice;
|
||||
$ii ++;
|
||||
}
|
||||
|
||||
$groupsOfDates[] = $group ;
|
||||
$groupsOfDates[] = $group;
|
||||
}
|
||||
|
||||
return [
|
||||
@ -494,7 +495,11 @@ class Poll {
|
||||
}
|
||||
|
||||
public function setAllowedAnswers( array $allowedAnswers ): self {
|
||||
$this->allowedAnswers = $allowedAnswers;
|
||||
if ( ! count( $allowedAnswers ) ) {
|
||||
$this->allowedAnswers = [ 'yes' ];
|
||||
} else {
|
||||
$this->allowedAnswers = $allowedAnswers;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user