diff options
author | John Denker <jsd@av8n.com> | 2021-11-11 08:40:48 -0700 |
---|---|---|
committer | John Denker <jsd@av8n.com> | 2021-11-11 16:08:19 -0700 |
commit | 9745514c1833bee05ce0a2ee28cd92d62fd4a8dc (patch) | |
tree | bb270293d4bbbddc24e69132b45b614363f83dea | |
parent | 9b981411b8dc7c0ff4878fa1a98dad6e3d69c653 (diff) |
fix it so that the set of "allowed functions" shows up in
even rows and almost-even columns
-rw-r--r-- | edit_algebra_form.php | 22 |
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(' ', 8 - strlen($func)); +// KLUDGE: far from perfect, but +// usable approximation for typical variable-width fonts: + $spacers[] = str_repeat(' ', 2.0*(8 - strlen($func))); } } // Create and add the group of function controls to the form. |