Classify exam grades into leagues

Course Queries Competitions/Entrance Exams 2 years ago

0 2 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Competitions/Entrance Exams related to Course Queries. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (2)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

 

Hey guys I want to make an academic-oriented matching website that allows boys and girls to find their potential partners through academic performance and hobbies.

I was just thinking about convert quantity of exam grades eg. A, B, C and convert them into leagues like S-class, A-class. First I want to convert exam grade A into integer of 5, exam grade B into integer of 4 and so on. Then I sum them up and classify them into their respective classes.

The original and tiring code... I'm not sure whether it's going to work.

$obtaindata = mysql_fetch_assoc(mysql_query('SELECT * FROM userinfo WHERE primaryemel="' . $_COOKIE['smkdtuser'] . '"'));

$pmrresults = json_decode($obtaindata['pmr']);
$spmresults = json_decode($obtaindata['spm']);
$upsresults = json_decode($obtaindata['upsr']);

function calculateClassForPMR ($pmrresults) {
$aquality = (int)$pmrresults['a'] * 5;
$bquality = (int)$pmrresults['b'] * 4;
$cquality = (int)$pmrresults['c'] * 3;
$dquality = (int)$pmrresults['d'] * 2;
$gquality = (int)$pmrresults['g'] * 1;

$additup = $aquality + $bquality + $cquality + $dquality + $gquality;

//Classify sum of scores to their respective class
if ($additup => 35) {$classified = "s";}
elseif ($additup >= 29 && $additup <= 34) {$classified = "a";}
elseif ($additup >= 23 && $additup <= 28) {$classified = "b";}
elseif ($additup >= 17 && $additup <= 22) {$classified = "c";}
elseif ($additup >= 11 && $additup <= 16) {$classified = "d";}
elseif ($additup >= 0 && $additup <= 10) {$classified = "e";}
else {$classified = "wtf";};

return $classified; }

Don't blame me though ,I was just started learning php and try to do something weird...

Any replies or comments are highly appreciated.

profilepic.png
manpreet 2 years ago

when using json_decode i assume that you have {"a":1,"b":2,"c":3,"d":4,"e":5} something like this containt in that tabel row. Try to use :

$pmrresults = var_dump(json_decode($obtaindata['pmr'], true)) then you can use $pmrresults['a'];

You have to json_encode() when you store values to DB

I don't want to rent another server just to test it... it's costly. ... user XAMPP it's free for testing.


0 views   0 shares

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.