@@ -242,11 +242,12 @@ public static function moodleoverflow_sort_answers_by_ratings($posts) {
242242 $ sortedposts [0 ] = $ parentpost ;
243243
244244 // Check if solved posts are preferred over helpful posts.
245- $ solutionspreferred = $ posts [ array_key_first ( $ posts )]-> ratingpreference == 1 ;
246- var_dump ( ' start ' );
247- var_dump ( $ posts ) ;
248- // Sort the answer posts by ratings.
245+ $ solutionspreferred = false ;
246+ if ( $ posts [ array_key_first ( $ posts )]-> ratingpreference == 1 ) {
247+ $ solutionspreferred = true ;
248+ }
249249
250+ // Sort the answer posts by ratings.
250251 // Build groups of different types of answers (Solved and helpful, only solved/helpful, other).
251252 // statusteacher == 1 means the post is marked as solved.
252253 // statusstarter == 1 means the post is marked as helpful.
@@ -343,15 +344,12 @@ public static function moodleoverflow_sort_answers_by_ratings($posts) {
343344 }
344345
345346 // Rearrange the indices and return the sorted posts.
346- var_dump ('sortedpost ' );
347- var_dump ($ sortedposts );
348347
349348 $ neworder = array ();
350349 foreach ($ sortedposts as $ post ) {
351350 $ neworder [$ post ->id ] = $ post ;
352351 }
353- var_dump ('neworder ' );
354- var_dump ($ neworder );
352+
355353 // return now the sorted posts.
356354 return $ neworder ;
357355 }
@@ -831,7 +829,7 @@ private static function moodleoverflow_quicksort_post_by_votes(array &$posts, $l
831829 }
832830 if ($ left <= $ right ) {
833831 $ temp = $ posts [$ right ];
834- $ post [$ right ] = $ posts [$ left ];
832+ $ posts [$ right ] = $ posts [$ left ];
835833 $ posts [$ left ] = $ temp ;
836834 $ right --;
837835 $ left ++;
0 commit comments