First Commit
This commit is contained in:
1 parent
5eb9dd037d
commit
2e62c0e60b
11877 files changed
+2035312
No files matched your search
@@ -0,0 +1,257 @@
|
||||
<?php
|
||||
if (!array_key_exists('generate',$_POST) || $_POST['generate'] != 'Y') {
|
||||
header("Location: http://www.hotlunches.net/");
|
||||
exit();
|
||||
}
|
||||
|
||||
$ValidAccess = 2010;
|
||||
|
||||
require_once("include/globals.php");
|
||||
|
||||
// Set colour scheme
|
||||
$colourcss = $school_record['colour_scheme'];
|
||||
|
||||
// Setup screen background
|
||||
$background = "background: #ffffff;\n";
|
||||
|
||||
include "math.inc.php";
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title>Math Worksheets</title>
|
||||
<style type="text/css">
|
||||
<!--
|
||||
body{
|
||||
margin: 0;
|
||||
text-align: center;
|
||||
padding: 0;
|
||||
font: 12px Arial, Helvetica, sans-serif;
|
||||
background: #ffffff;
|
||||
}
|
||||
-->
|
||||
</style>
|
||||
<link rel="stylesheet" href="css/master.css" type="text/css">
|
||||
<link rel="stylesheet" href="css/layout.css" type="text/css">
|
||||
<link rel="stylesheet" href="css/top-bar.css" type="text/css">
|
||||
<link rel="stylesheet" type="text/css" href="css/primary-nav.css">
|
||||
<link rel="stylesheet" type="text/css" href="css/secondary-nav.css">
|
||||
<link rel="stylesheet" href="css/buttons.css" type="text/css">
|
||||
<link rel="stylesheet" href="css/<?php echo($colourcss) ?>" type="text/css">
|
||||
</head>
|
||||
<body>
|
||||
<center>
|
||||
<?php
|
||||
|
||||
$min_top_digits = $_POST['min_top_digits'];
|
||||
$max_top_digits = $_POST['max_top_digits'];
|
||||
$min_bottom_digits = $_POST['min_bottom_digits'];
|
||||
$max_bottom_digits = $_POST['max_bottom_digits'];
|
||||
$operation = $_POST['operation'];
|
||||
$pages = $_POST['pages'];
|
||||
|
||||
if ($min_top_digits > $max_top_digits || $min_bottom_digits > $max_bottom_digits) {
|
||||
echo("<p>Error: Minimum number of digits can not be greater than the maximum number</p>\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Setup title and op symbol
|
||||
switch ($operation) {
|
||||
case 'addition':
|
||||
$title = "Addition";
|
||||
$op = "+";
|
||||
break;
|
||||
|
||||
case 'subtraction':
|
||||
$title = "Subtraction";
|
||||
$op = "-";
|
||||
|
||||
if ($min_bottom_digits > $max_top_digits) {
|
||||
echo("<p>Error: Simple subtraction can not have more digits in the second term</p>\n");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'multiplication':
|
||||
$title = "Multiplication";
|
||||
$op = "x";
|
||||
break;
|
||||
|
||||
case 'division':
|
||||
$title = "Division";
|
||||
$op = "÷";
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
$min1 = intval(substr("100000000",0,$min_top_digits));
|
||||
$max1 = intval(substr("999999999",0,$max_top_digits));
|
||||
$min2 = intval(substr("100000000",0,$min_bottom_digits));
|
||||
$max2 = intval(substr("999999999",0,$max_bottom_digits));
|
||||
|
||||
if ($min1 == 1 && $operation != 'division') $min1 = 0;
|
||||
if ($min2 == 1 && $operation != 'division') $min2 = 0;
|
||||
|
||||
|
||||
// Display each page of questions
|
||||
$questions = array();
|
||||
$num = 0;
|
||||
|
||||
for ($p = 0; $p < $pages; $p++) {
|
||||
|
||||
// Setup the questions
|
||||
for ($r = 0; $r < $numRows; $r++) {
|
||||
|
||||
for ($q = 0; $q < $numQuestions; $q++) {
|
||||
$op1 = rand($min1,$max1);
|
||||
$op2 = rand($min2,$max2);
|
||||
|
||||
$lcount = 0;
|
||||
while ($operation == 'subtraction' && $op2 > $op1) {
|
||||
$op2 = rand($min2,$max2);
|
||||
$lcount++;
|
||||
if ($lcount > 5) {
|
||||
$op1 = rand($min1,$max1);
|
||||
$lcount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate the answer
|
||||
switch ($operation) {
|
||||
case 'addition':
|
||||
$ans = $op1 + $op2;
|
||||
break;
|
||||
|
||||
case 'subtraction':
|
||||
$ans = $op1 - $op2;
|
||||
break;
|
||||
|
||||
case 'multiplication':
|
||||
$ans = $op1 * $op2;
|
||||
break;
|
||||
|
||||
case 'division':
|
||||
$val = $op1 * $op2;
|
||||
$ans = $op2;
|
||||
$op2 = $op1;
|
||||
$op1 = $val;
|
||||
break;
|
||||
}
|
||||
|
||||
// Store the question terms
|
||||
$questions[$num]['1'] = $op1;
|
||||
$questions[$num]['2'] = $op2;
|
||||
$questions[$num]['ans'] = $ans;
|
||||
$num++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Display the questions only
|
||||
$num = 0;
|
||||
$tableStyle = "style='border: solid 1px #611A0B;'";
|
||||
for ($p = 0; $p < $pages; $p++) {
|
||||
$page = $p + 1;
|
||||
?>
|
||||
<table width='100%' cellpadding='5' cellspacing='1' border='0' <?php echo($tableStyle) ?>>
|
||||
<tr>
|
||||
<td colspan='20' align='center' class='heading'>Math Worksheet - <?php echo($title) ?> (Page <?php echo($page) ?>)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan='20'> </td>
|
||||
</tr>
|
||||
<?php
|
||||
$tableStyle = "style='border: solid 1px #611A0B; page-break-before: always'";
|
||||
|
||||
// Display the questions
|
||||
for ($r = 0; $r < $numRows; $r++) {
|
||||
echo(" <tr>\n");
|
||||
|
||||
for ($q = 0; $q < $numQuestions; $q++) {
|
||||
$op1 = $questions[$num]['1'];
|
||||
$op2 = $questions[$num]['2'];
|
||||
$ans = $questions[$num]['ans'];
|
||||
$num++;
|
||||
?>
|
||||
<td align='right' class='question'>
|
||||
<?php echo($op1) ?><br>
|
||||
<nobr><?php echo("<span class='op'>$op</span> $op2") ?></nobr><br>
|
||||
<hr>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
</td>
|
||||
<td width='10'> </td>
|
||||
<?php
|
||||
}
|
||||
|
||||
echo(" </tr>\n");
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<br>
|
||||
<table width='100%' cellpadding='0' cellspacing='0' border='0'>
|
||||
<tr>
|
||||
<td><a href='http://www.hotlunches.net/' target='_blank'><img src='images/MathLogo.gif' width='300' height='60' align='right' border='0'></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
// Display the questions and answers
|
||||
$num = 0;
|
||||
for ($p = 0; $p < $pages; $p++) {
|
||||
$page = $p + 1;
|
||||
?>
|
||||
<table width='100%' cellpadding='5' cellspacing='1' border='0' <?php echo($tableStyle) ?>>
|
||||
<tr>
|
||||
<td colspan='20' align='center' class='heading'>Math Worksheet - <?php echo($title) ?> Answers (Page <?php echo($page) ?>)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan='20'> </td>
|
||||
</tr>
|
||||
<?php
|
||||
|
||||
// Display the questions
|
||||
for ($r = 0; $r < $numRows; $r++) {
|
||||
echo(" <tr>\n");
|
||||
|
||||
for ($q = 0; $q < $numQuestions; $q++) {
|
||||
$op1 = $questions[$num]['1'];
|
||||
$op2 = $questions[$num]['2'];
|
||||
$ans = $questions[$num]['ans'];
|
||||
$num++;
|
||||
?>
|
||||
<td align='right' class='question'>
|
||||
<?php echo($op1) ?><br>
|
||||
<nobr><?php echo("<span class='op'>$op</span> $op2") ?></nobr><br>
|
||||
<hr>
|
||||
<?php echo($ans) ?><br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
</td>
|
||||
<td width='10'> </td>
|
||||
<?php
|
||||
}
|
||||
|
||||
echo(" </tr>\n");
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<br>
|
||||
<table width='100%' cellpadding='0' cellspacing='0' border='0'>
|
||||
<tr>
|
||||
<td><a href='http://www.hotlunches.net/' target='_blank'><img src='images/MathLogo.gif' width='300' height='60' align='right' border='0'></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</center>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user