ILIAS  release_8 Revision v8.24
base1.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
6
7function base1()
8{
9 global $DIC;
10 $f = $DIC->ui()->factory();
11 $renderer = $DIC->ui()->renderer();
12
13 //build viewcontrols
14 $actions = array("Alle" => "#", "Mehr als 5 Antworten" => "#");
15 $aria_label = "filter entries";
16 $view_controls = array(
17 $f->viewControl()->mode($actions, $aria_label)->withActive("Alle")
18 );
19
20 $mapping_closure = function ($row, $record, $ui_factory, $environment) {
21 return $row
22 ->withHeadline($record['question_title'])
23 ->withSubheadline($record['question_txt'])
24 ->withImportantFields(
25 array(
26 $record['type'],
27 'Beantwortet: ' => $record['stats']['total'],
28 'Häufigste Antwort: ' => $record['answers'][$record['stats']['most_common']]['title']
29 )
30 )
31 ->withContent(
32 $ui_factory->listing()->descriptive(
33 array(
34 'Werte' => $environment['totals']($record['answers']),
35 'Chart' => $environment['chart']($record['answers']),
36 )
37 )
38 )
39 ->withFurtherFieldsHeadline($record['type'])
40 ->withFurtherFields(
41 array(
42 'Beantwortet: ' => $record['stats']['total'],
43 'Übersprungen' => $record['stats']['skipped'],
44 'Häufigste Antwort: ' => $record['answers'][$record['stats']['most_common']]['title'],
45 'Anzahl Häufigste: ' => $record['stats']['most_common_total'],
46 'Median: ' => $record['answers'][$record['stats']['median']]['title']
47 )
48 )
49 ->withAction($ui_factory->button()->standard('zur Frage', '#'));
50 };
51
52 $ptable = $f->table()->presentation(
53 'Presentation Table', //title
54 $view_controls,
55 $mapping_closure
56 )
57 ->withEnvironment(environment());
58
59 //example data
61
62 //apply data to table and render
63 return $renderer->render($ptable->withData($data));
64}
65
66function environment()
67{
68 $totals = function ($answers) {
69 $ret = '<table>';
70 $ret .= '<tr><td></td>'
71 . '<td>Amount</td>'
72 . '<td style="padding-left: 10px;">Proportion</td></tr>';
73
74 foreach ($answers as $answer) {
75 $ret .= '<tr>'
76 . '<td style="padding-right: 10px;">' . $answer['title'] . '</td>'
77 . '<td align="right">' . $answer['amount'] . '</td>'
78 . '<td align="right">' . $answer['proportion'] . '%</td>'
79 . '</tr>';
80 }
81
82 $ret .= '</table><br>';
83 return $ret;
84 };
85
86
87 $chart = function ($answers) {
88 $ret = '<table style="width:100%">';
89 foreach ($answers as $answer) {
90 $ret .= '<tr style="border-bottom: 1px solid black;">'
91 . '<td style="width: 200px;">'
92 . $answer['title']
93 . '</td><td>'
94 . '<div style="background-color:grey; height:20px; width:' . $answer['proportion'] . '%;"></div>'
95 . '</td></tr>';
96 }
97 $ret .= '</table>';
98 return $ret;
99 };
100
101 return array(
102 'totals' => $totals,
103 'chart' => $chart
104 );
105}
106
108{
109 return array(
110 array(
111 'type' => 'Single Choice Frage',
112 'question_title' => 'Belastbarkeit',
113 'question_txt' => 'Wie ausgeprägt ist die Belastbarkeit des / der Auszubildenden?',
114 'answers' => array(
115 array('title' => 'weniger ausgeprägt', 'amount' => 2, 'proportion' => 20),
116 array('title' => 'teilweise ausgeprägt', 'amount' => 0, 'proportion' => 0),
117 array('title' => 'ausgeprägt', 'amount' => 6, 'proportion' => 60),
118 array('title' => 'deutlich ausgeprägt', 'amount' => 1, 'proportion' => 10),
119 array('title' => 'stark ausgeprägt', 'amount' => 0, 'proportion' => 0),
120 array('title' => 'sehr stark ausgeprägt', 'amount' => 0, 'proportion' => 0),
121 array('title' => 'übermäßig ausgeprägt', 'amount' => 1, 'proportion' => 10)
122 ),
123 'stats' => array(
124 'total' => 10,
125 'skipped' => 2,
126 'most_common' => 2,
127 'most_common_total' => 6,
128 'median' => 2,
129 )
130 ),
131
132 array(
133 'type' => 'Single Choice Frage',
134 'question_title' => 'Dialogfähigkeit, Kundenorientierung, Beratungsfähigkeit',
135 'question_txt' => 'Wie ausgeprägt ist die Dialogfähigkeit, Kundenorientierung und Beratungsfähigkeit des / der Auszubildenden?',
136 'answers' => array(
137 array('title' => 'weniger ausgeprägt', 'amount' => 0, 'proportion' => 0),
138 array('title' => 'teilweise ausgeprägt', 'amount' => 1, 'proportion' => 100),
139 array('title' => 'ausgeprägt', 'amount' => 0, 'proportion' => 0),
140 array('title' => 'deutlich ausgeprägt', 'amount' => 0, 'proportion' => 0),
141 array('title' => 'stark ausgeprägt', 'amount' => 0, 'proportion' => 0),
142 array('title' => 'sehr stark ausgeprägt', 'amount' => 0, 'proportion' => 0),
143 array('title' => 'übermäßig ausgeprägt', 'amount' => 0, 'proportion' => 0)
144 ),
145 'stats' => array(
146 'total' => 1,
147 'skipped' => 0,
148 'most_common' => 1,
149 'most_common_total' => 1,
150 'median' => 1,
151 )
152 ),
153 );
154}
global $DIC
Definition: feed.php:28