File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
public/main/gradebook/lib/be Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -665,18 +665,23 @@ public function lock($locked)
665665 */
666666 public static function getCurrentUserRanking ($ userId , $ studentList )
667667 {
668+ $ previousScore = null ;
668669 $ ranking = null ;
670+ $ position = null ;
669671 $ currentUserId = $ userId ;
670672 if (!empty ($ studentList ) && !empty ($ currentUserId )) {
671673 $ studentList = array_map ('floatval ' , $ studentList );
672- asort ($ studentList );
673- $ ranking = $ count = count ($ studentList );
674-
675- foreach ($ studentList as $ userId => $ position ) {
674+ arsort ($ studentList );
675+ $ count = count ($ studentList );
676+ foreach ($ studentList as $ userId => $ score ) {
677+ $ position ++;
678+ if ($ previousScore === null || $ score < $ previousScore ) {
679+ $ ranking = $ position ;
680+ }
681+ $ previousScore = $ score ;
676682 if ($ currentUserId == $ userId ) {
677683 break ;
678684 }
679- $ ranking --;
680685 }
681686
682687 // If no ranking was detected.
You can’t perform that action at this time.
0 commit comments