alphas: 0 betas: 0 raw marks: 0 merit marks: 0 |
M = max(30α + 5β + m - 120, 15α + 5β + m) The maximum possible Merit Mark is 1120. |
Copyable URL: |
<html>
<head>
<title>Maths Tripos marks calculator</title>
<script type="text/javascript">
function toggle(element) {
document.getElementById(element).style.display
= (document.getElementById(element).style.display == "none") ? "" : "none";
}
</script>
</head>
<body>
<a href="index.html">go back</a>
<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
<table>
<thead>
<tr>
<td>Paper</td><td colspan="4">Section I</td><td colspan="5">Section II</td>
</tr>
<?
for ($p = 1; $p <= 4; $p++) {?>
<tr>
<td>Paper <?=$p?></td>
<?
for ($i = 1; $i <= 4; $i++){?>
<td><input type="text" name="p<?=$p?>I<?=$i?>"
size="1" maxlength="2" value="<?=$_REQUEST["p{$p}I{$i}"]?>"/></td>
<?}?>
<td></td>
<?
for ($i = 1; $i <= 5; $i++){?>
<td><input type="text" name="p<?=$p?>II<?=$i?>"
size="1" maxlength="2" value="<?=$_REQUEST["p{$p}II{$i}"]?>"/></td>
<?}?>
</tr>
<?}?>
<tr><td colspan="11">
<input type="submit" value="Calculate"/>
</td></tr>
</table>
</form>
<hr/>
<?
$alphas = 0;
$betas = 0;
$marks = 0;
$S1 = $S2 = array();
for ($p=1;$p<=4;$p++) {
for ($i=1;$i<=4;$i++) {
$S1[$p][$i] = $_REQUEST["p{$p}I{$i}"]; //section 1
}
for ($i=1;$i<=5;$i++) {
$S2[$p][$i] = $_REQUEST["p{$p}II{$i}"]; //section 2
}
}
for ($p=1;$p<=4;$p++){
for ($i=1; $i<=4;$i++){
$marks += $S1[$p][$i];
if ($S1[$p][$i] > 10 or $S1[$p][$i] < 0)
die('Section I questions are out of 10.');
if ($S1[$p][$i] >= 8) $betas ++;
}
for ($i=1; $i<=5;$i++){
$marks += $S2[$p][$i];
if ($S2[$p][$i] > 20 or $S2[$p][$i] < 0)
die('Section II questions are out of 20.');
if ($S2[$p][$i] >= 15) $alphas ++;
elseif ($S2[$p][$i] >= 10) $betas++;
}
}
$M1 = 15*$alphas + 5*$betas + $marks;
$M2 = 30*$alphas + 5*$betas + $marks - 120;
$M = max($M1, $M2);
?>
<table style="width: 100%;">
<tr>
<td style="width: 40%;">
alphas: <?=$alphas?><br/>
betas: <?=$betas?><br/>
raw marks: <?=$marks?><br/>
<b>merit marks: <?=$M?></b><br/>
</td>
<td>
M = max(30α + 5β + m - 120, 15α + 5β + m)<br/><br/>
The maximum possible Merit Mark is 1120.
</td>
</tr>
<tr><td colspan="2">
Copyable URL:
<textarea rows="3" style="width: 100%;" disabled="disabled">
<?php echo "http://jmft2.user.srcf.net/ia-triposmarks.php?";
for ($p=1;$p<=4;$p++) {
for ($i=1;$i<=4;$i++) {
if ($_REQUEST["p{$p}I{$i}"] != "")
echo "p{$p}I{$i}=".$_REQUEST["p{$p}I{$i}"]."&";
}
for ($j=1;$j<=5;$j++) {
if ($_REQUEST["p{$p}II{$j}"] != "")
echo "p{$p}II{$j}=".$_REQUEST["p{$p}II{$j}"]."&";
}
}
?>
</textarea>
</td></tr></table>
<hr/>
<a href="javascript:toggle('secret')">show source</a>
<div id="secret" style="display: none;">
<?highlight_file(__FILE__);?>
</div>
</body>
</html>