];
}, array_keys($ansCountBy), $ansCountBy);
+ $more = [];
+ if($question['type'] === 'poll_rating') {
+ $numberOnly = array_filter($ansCountBy, fn($ans) => is_numeric($ans['value']));
+ $count = array_sum(array_column($numberOnly, 'count'));
+ $score = array_reduce($numberOnly, fn($acc, $ans) => $acc + $ans['value'] * $ans['count']);
+ $more['mean'] = number_format($score/$count, 2);
+ }
- return array_merge($question, [
+
+
+ return $question + [
'answers' => $ansCountBy
- ]);
+ ] + $more;
});
'aws_s3_url' => 'https://prescription-sante.s3.eu-west-3.amazonaws.com',
- 'version' => '0.4.2 beta 3',
+ 'version' => '0.6.1 beta 4',
/*
'icon' => 'check',
'component' => 'a17-block-poll_check_item',
],
+ 'poll_yes_no' => [
+ 'title' => 'Oui / Non',
+ 'icon' => 'check',
+ 'component' => 'a17-block-poll_yes_no',
+ ],
+ 'poll_rating' => [
+ 'title' => 'Notation (0-10)',
+ 'icon' => 'check',
+ 'component' => 'a17-block-poll_rating',
+ ],
],
'crops' => [
</div>
<div v-else>
+
+ <div class="alert alert-info my-2" v-if="selected_question.type === 'poll_rating'">
+ Le score moyen obtenu est de {{selected_question.mean}}
+ </div>
+
<table class="table table-hover">
<thead class="thead-light">
<tr>
--- /dev/null
+@twillRepeaterTitle('Notation 0-10')
+@twillRepeaterGroup('app')
+
+@formField('input', [
+ 'name' => 'question',
+ 'label' => 'Question',
+ 'maxlength' => 250,
+ 'required' => true,
+])
--- /dev/null
+@twillRepeaterTitle('Oui / Non')
+@twillRepeaterGroup('app')
+
+@formField('input', [
+ 'name' => 'question',
+ 'label' => 'Question',
+ 'maxlength' => 250,
+ 'required' => true,
+])
'maxlength' => 100
])
- @formField('block_editor', ['blocks' => ['poll_text', 'poll_check', 'image']])
+ @formField('block_editor', ['blocks' => ['poll_text', 'poll_check', 'poll_yes_no', 'poll_rating', 'image']])
--- /dev/null
+@php
+ $slug = Str::slug($question = $block->input('question'))
+@endphp
+<div class="form-group">
+ <label for="{{$slug}}">{{$question}}</label>
+ <div>
+ @for($i = 0; $i <= 10; $i++)
+
+ <div class="form-check form-check-inline">
+ <input class="form-check-input" type="radio" name="{{$slug}}" id="answer-{{$i}}-{{$slug}}" value="{{$i}}">
+ <label class="form-check-label" for="answer-{{$i}}-{{$slug}}">
+ {{$i}}
+ </label>
+ </div>
+ @endfor
+
+ </div>
+
+
+</div>
--- /dev/null
+@php
+ $slug = Str::slug($question = $block->input('question'))
+@endphp
+<div class="form-group">
+ <label for="{{$slug}}">{{$question}}</label>
+ <div>
+ <div class="form-check form-check-inline">
+ <input class="form-check-input" type="radio" name="{{$slug}}" id="answer-yes-{{$slug}}" value="Oui">
+ <label class="form-check-label" for="answer-yes-{{$slug}}">
+ Oui
+ </label>
+ </div>
+ <div class="form-check form-check-inline">
+ <input class="form-check-input" type="radio" name="{{$slug}}" id="answer-no-{{$slug}}" value="Non">
+ <label class="form-check-label" for="answer-no-{{$slug}}">
+ Non
+ </label>
+ </div>
+
+ </div>
+
+
+</div>
-@extends('layouts.app', ['hideNav' => true])
+@extends('layouts.app', ['hideNav' => true, 'hideFooter' => true])
@section('content')
<article class="container">