Skip to content
Snippets Groups Projects
Commit 293f3475 authored by Chris Sangwin's avatar Chris Sangwin
Browse files

Add a section to the report amalgamating inputs: useful with no random...

Add a section to the report amalgamating inputs: useful with no random versions on multi-part questions.
parent 5a94e495
No related branches found
No related tags found
No related merge requests found
...@@ -510,6 +510,7 @@ $string['basicreportraw'] = 'Raw data'; ...@@ -510,6 +510,7 @@ $string['basicreportraw'] = 'Raw data';
$string['basicreportnotes'] = 'Frequency of answer notes, for each PRT, regardless of which variant was used.'; $string['basicreportnotes'] = 'Frequency of answer notes, for each PRT, regardless of which variant was used.';
$string['basicreportnotessplit'] = 'Frequency of answer notes, for each PRT, split by |, regardless of which variant was used.'; $string['basicreportnotessplit'] = 'Frequency of answer notes, for each PRT, split by |, regardless of which variant was used.';
$string['basicreportvariants'] = 'Raw inputs and PRT answer notes by variant.'; $string['basicreportvariants'] = 'Raw inputs and PRT answer notes by variant.';
$string['basicreportinputsummary'] = 'Raw inputs, regardless of which variant was used.';
// Equiv input specific string. // Equiv input specific string.
$string['equivnocomments'] = 'You are not permitted to use comments in this input type. Please just work line by line.'; $string['equivnocomments'] = 'You are not permitted to use comments in this input type. Please just work line by line.';
......
...@@ -125,7 +125,11 @@ $qinputs = array_flip(array_keys($question->inputs)); ...@@ -125,7 +125,11 @@ $qinputs = array_flip(array_keys($question->inputs));
foreach ($qinputs as $key => $val) { foreach ($qinputs as $key => $val) {
$qinputs[$key] = array('score' => array(), 'valid' => array(), 'invalid' => array(), 'other' => array()); $qinputs[$key] = array('score' => array(), 'valid' => array(), 'invalid' => array(), 'other' => array());
} }
$inputreport = array(); $inputreport = array();
// The inputreportsummary is used to store inputs, regardless of variant.
// Multi-part questions may have inputs which are not subject to randomisation.
$inputreportsummary = $qinputs;
$inputtotals = array(); $inputtotals = array();
$qprts = array_flip(array_keys($question->prts)); $qprts = array_flip(array_keys($question->prts));
...@@ -164,6 +168,11 @@ foreach ($summary as $variant => $vdata) { ...@@ -164,6 +168,11 @@ foreach ($summary as $variant => $vdata) {
} else { } else {
$inputreport[$variant][$input][$status][$datas] = $num; $inputreport[$variant][$input][$status][$datas] = $num;
} }
if (array_key_exists($datas, $inputreportsummary[$input][$status])) {
$inputreportsummary[$input][$status][$datas] += (int) $num;
} else {
$inputreportsummary[$input][$status][$datas] = $num;
}
// Count the total numbers in this array. // Count the total numbers in this array.
if (array_key_exists($input, $inputtotals)) { if (array_key_exists($input, $inputtotals)) {
$inputtotals[$input] += (int) $num; $inputtotals[$input] += (int) $num;
...@@ -204,6 +213,13 @@ foreach ($inputreport as $variant => $vdata) { ...@@ -204,6 +213,13 @@ foreach ($inputreport as $variant => $vdata) {
} }
} }
foreach ($inputreportsummary as $input => $idata) {
foreach ($idata as $key => $value) {
arsort($value);
$inputreportsummary[$input][$key] = $value;
}
}
foreach ($prtreport as $variant => $vdata) { foreach ($prtreport as $variant => $vdata) {
foreach ($vdata as $prt => $tdata) { foreach ($vdata as $prt => $tdata) {
arsort($tdata); arsort($tdata);
...@@ -280,6 +296,36 @@ if (trim($sumout) !== '') { ...@@ -280,6 +296,36 @@ if (trim($sumout) !== '') {
echo html_writer::tag('pre', trim($sumout)); echo html_writer::tag('pre', trim($sumout));
} }
$sumout = '';
foreach ($inputreportsummary as $input => $idata) {
$sumouti = '';
$tot = 0;
foreach ($idata as $key => $data) {
foreach ($data as $dat => $num) {
$tot += $num;
}
}
foreach ($idata as $key => $data) {
if ($data !== array()) {
$sumouti .= '### ' . $key . "\n";
$pad = max($data);
foreach ($data as $dat => $num) {
$sumouti .= str_pad($num, strlen((string) $pad) + 1) . '(' .
str_pad(number_format((float) 100 * $num / $tot, 2, '.', ''), 6, ' ', STR_PAD_LEFT) .
'%); ' . $dat . "\n";
}
$sumouti .= "\n";
}
}
if (trim($sumouti) !== '') {
$sumout .= '## ' . $input . ' ('. $tot . ")\n" . $sumouti;
}
}
if (trim($sumout) !== '') {
echo html_writer::tag('h3', stack_string('basicreportinputsummary'));
echo html_writer::tag('pre', $sumout);
}
// Output a report. // Output a report.
if (array_keys($summary) !== array()) { if (array_keys($summary) !== array()) {
echo html_writer::tag('h2', stack_string('basicreportvariants')); echo html_writer::tag('h2', stack_string('basicreportvariants'));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment