Dies ist eine alte Version des Dokuments!
Using the functions value()
, valueMean()
, the participant's answers can already be evaluated during the Questionnaire session (also see Score Responses). Some questions, like for instance Implicit association test (IAT), deliver an evaluation directly. Additionally, with the help of statistic()
function, it is possible to evaluate values of all the previously tested participants.
It is easy to present the evaluation outcome as text. The sprintf()
function makes it easy to format decimal values. Using sprintf('%1.2f', $value)
the decimal value $value
is formated in such a way so that there are 2 digits after after the point (two decimal digits).
The easiest way to output single values is to use html()
. Strings can be bound using a point (.
) (for instance when binding fragments of HTML code and the output values that should be displayed).
$value = valueMean('AB01'); html(' <p>You evaluated the current TV programm on a scale from 1 to 10 and your average evaluation was '.sprintf('%1.1f', $value).'. Average evaluation for this program countrywide is 6.3</p> ');
Possibly, one may also want to output different lines of text depending on the outcome of the evaluation. To set this up the function Filter can be used:
// Calculating the outcome value $value = valueMean('AB01_01', 'AB01_05', 'AB01_09'); // z-Transformation $zValue = ($value - 5) / 2.8; // Showing the appropriate text based on the outcome value if ($value < 0) { // no valid data in $value - no output } elseif ($zValue < -2) { text('resultExtraSD-2'); } elseif ($zValue < -1) { text('resultExtraSD-1'); } elseif ($zValue <= 1) { text('resultExtraSD-0'); } elseif ($zValue < 2) { text('resultExtraSD+1'); } else { text('resultExtraSD+2'); }
Multiple values are commonly displayed in a table. The easiest way to do this is with text-blocks and placeholders. For instance you could save the following HTML code under Textblocks and Labels inside a new textblock results.
<table cellspacing="5" cellpadding="0" border="0"> <tr> <th>Trait</th> <th>Your value</th> <th>Value of comparison</th> </tr> <tr> <td>Extraversion</td> <td>%val-extra%</td> <td>3.2</td> </tr> <tr> <td>Neuroticism</td> <td>%val-neuro%</td> <td>2.4</td> </tr> </table>
The placeholders can finally directly be indicated in the command text()
. Alternatively, replace()
can also be used.
text('result', array( '%val-extra%' => valueMean('AB01_01', 'AB01_05', 'AB01_09'), '%val-neuro%' => valueMean('AB01_02', 'AB01_06', 'AB01_10') ));
There are several different options available to present outcomes visually.
For single values (for example an IAT score) an HTML code can be used to show a scale with a mark on it.
Speichern Sie den folgenden HTML-Code als Textbaustein, z.B. mit der Kennung „responseSD“.
<!-- Überschrift für die Abbildung --> <div class="title" style="text-align: center">%title%</div> <div style="position: relative"> <!-- Die Skala liegt im Hintergrund --> <div style="margin: 0 auto; width: 400px; height: 25px; background-image:url('ofb://slider.scale.sd-blue400S')"> <!-- Zur Platzierung der Markierung wird eine Einheit (Bereich 0 bis 1) als Blockelement platziert --> <div style="position: absolute; top: -2px; left: 50%; width: 65px; height: 27px"> <!-- Die eigentliche Markierung wird an der richtigen Stelle eingefügt --> <img src="ofb://slider.button.rhomb" alt="" style="position: absolute; left: %z-value*100%%; margin-left: -8px" /> </div> </div> </div>
Im HTML-Code sind zwei Platzhalter: %title%
und %z-value*100%
. Der zweite Platzhalter heißt eigentlich %z-value%
, sein Wert wird wegen dem *100
aber mit 100 multipliziert, bevor er in den HTML-Code eingesetzt wird. Dieser HTML-Code ist dafür ausgelegt, einen z-Wert zwischen -3 und +3 anzuzeigen. Entsprechend sähe die Verwendung aus wie folgt:
// Wert/Ergebnis ermitteln $value = valueMean('AB01_01', 'AB01_05', 'AB01_09'); // z-Transformation $zValue = ($value - 5) / 2.8; // Extremwerte filtern if ($zValue < -3) { $zValue = -3; } if ($zValue > 3) { $zValue = 3; } // Textbaustein verwenden (nur, wenn $value einen gültigen Wert geliefert hat) if ($value > 0) { text('responseSD', array( '%title%' => 'Extraversion', '%z-value%' => $zValue )); }
Mit Hilfe der Funktion diagram2()
lassen sich ausgewählte Diagramme im Fragebogen platzieren. Zur Verwendung sei auf die Dokumentation der Funktion verwiesen. Eine optimierte Funktion chart()
wird in künftigen Versionen von SoSci Survey zur Verfügung stehen.
Sofern auf dem Befragungsserver das Plug-In Highcharts zur Verfügung steht, können mit der Highcharts-Bibliothek sehr schicke Diagramme im Fragebogen angezeigt werden. Wenn die Kategorie-Beschriftungen in im Array $labels
gespeichert sind, die Ergebnisse im Array $ownData
und Referenzdaten im Array $refData
, kann man mit folgendem Textbaustein „chart“ (Darstellung „HTML_Code“) und dem zugehörigen PHP-Code ein Balken-Diagramm anzeigen. Erklärungen und Details sind der Highcharts Dokumentation zu entnehmen.
<!-- Container für das Diagramm --> <div id="chart" style="height: 600px"></div> <script type="text/javascript" src="../plugins/highcharts/highcharts.js"></script> <script type="text/javascript"> <!-- $(function () { $('#chart').highcharts({ chart: { type: 'bar' }, title: { text: null }, xAxis: { categories: %labels%, title: { text: null } }, plotOptions: { bar: { dataLabels: { enabled: true } } }, legend: { layout: 'horizontal', align: 'center', verticalAlign: 'bottom', floating: false, borderWidth: 0, backgroundColor: ((Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'), shadow: false }, credits: { enabled: false }, series: [{ name: 'Durchschnitt', data: %refData%, color: '#BBBBBB', dataLabels: { enabled: false } }, { name: 'Ihr Wert', data: %ownData%, color: '#009900', dataLabels: { enabled: false } }] }); }); // --> </script>
// Bibliothek jQuery verfügbar machen option('script', 'jQuery 1.x'); // Textbaustein mit dem HTML-Code für das Chart einbinden text('chart', array( '%labels%' => json_encode($labels), '%ownData%' => json_encode($ownData), '%refData%' => json_encode($refData) ));