DeanWhitehouse Posted June 23, 2009 Share Posted June 23, 2009 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"))))))) Quote Link to comment https://forums.phpfreaks.com/topic/163351-complicated-maths-issue-s/ Share on other sites More sharing options...
DeanWhitehouse Posted June 24, 2009 Author Share Posted June 24, 2009 No one? or is the question unclear? Quote Link to comment https://forums.phpfreaks.com/topic/163351-complicated-maths-issue-s/#findComment-862544 Share on other sites More sharing options...
MadTechie Posted June 24, 2009 Share Posted June 24, 2009 I can't make sense of the logic your using, why are use counting the rows ?! $pass += (6 * mysql_num_rows($sql)); and in the excel what's X9 related to ? Quote Link to comment https://forums.phpfreaks.com/topic/163351-complicated-maths-issue-s/#findComment-862549 Share on other sites More sharing options...
DeanWhitehouse Posted June 24, 2009 Author Share Posted June 24, 2009 Counting the rows is so that the point system is based on the number of units ( number of rows ) And cell X9 is just a total of the points (so my $points variable) Quote Link to comment https://forums.phpfreaks.com/topic/163351-complicated-maths-issue-s/#findComment-862552 Share on other sites More sharing options...
Ken2k7 Posted June 24, 2009 Share Posted June 24, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/163351-complicated-maths-issue-s/#findComment-862656 Share on other sites More sharing options...
Daniel0 Posted June 25, 2009 Share Posted June 25, 2009 Doing it on paper, how would you calculate it? Quote Link to comment https://forums.phpfreaks.com/topic/163351-complicated-maths-issue-s/#findComment-863226 Share on other sites More sharing options...
DeanWhitehouse Posted June 25, 2009 Author Share Posted June 25, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/163351-complicated-maths-issue-s/#findComment-863806 Share on other sites More sharing options...
MadTechie Posted June 25, 2009 Share Posted June 25, 2009 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! Quote Link to comment https://forums.phpfreaks.com/topic/163351-complicated-maths-issue-s/#findComment-863815 Share on other sites More sharing options...
Ken2k7 Posted June 26, 2009 Share Posted June 26, 2009 No one? or is the question unclear? Pointless? I answered your question. Well, excuse me for answering it. I won't be answering your questions anymore. Quote Link to comment https://forums.phpfreaks.com/topic/163351-complicated-maths-issue-s/#findComment-863817 Share on other sites More sharing options...
DeanWhitehouse Posted June 26, 2009 Author Share Posted June 26, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/163351-complicated-maths-issue-s/#findComment-863837 Share on other sites More sharing options...
chmpdog Posted June 26, 2009 Share Posted June 26, 2009 Its seems correct Quote Link to comment https://forums.phpfreaks.com/topic/163351-complicated-maths-issue-s/#findComment-863924 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.