mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
Better layout of gathering quiz results, which mkes it easier for developers
at the cost of perhaps a little efficiency ... some more testing on this i should be done. Thanks to Henrick Kaipe for this.
This commit is contained in:
parent
7e4a64888b
commit
cee5ff1d04
1 changed files with 13 additions and 23 deletions
|
@ -92,34 +92,24 @@
|
|||
}
|
||||
|
||||
foreach ($rawanswers as $key => $value) { // Parse input for question -> answers
|
||||
if (substr($key, 0, 1) == "q") {
|
||||
$key = substr($key,1);
|
||||
if (isset($questions[$key])) { // It's a real question number, not a coded one
|
||||
$questions[$key]->answer[] = trim($value);
|
||||
|
||||
} else if (substr_count($key, "rq")) { // Random Question information
|
||||
$check = explode("rq", $key);
|
||||
$key = $check[0]; // The random question id
|
||||
$real = $check[1]; // The real question id
|
||||
$questions[$key]->random = $real;
|
||||
if (ereg('^q([0-9]+)$', $key, $keyregs)) { // It's a real question number, not a coded one
|
||||
$questions[$keyregs[1]]->answer[] = trim($value);
|
||||
|
||||
} else if (substr_count($key, "a")) { // Checkbox style multiple answers
|
||||
$check = explode("a", $key);
|
||||
$key = $check[0]; // The main question number
|
||||
$value = $check[1]; // The actual answer
|
||||
$questions[$key]->answer[] = trim($value);
|
||||
} else if (ereg('^q([0-9]+)rq([0-9]+)$', $key, $keyregs)) { // Random Question information
|
||||
$questions[$keyregs[1]]->random = $keyregs[2];
|
||||
|
||||
} else if (substr_count($key, "r")) { // Random-style answers
|
||||
$check = explode("r", $key);
|
||||
$key = $check[0]; // The main question
|
||||
$rand = $check[1]; // The random sub-question
|
||||
$questions[$key]->answer[] = "$rand-$value";
|
||||
} else if (ereg('^q([0-9]+)a([0-9]+)$', $key, $keyregs)) { // Checkbox style multiple answers
|
||||
$questions[$keyregs[1]]->answer[] = $keyregs[2];
|
||||
|
||||
} else {
|
||||
error("Answer received for non-existent question ($key)!");
|
||||
}
|
||||
} else if ($key == "shuffleorder") {
|
||||
} else if (ereg('^q([0-9]+)r([0-9]+)$', $key, $keyregs)) { // Random-style answers
|
||||
$questions[$keyregs[1]]->answer[] = "$keyregs[2]-$value";
|
||||
|
||||
} else if ('shuffleorder' == $key) {
|
||||
$shuffleorder = explode(",", $value); // Actual order questions were given in
|
||||
|
||||
} else { // Useful for debugging new question types. Must be last.
|
||||
error("Answer received for non-existent question ($key -> $value)");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue