Lee Traynor's PHP Tutorials - A Simple Method for Distributing ECTS Grades

0) { $portion_students = $group_size[$i] / $total_students; $j = $start_j; $subtotal = $progress + $portion_students; while ($j < 4 and $subtotal > $limits[$j]) $j++; switch ($j - $start_j) { case 0: $grade_j = $j; break; case 1: $remainder[$i] = $limits[$j - 1] - $progress; if (round ($portion_students * $total_students / 2, 4) <= round ($remainder[$i] * $total_students, 4)) $grade_j = $j - 1; else $grade_j = $j; break; case 2: switch ($start_j) { case 0: if ($subtotal - 0.25 > 0) $grade_j = 1; else $grade_j = 2; break; case 1: $grade_j = 2; break; case 2: if (round ($progress, 4) <= 0.4) $grade_j = 2; else $grade_j = 3; break; } break; case 3: case 4: $grade_j = 2; break; } $distributed_grade[$i] = $grades[$grade_j]; $progress += $portion_students; $start_j = $j; } } echo "$b$b"; if (isset ($group_size) and $total_students > 0) { echo "$b"; } echo "$b$b
$b$b"; echo "$b"; echo "$b"; for ($i = 0; $i < count ($group_size); $i++) { if ((isset ($group_size[$i]) and $group_size[$i] > 0) or $rank_description[$i] != "") { echo ""; if (isset ($rank_description[$i]) and $rank_description[$i] == "") echo ""; else echo ""; echo "$b"; } } echo "$b
Your Results
Ranked GroupNumber of StudentsECTS Grade
$i $rank_description[$i]$group_size[$i]"; if (isset ($distributed_grade[$i])) echo "$distributed_grade[$i]"; else echo "-"; echo "
Total$total_students
$b
$b$b"; echo "$b"; echo "$b"; echo "$b"; for ($i = 0; $i < $imax; $i++) { echo "$b"; } echo "$b$b"; echo "$b"; echo "
New Distribution
Ranked GroupNumber of Students
$i:
No of ranking levels:
$b
$b"; ?>