Files
HotLunches/math.php
T
2026-10-19 15:22:52 -07:00

149 lines
5.9 KiB
PHP

<?php
require_once("include/globals.php");
// Start the template and output buffering
startTemplate();
$templatePageTitle = "";
$noTitle = true;
$headerArgs = "";
include "math.inc.php";
?>
<script language= "JavaScript">
function checkDigits() {
// Get min_top_digits
for (var i=0; i < document.worksheet.min_top_digits.length; i++) {
if (document.worksheet.min_top_digits[i].checked) {
var min_top_digits = document.worksheet.min_top_digits[i].value;
}
}
// Get max_top_digits
for (var i=0; i < document.worksheet.max_top_digits.length; i++) {
if (document.worksheet.max_top_digits[i].checked) {
var max_top_digits = document.worksheet.max_top_digits[i].value;
}
}
// Get min_bottom_digits
for (var i=0; i < document.worksheet.min_bottom_digits.length; i++) {
if (document.worksheet.min_bottom_digits[i].checked) {
var min_bottom_digits = document.worksheet.min_bottom_digits[i].value;
}
}
// Get max_bottom_digits
for (var i=0; i < document.worksheet.max_bottom_digits.length; i++) {
if (document.worksheet.max_bottom_digits[i].checked) {
var max_bottom_digits = document.worksheet.max_bottom_digits[i].value;
}
}
// Validate the top digits
if (min_top_digits > max_top_digits) {
alert("Error: Minimum number of top digits is greater than the maximum number");
return false;
}
// Validate the bottom digits
if (min_bottom_digits > max_bottom_digits) {
alert("Error: Minimum number of bottom digits is greater than the maximum number");
return false;
}
}
</script>
<br>
<form name='worksheet' method='post' action='math-worksheets.php' target='_blank' onSubmit="return checkDigits();">
<table class='content-table'>
<tr>
<td colspan='2' align='center' class='heading'>Define Math Worksheets</td>
</tr>
<tr class='data-odd'>
<td align='right'>First Number Digits (min) :: </td>
<td align='left'>
<nobr><input type='radio' name='min_top_digits' value='1' checked='checked'"> 1</nobr>&nbsp;
<nobr><input type='radio' name='min_top_digits' value='2'> 2</nobr>&nbsp;
<nobr><input type='radio' name='min_top_digits' value='3'> 3</nobr>&nbsp;
<nobr><input type='radio' name='min_top_digits' value='4'> 4</nobr>&nbsp;
<nobr><input type='radio' name='min_top_digits' value='5'> 5</nobr>&nbsp;
</td>
</tr>
<tr class='data-even'>
<td align='right'>First Number Digits (max) :: </td>
<td align='left'>
<nobr><input type='radio' name='max_top_digits' value='1' checked='checked'> 1</nobr>&nbsp;
<nobr><input type='radio' name='max_top_digits' value='2'> 2</nobr>&nbsp;
<nobr><input type='radio' name='max_top_digits' value='3'> 3</nobr>&nbsp;
<nobr><input type='radio' name='max_top_digits' value='4'> 4</nobr>&nbsp;
<nobr><input type='radio' name='max_top_digits' value='5'> 5</nobr>&nbsp;
</td>
</tr>
<tr class='data-odd'>
<td align='right'>Second Number Digits (min) :: </td>
<td align='left'>
<nobr><input type='radio' name='min_bottom_digits' value='1' checked='checked'> 1</nobr>&nbsp;
<nobr><input type='radio' name='min_bottom_digits' value='2'> 2</nobr>&nbsp;
<nobr><input type='radio' name='min_bottom_digits' value='3'> 3</nobr>&nbsp;
<nobr><input type='radio' name='min_bottom_digits' value='4'> 4</nobr>&nbsp;
<nobr><input type='radio' name='min_bottom_digits' value='5'> 5</nobr>&nbsp;
</td>
</tr>
<tr class='data-even'>
<td align='right'>Second Number Digits (max) :: </td>
<td align='left'>
<nobr><input type='radio' name='max_bottom_digits' value='1' checked='checked'> 1</nobr>&nbsp;
<nobr><input type='radio' name='max_bottom_digits' value='2'> 2</nobr>&nbsp;
<nobr><input type='radio' name='max_bottom_digits' value='3'> 3</nobr>&nbsp;
<nobr><input type='radio' name='max_bottom_digits' value='4'> 4</nobr>&nbsp;
<nobr><input type='radio' name='max_bottom_digits' value='5'> 5</nobr>&nbsp;
</td>
</tr>
<tr class='data-odd'>
<td align='right'>Math Operation :: </td>
<td align='left'><?php BuildFileRadio("operations.txt","operation","multiplication") ?></td>
</tr>
<tr class='data-even'>
<td align='right'>Number of Pages :: </td>
<td align='left'>
<select name='pages'>
<option value='1'>1 page - <?php echo(1 * $numRows * $numQuestions) ?> questions</option>
<option value='2'>2 pages - <?php echo(2 * $numRows * $numQuestions) ?> questions</option>
<option value='3'>3 pages - <?php echo(3 * $numRows * $numQuestions) ?> questions</option>
<option value='4'>4 pages - <?php echo(4 * $numRows * $numQuestions) ?> questions</option>
<option value='5'>5 pages - <?php echo(5 * $numRows * $numQuestions) ?> questions</option>
</select>
</td>
</tr>
<tr>
<td colspan='2' align='center'>
<br>
<input type='submit' class='btn btn--primary' value='View Worksheet'>
<input type='hidden' name='generate' value='Y'>
<br>
<br>
</td>
</tr>
<tr>
<td colspan='2' align='center'>
<br>
<p>For example, a number with a minimum of 2 digits and a maximum of 3 digits<br>
will be a number between 10 and 999.</p>
<br>
<p><b>NOTE:</b> For division questions the number to be divided will always be the<br>
product of the 'First' and 'Second' numbers, thus ensuring an integer result.<br>
If you select a 2 digit 'First' number and a 1 digit 'Second' number the number<br>
to be divided will most likely be 3 digits in length and the other two operands<br>
will be 2 digits and 1 digits in length respectively.</p>
<p>The answers will be generated on a separate page so that you can check the work</p>
</td>
</tr>
</table>
</form>
<?php
endTemplate();
?>