aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--edit_algebra_form.php22
1 files changed, 18 insertions, 4 deletions
diff --git a/edit_algebra_form.php b/edit_algebra_form.php
index e091418..3ab31ac 100644
--- a/edit_algebra_form.php
+++ b/edit_algebra_form.php
@@ -89,18 +89,32 @@ class qtype_algebra_edit_form extends question_edit_form {
// Create an array which will store the function checkboxes.
$funcgroup = array();
+// KLUDGE: illogical, but works better than the alternative:
+// <br> doesn't separate rows the way you want; try a full-width div instead:
+ $rowSep = '<div style="width:100%"></div>';
+
+// FIXME:
+// Trying to align columns using flexbox + spacers is an unsound design.
+// It fails in ways the server cannot anticipate, because of variable-width fonts.
+// Such things should be aligned using an html table or css grid,
+// or by wrapping each checkbox in a fixed-width wrapper:
+// https://stackoverflow.com/questions/257505/css-fixed-width-in-a-span
// Create an array to add spacers between the boxes.
- $spacers = array('<br>');
+ $spacers = array($rowSep);
+ $itemsPerRow = 6;
// Add the initial all functions box to the list of check boxes.
$funcgroup[] =& $mform->createElement('checkbox', 'all', '', get_string('allfunctions', 'qtype_algebra'));
// Create a checkbox element for each function understood by the parser.
+// FIXME: why do the function names show up on the page in some weird order???
for ($i = 0; $i < count(qtype_algebra_parser::$functions); $i++) {
$func = qtype_algebra_parser::$functions[$i];
$funcgroup[] =& $mform->createElement('checkbox', $func, '', $func);
- if (($i % 6) == 5) {
- $spacers[] = '<br>';
+ if (((1+$i) % $itemsPerRow) == 0) {
+ $spacers[] = $rowSep;
} else {
- $spacers[] = str_repeat('&nbsp;', 8 - strlen($func));
+// KLUDGE: far from perfect, but
+// usable approximation for typical variable-width fonts:
+ $spacers[] = str_repeat('&nbsp;', 2.0*(8 - strlen($func)));
}
}
// Create and add the group of function controls to the form.