Skip to content

Commit 544db80

Browse files
committed
Revert "try to fix sort bug"
This reverts commit c2e97b1.
1 parent c2e97b1 commit 544db80

File tree

2 files changed

+3
-33
lines changed

2 files changed

+3
-33
lines changed

classes/ratings.php

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,9 @@ public static function moodleoverflow_get_reputation($moodleoverflowid, $userid
228228
/**
229229
* Sort the answers of a discussion by their marks and votes.
230230
*
231-
* @param array $posts all the posts from a discussion.
231+
* @param object $posts all the posts from a discussion.
232232
*/
233233
public static function moodleoverflow_sort_answers_by_ratings($posts) {
234-
235234
// Create a copy that only has the answer posts and save the parent post.
236235
$answerposts = $posts;
237236
$parentpost = array_shift($answerposts);
@@ -848,29 +847,4 @@ private static function moodleoverflow_quicksort_post_by_votes(array &$posts, $l
848847
}
849848
}
850849

851-
private static function moodleoverflow_mergesort_post_by_votes(array &$posts, $low, $high): array {
852-
$length = $high - $low;
853-
if ($length <= 1) {
854-
return $posts;
855-
}
856-
$mid = $low + (int) ($length / 2);
857-
858-
self::moodleoverflow_mergesort_post_by_votes($posts, $low, $mid);
859-
self::moodleoverflow_mergesort_post_by_votes($posts, $mid + 1, $high);
860-
return self::moodleoverflow_merge_posts($post, $low, $mid, $mid+1, $high);
861-
}
862-
863-
private static function moodleoverflow_merge_posts(&$posts, $leftlow, $lefthigh, $rightlow, $righthigh) {
864-
while ($leftlow <= $lefthigh && $rightlow <= $righthigh) {
865-
// Sort after votesdifference, then sort after time created.
866-
if ($posts[$leftlow]->votesdifference > $posts[$rightlow]->votesdifference) {
867-
$leftlow++;
868-
} else {
869-
$value = $posts[$rightlow];
870-
$index = $rightlow;
871-
872-
//Shift all the element
873-
}
874-
}
875-
}
876850
}

locallib.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -928,12 +928,8 @@ function moodleoverflow_print_discussion($course, $cm, $moodleoverflow, $discuss
928928

929929
// Retrieve all posts of the discussion.
930930
$posts = moodleoverflow_get_all_discussion_posts($discussion->id, $istracked, $modulecontext);
931-
/*$newpost = [];
932-
foreach($posts as $posti) {
933-
$newpost[] = $posti->message;
934-
}
935-
var_dump($newpost);
936-
*/$usermapping = anonymous::get_userid_mapping($moodleoverflow, $discussion->id);
931+
932+
$usermapping = anonymous::get_userid_mapping($moodleoverflow, $discussion->id);
937933

938934
// Start with the parent post.
939935
$post = $posts[$post->id];

0 commit comments

Comments
 (0)