19declare(strict_types=1);
44 $this->total_votes = (
int) (
$res[
'total'] ?? 0);
46 $this->answer_percentages = array_map(
47 fn(array
$a) => (
float) (
$a[
'perc'] ?? 0),
50 $this->answer_totals = array_map(
51 fn(array
$a) => (
int) (
$a[
'abs'] ?? 0),
61 if ($this->sort_by_votes) {
64 $order = array_keys($order);
66 foreach ($this->answers->getAnswers() as
$id => $answer) {
67 if (!in_array(
$id, $order)) {
72 foreach ($order as
$id) {
76 foreach ($this->answers->getAnswers() as
$id => $answer) {
89 return $this->answers->getAnswer(
$id);
94 return $this->answer_percentages[
$id] ?? 0;
99 return $this->answer_totals[
$id] ?? 0;
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
array $answer_percentages
__construct(ilObjPoll $poll, ilPollAnswersHandler $answers)
getAnswerPercentage(int $id)
ilPollAnswersHandler $answers
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples