Jump to content

Complicated Maths issue :s


DeanWhitehouse

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:

=IF(X9>=252,"DDD",IF(X9>=228,"DDM",IF(X9>=204,"DMM",IF(X9>=180,"MMM",IF(X9>=156,"MMP",IF(X9>=132,"MPP",IF(X9>=108,"PPP","R")))))))

Link to comment
Share on other sites

I can't make sense of it either. :-\

 

Someone needs to learn to communicate better:

 

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.

Stop starting you sentence with "So my problem..." and "The problem is..." if you don't specify what it is. The first one tells me what you're doing. It doesn't tell me the problem. The second one doesn't tell me what the problem is either. How would I know if your math is correct. :-\ It's like me asking you if this is correct - 5*5+3*4. Mathematically, it is an equation, but can you tell me if it's correct?

Link to comment
Share on other sites

I can't make sense of it either. :-\

 

Someone needs to learn to communicate better:

 

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.

Stop starting you sentence with "So my problem..." and "The problem is..." if you don't specify what it is. The first one tells me what you're doing. It doesn't tell me the problem. The second one doesn't tell me what the problem is either. How would I know if your math is correct. :-\ It's like me asking you if this is correct - 5*5+3*4. Mathematically, it is an equation, but can you tell me if it's correct?

 

Someone needs to learn what a help forum is, if you don't understand the question then don't anwser with your pointless post.

 

And Daniel0, im not sure, i believe what i have is correct, but i have no way to be sure, logicaly is it correct?

Link to comment
Share on other sites

Someone needs to learn what a help forum is, if you don't understand the question then don't anwser with your pointless post.

Hardly pointless, if no one said they don't understand then your never know,

some response is better then none.

if someone say you need to explain it better or even can you show us your calculation (as if it was on paper), them that means we can't work with what you have!

 

as Ken2k7 says:~

How would I know if your math is correct. :-\ It's like me asking you if this is correct - 5*5+3*4. Mathematically, it is an equation, but can you tell me if it's correct?

 

And Daniel0, im not sure, i believe what i have is correct, but i have no way to be sure, logicaly is it correct?

Sure theirs a way to be sure, use what they have and check your doing the same! or at least getting the same results!

Link to comment
Share on other sites

Someone needs to learn what a help forum is, if you don't understand the question then don't anwser with your pointless post.

Hardly pointless, if no one said they don't understand then your never know,

some response is better then none.

if someone say you need to explain it better or even can you show us your calculation (as if it was on paper), them that means we can't work with what you have!

 

as Ken2k7 says:~

How would I know if your math is correct. :-\ It's like me asking you if this is correct - 5*5+3*4. Mathematically, it is an equation, but can you tell me if it's correct?

 

And Daniel0, im not sure, i believe what i have is correct, but i have no way to be sure, logicaly is it correct?

Sure theirs a way to be sure, use what they have and check your doing the same! or at least getting the same results!

If he asked me to explain it better i would of but starting a replie by saying i need to learn to communicate better and then telling me what to do "Stop starting you sentence with "So my problem..." and "The problem is..." us hardly going to get a respone praising him for his reply.

 

And i anwsered daniel0's question about writing it down ;)

 

And yes i could do that but that would mean waiting until the college has been shown the system and then i have time to add all 18 units with all 10 - 12 criteria per unit, all i am asking is if the logic of the code seems sound or if it looks wrong.

 

P.s. i didn't say there wasn't a way to be sure i said i have no way to be sure

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.