Jump to content

ComplicatedMaths-issue


ricky_vancouver

Recommended Posts

Hey long time no post

 

So my problem, i am developing a grading system for my college and a function i wrote to work out the grade for the course is based on there current system but modified to be more flexible.

 

The problem is is that i don't know if my maths is correct in it, and have no way to reliably test it.

 

So, the function

function WorkOutYearGrade($ProgID){	$ProgID = SecureVar($ProgID);		$sql_check = mysql_query("SELECT * FROM student_grade WHERE program_id = '".$ProgID."' AND PSN = '".$_SESSION['PSN']."'");	if(mysql_num_rows($sql_check) != 0)	{		$sql = mysql_query("SELECT id FROM units WHERE program_id = '".$ProgID."'");		$distinction = 0;		$merit = 0;		$pass = 0;			while($rows = mysql_fetch_assoc($sql))		{			$grade = work_out_grade_average("program",$ProgID,$rows['id']);						if($grade == "Pass")			{				$pass += (6 * mysql_num_rows($sql));			}			elseif($grade == "Merit")			{				$merit += (12 * mysql_num_rows($sql));			}			elseif($grade == "Distinction")			{				$distinction += (18 * mysql_num_rows($sql));			}		}		$points = round(($distinction) + ($merit) + ($pass));				$ExpPoints_d = 18 * mysql_num_rows($sql);		$ExpPoints_m = 12 * mysql_num_rows($sql);		$ExpPoints_p = 6 * mysql_num_rows($sql);		$dist = $ExpPoints_d + $ExpPoints_m + $ExpPoints_p;		$merit = $ExpPoints_m + $ExpPoints_p;		$pass = $ExpPoints_p;							if($points == 0)		{			return "<span style=\"color:red;\">R</span>";		}		else		{			switch($points)			{				case $points >= $dist;					return "DDD";					break;				case $points >= $merit + (48 * mysql_num_rows($sql));					return "DDM";					break;				case $points >= $merit + (24 * mysql_num_rows($sql));					return "DMM";					break;				case $points >= $merit;					return "MMM";					break;				case $points >= $pass + (48 * mysql_num_rows($sql));					return "MMP";					break;				case $points >= $pass + (24 * mysql_num_rows($sql));					return "MPP";					break;				case $points >= $pass;					return "PPP";					break;				default;					return "<span style=\"color:red;\">R</span>";					break;			}		}	}}

It is based on their point system which is:

 

a pass = 6

a merit = 12

a distinction = 18

 

The point system the college was using is based on having 18 units where as mine is dynamic and based on how many units there are.

 

Direct from their spreadsheet system:

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.