@@ -242,11 +242,12 @@ public static function moodleoverflow_sort_answers_by_ratings($posts) {
242
242
$ sortedposts [0 ] = $ parentpost ;
243
243
244
244
// 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
+ }
249
249
250
+ // Sort the answer posts by ratings.
250
251
// Build groups of different types of answers (Solved and helpful, only solved/helpful, other).
251
252
// statusteacher == 1 means the post is marked as solved.
252
253
// statusstarter == 1 means the post is marked as helpful.
@@ -343,15 +344,12 @@ public static function moodleoverflow_sort_answers_by_ratings($posts) {
343
344
}
344
345
345
346
// Rearrange the indices and return the sorted posts.
346
- var_dump ('sortedpost ' );
347
- var_dump ($ sortedposts );
348
347
349
348
$ neworder = array ();
350
349
foreach ($ sortedposts as $ post ) {
351
350
$ neworder [$ post ->id ] = $ post ;
352
351
}
353
- var_dump ('neworder ' );
354
- var_dump ($ neworder );
352
+
355
353
// return now the sorted posts.
356
354
return $ neworder ;
357
355
}
@@ -831,7 +829,7 @@ private static function moodleoverflow_quicksort_post_by_votes(array &$posts, $l
831
829
}
832
830
if ($ left <= $ right ) {
833
831
$ temp = $ posts [$ right ];
834
- $ post [$ right ] = $ posts [$ left ];
832
+ $ posts [$ right ] = $ posts [$ left ];
835
833
$ posts [$ left ] = $ temp ;
836
834
$ right --;
837
835
$ left ++;
0 commit comments