Changeset 26901 for branches/2.6/admin/rating_user.php
- Timestamp:
- Jan 21, 2014, 11:50:59 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.6/admin/rating_user.php
r26461 r26901 36 36 } 37 37 38 $consensus_top_number = $conf['top_number']; 39 if (isset($_GET['consensus_top_number'])) 40 { 41 $consensus_top_number = (int)$_GET['consensus_top_number']; 42 } 43 38 44 // build users 39 45 global $conf; … … 61 67 } 62 68 63 69 // by user aggregation 64 70 $image_ids = array(); 65 71 $by_user_ratings = array(); … … 88 94 $rating['uid'] = (int)$row['user_id']; 89 95 $rating['aid'] = $usr['anon'] ? $row['anonymous_id'] : ''; 96 $rating['last_date'] = $row['date']; 90 97 } 91 98 $rating['rates'][$row['rate']][] = array( … … 114 121 } 115 122 123 //all image averages 116 124 $query='SELECT element_id, 117 125 AVG(rate) AS avg … … 125 133 } 126 134 135 $query='SELECT id 136 FROM '.IMAGES_TABLE.' 137 ORDER by rating_score DESC 138 LIMIT '.$consensus_top_number; 139 $best_rated = array_flip( array_from_query($query, 'id')); 140 141 // by user stats 127 142 foreach($by_user_ratings as $id => &$rating) 128 143 { 129 $c=0; $s=0; $ss=0; $consensus_dev=0; 144 $c=0; $s=0; $ss=0; $consensus_dev=0; $consensus_dev_top=0; $consensus_dev_top_count=0; 130 145 foreach($rating['rates'] as $rate => $rates) 131 146 { … … 136 151 foreach($rates as $id_date) 137 152 { 138 $consensus_dev += abs($rate - $all_img_sum[$id_date['id']]['avg']); 153 $dev = abs($rate - $all_img_sum[$id_date['id']]['avg']); 154 $consensus_dev += $dev; 155 if (isset($best_rated[$id_date['id']])) 156 { 157 $consensus_dev_top += $dev; 158 $consensus_dev_top_count++; 159 } 139 160 } 140 161 } 141 162 142 163 $consensus_dev /= $c; 164 if ($consensus_dev_top_count) 165 $consensus_dev_top /= $consensus_dev_top_count; 143 166 144 167 $var = ($ss - $s*$s/$c)/$c; … … 148 171 'avg' => $s/$c, 149 172 'cv' => $s==0 ? -1 : sqrt($var)/($s/$c), // http://en.wikipedia.org/wiki/Coefficient_of_variation 150 'cd' => $consensus_dev 173 'cd' => $consensus_dev, 174 'cdtop' => $consensus_dev_top_count ? $consensus_dev_top : '' 151 175 ); 152 176 } … … 214 238 'F_ACTION' => get_root_url().'admin.php', 215 239 'F_MIN_RATES' => $filter_min_rates, 240 'CONSENSUS_TOP_NUMBER' => $consensus_top_number, 216 241 'available_rates' => $conf['rate_items'], 217 242 'ratings' => $by_user_ratings,
Note: See TracChangeset
for help on using the changeset viewer.