Changeset 26900
- Timestamp:
- Jan 21, 2014, 11:50:06 PM (10 years ago)
- Location:
- trunk/admin
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/rating.php
r26837 r26900 76 76 $page['user_filter'] = ' AND r.user_id = '.$conf['guest_id']; 77 77 } 78 }79 80 if (isset($_GET['del']))81 {82 include_once(PHPWG_ROOT_PATH.'include/functions_rate.inc.php');83 $del_params = urldecode( $_GET['del'] );84 parse_str($del_params, $vars);85 if ( !is_numeric($vars['e']) or !is_numeric($vars['u']) )86 {87 die('Hacking attempt');88 }89 $query = '90 DELETE FROM '. RATE_TABLE .'91 WHERE element_id=' . $vars['e'] . '92 AND user_id=' . $vars['u'] . '93 AND anonymous_id=\'' . $vars['a'] . '\'94 ;';95 pwg_query($query);96 update_rating_score( $vars['e'] );97 78 } 98 79 -
trunk/admin/rating_user.php
r26461 r26900 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, -
trunk/admin/themes/default/template/rating_user.tpl
r26837 r26900 31 31 <input type="text" size="5" name="f_min_rates" value="{$F_MIN_RATES}"> 32 32 </label> 33 <label>{'Consensus deviation'|@translate} 34 <input type="text" size="5" name="consensus_top_number" value="{$CONSENSUS_TOP_NUMBER}"> 35 {'Best rated'|@translate} 36 </label> 37 33 38 <input type="submit" value="{'Submit'|@translate}"> 34 39 </label> … … 44 49 aaSorting: [[4,'desc']], 45 50 aoColumnDefs: [ 51 /*{ 52 aTargets: ["dtc_user"] 53 },*/ 46 54 { 47 aTargets: ["dtc_user"], 55 aTargets: ["dtc_date"], 56 asSorting: ["desc","asc"] 48 57 }, 49 58 { … … 93 102 <tr class="throw"> 94 103 <td class="dtc_user">{'Username'|@translate}</td> 104 <td class="dtc_date">{'Last'|@translate}</td> 95 105 <td class="dtc_stat">{'Number of rates'|@translate}</td> 96 106 <td class="dtc_stat">{'Average rate'|@translate}</td> 97 107 <td class="dtc_stat">{'Variation'|@translate}</td> 98 108 <td class="dtc_stat">{'Consensus deviation'|@translate|@replace:' ':'<br>'}</td> 109 <td class="dtc_stat">{'Consensus deviation'|@translate|@replace:' ':'<br>'} {$CONSENSUS_TOP_NUMBER}</td> 99 110 {foreach from=$available_rates item=rate} 100 111 <td class="dtc_rate">{$rate}</td> … … 106 117 <tr> 107 118 <td>{$user}</td> 119 <td>{$rating.last_date}</td> 108 120 <td>{$rating.count}</td> 109 121 <td>{$rating.avg|@number_format:2}</td> 110 122 <td>{$rating.cv|@number_format:3}</td> 111 123 <td>{$rating.cd|@number_format:3}</td> 124 <td>{if !empty($rating.cdtop)}{$rating.cdtop|@number_format:3}{/if}</td> 112 125 {foreach from=$rating.rates item=rates key=rate} 113 126 <td>{if !empty($rates)}
Note: See TracChangeset
for help on using the changeset viewer.