Changeset 26901


Ignore:
Timestamp:
01/21/14 23:50:59 (6 years ago)
Author:
rvelices
Message:

merge -r26900 from trunk to 2.6
admin rating user improvements

  • add last rate date for user
  • add consensus deviation but only based on the best rated photos (e.g. how much this user tries to change the best rated photos)
Location:
branches/2.6/admin
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/2.6/admin/rating.php

    r26838 r26901  
    7676    $page['user_filter'] = ' AND r.user_id = '.$conf['guest_id']; 
    7777  } 
    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'] ); 
    9778} 
    9879 
  • branches/2.6/admin/rating_user.php

    r26461 r26901  
    3636} 
    3737 
     38$consensus_top_number = $conf['top_number']; 
     39if (isset($_GET['consensus_top_number'])) 
     40{ 
     41  $consensus_top_number = (int)$_GET['consensus_top_number']; 
     42} 
     43 
    3844// build users 
    3945global $conf; 
     
    6167} 
    6268 
    63  
     69// by user aggregation 
    6470$image_ids = array(); 
    6571$by_user_ratings = array(); 
     
    8894    $rating['uid'] = (int)$row['user_id']; 
    8995    $rating['aid'] = $usr['anon'] ? $row['anonymous_id'] : ''; 
     96    $rating['last_date'] = $row['date']; 
    9097  } 
    9198  $rating['rates'][$row['rate']][] = array( 
     
    114121} 
    115122 
     123//all image averages 
    116124$query='SELECT element_id, 
    117125    AVG(rate) AS avg 
     
    125133} 
    126134 
     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 
    127142foreach($by_user_ratings as $id => &$rating) 
    128143{ 
    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; 
    130145  foreach($rating['rates'] as $rate => $rates) 
    131146  { 
     
    136151    foreach($rates as $id_date) 
    137152    { 
    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      } 
    139160    } 
    140161  } 
    141162 
    142163  $consensus_dev /= $c; 
     164  if ($consensus_dev_top_count) 
     165    $consensus_dev_top /= $consensus_dev_top_count; 
    143166 
    144167  $var = ($ss - $s*$s/$c)/$c; 
     
    148171    'avg' => $s/$c, 
    149172    '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 : '' 
    151175  ); 
    152176} 
     
    214238  'F_ACTION' => get_root_url().'admin.php', 
    215239  'F_MIN_RATES' => $filter_min_rates, 
     240  'CONSENSUS_TOP_NUMBER' => $consensus_top_number, 
    216241  'available_rates' => $conf['rate_items'], 
    217242  'ratings' => $by_user_ratings, 
  • branches/2.6/admin/themes/default/template/rating_user.tpl

    r26838 r26901  
    3131        <input type="text" size="5" name="f_min_rates" value="{$F_MIN_RATES}"> 
    3232        </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 
    3338        <input type="submit" value="{'Submit'|@translate}"> 
    3439        </label> 
     
    4449        aaSorting: [[4,'desc']], 
    4550        aoColumnDefs: [ 
     51                /*{ 
     52                        aTargets: ["dtc_user"] 
     53                },*/ 
    4654                { 
    47                         aTargets: ["dtc_user"], 
     55                        aTargets: ["dtc_date"], 
     56                        asSorting: ["desc","asc"] 
    4857                }, 
    4958                { 
     
    93102<tr class="throw"> 
    94103        <td class="dtc_user">{'Username'|@translate}</td> 
     104        <td class="dtc_date">{'Last'|@translate}</td> 
    95105        <td class="dtc_stat">{'Number of rates'|@translate}</td> 
    96106        <td class="dtc_stat">{'Average rate'|@translate}</td> 
    97107        <td class="dtc_stat">{'Variation'|@translate}</td> 
    98108        <td class="dtc_stat">{'Consensus deviation'|@translate|@replace:' ':'<br>'}</td> 
     109        <td class="dtc_stat">{'Consensus deviation'|@translate|@replace:' ':'<br>'} {$CONSENSUS_TOP_NUMBER}</td> 
    99110{foreach from=$available_rates item=rate} 
    100111        <td class="dtc_rate">{$rate}</td> 
     
    106117<tr> 
    107118        <td>{$user}</td> 
     119        <td>{$rating.last_date}</td> 
    108120        <td>{$rating.count}</td> 
    109121        <td>{$rating.avg|@number_format:2}</td> 
    110122        <td>{$rating.cv|@number_format:3}</td> 
    111123        <td>{$rating.cd|@number_format:3}</td> 
     124        <td>{if !empty($rating.cdtop)}{$rating.cdtop|@number_format:3}{/if}</td> 
    112125        {foreach from=$rating.rates item=rates key=rate} 
    113126        <td>{if !empty($rates)} 
Note: See TracChangeset for help on using the changeset viewer.