我一直在努力争取一些复杂的排名系统。排名取决于学生独立于分数的分数。点计算对我来说没问题。问题出现在打破关系时,因为这取决于完全不同的学生标记。学生可以有相似的分数,但分数有所不同,可以用来打破平局,以防一些学生在积分上打分。我需要帮助,因为我卡住了。请参考我的照片以获得一个粗略的想法,并告诉我是否可以完成。我还包括了一些我的代码。php中的复杂排名
<?php
$rank_by_point=array();
//loop out students and get their admission number from which you calculate individual points based on an algorithm
foreach($students as $student => $student_no){
array_push($rank_by_point[$student_no],calculatePoints($student_no));
}
//sorting the points from highest to lowest
arsort($rank_by_point);
//the ranking code down here
$ties=array();
$break=array();
$initial_positions=array();
$rank = 0;
$last = false;
foreach($rank_by_point as $key => $value){
if($last != $value){
$last = $value;
$rank++;
}else{
//when a tie is detected add the values to a tie array
array_push($ties[$key],$rank);
}
array_push($initial_positions[$key],$rank);
}
//spliting of ties is done by getting marks and rearrangin the tie
foreach($ties as $admno => $st_rank){
$read_position=$rank;//same value for all keys in the ties array
$getmarks=getMarks($admno);
array_push($break[$admno],$getmarks);
//reorder the array in desc order
arsort($break);
}
//reranking the ties. i got stuck here :-(
?>
你好。在使用分数进行排名时,关联使用标记来打破。我确实尝试了代码的修改版本,但订购那些绑定了 –
的订单时仍存在问题。 – Barmar