History: Simple Wiki Ratings
Source of version: 23 (current)
Copy to clipboard
{syntax type="markdown" editor="wysiwyg"} # Stub This page is a stub of information related to the not-very-well-documented simple wiki ratings feature. ## Enabling and Configuration Set "Simple wiki ratings" under Admin Home, Wiki, Features (tiki-admin.php?page=wiki&cookietab=2) ## FAQ 1. Where are the results displayed? tiki-poll_results.php ? Seems to not list Simple Wiki Rating results. tiki-old_polls.php ? Seems to not list Simple Wiki Rating results. The results are tabulated in the database table **tiki_user_votings**. The site pages for which the votes are applied are in field "**id**" with **values** like "wiki2". "Wiki2" in this example, is the Rating Type, "wiki" (as opposed to "article"), and the "2" indicates the "**page_id**" from database table **tiki_pages**. Don't know yet if there is a page to display the results. 2. Why doesn't the rating bar show up on pages for users with lower permissions? Because templates/tiki-show_page.tpl requires $tiki_p_assign_perm_wiki_page eq 'y' . This appears to be a bug. Consider changing that to " $tiki_p_wiki_vote_ratings eq 'y' ". 3. Can the collected votes be deleted somehow to reset the tally? ## From lib/prefs/wiki.php: {CODE(wrap="0")}'wiki_simple_ratings' => array( 'name' => tra('Simple wiki ratings'), 'description' => tra('Enable users to rate articles based on a simple numeric scale.'), 'type' => 'flag', 'default' => 'n', ), 'wiki_simple_ratings_options' => array( 'name' => tra('Wiki rating options'), 'description' => tra('List of options available for the rating of wiki pages.'), 'type' => 'text', 'separator' => ',', 'filter' => 'int', 'default' => range(1, 5), ),{CODE} ## From tiki-admin.php: {CODE(wrap="0")}"rating" => array( 'position' => '-300px -215px;', 'icon' => 'img/icons/large/rating.png', 'title' => tr('Rating'), 'help' => 'Advanced+Rating', 'disabled' => $prefs['wiki_simple_ratings'] !== 'y' && $prefs['rating_advanced'] !== 'y' && $prefs['article_user_rating'] !== 'y', ),{CODE} ## From lib/rating/ratinglib.php References database table "tiki_user_votings". {CODE(wrap="0")}function get_options( $type ) { $pref = 'rating_default_options'; switch( $type ) { case 'wiki page': $pref = 'wiki_simple_ratings_options'; break; case 'article': $pref = 'article_user_rating_options'; break; } global $tikilib; return $tikilib->get_preference($pref, range(1, 5), true); }{CODE} ## From lib/test/rating/RegisterVoteTest.php {CODE(wrap="0")}function testGetWikiPageRange() { global $prefs; $prefs['wiki_simple_ratings_options'] = range(2, 8); $lib = new RatingLib; $this->assertEquals(range(2, 8), $lib->get_options('wiki page')); }{CODE} ## From templates/tiki-show_page.tpl $tiki_p_assign_perm_wiki_page appears to be a bug. Too strong. Should perhaps be $tiki_p_wiki_vote_ratings . {CODE(wrap="0")} {if $prefs.feature_wiki_ratings eq 'y'} {include file='poll.tpl'} {/if} {if $prefs.wiki_simple_ratings eq 'y' && $tiki_p_assign_perm_wiki_page eq 'y'} <form method="post" action=""> {rating type="wiki page" id=$page_id} </form> {/if} {CODE} ## From lib/core/Tracker/Field/Rating.php: $votings = TikiDb::get()->table('tiki_user_votings'); ## From lib/polls/polllib_shared.php: $query = "select user from `tiki_user_votings` where `optionId`=?"; ' left join `tiki_user_votings` tuv on (tpo.`optionId` = tuv.`optionId`)' . $query = 'delete from `tiki_user_votings` where `id`=?'; $query = 'delete from `tiki_user_votings` where `id`=? and `optionId`=? and '; ## From lib/rating/ratinglib.php: $joins = array( '`tiki_user_votings` `uv`' ); INNER JOIN ( SELECT ' . $connect . '(`time`) `t`, `user` `u` FROM `tiki_user_votings` WHERE ' . implode(' AND ', $where) . ' GROUP BY `user` ' . $extra . ' ) `j` 'INSERT INTO `tiki_user_votings` ( `user`, `ip`, `id`, `optionId`, `time` ) VALUES( ?, ?, ?, ?, ? )', 'SELECT `optionId` FROM `tiki_user_votings` WHERE `user` = ? AND `id` = ? ORDER BY `time` DESC', ## From lib/surveys/surveylib.php: $query = 'delete from `tiki_user_votings` where `id`=?'; ## lib/test/rating/AggregationTest.php: TikiDb::get()->query('DELETE FROM `tiki_user_votings` WHERE `id` LIKE ?', array('test.%')); ## Fromlib/test/rating/RegisterVoteTest.php: return TikiDb::get()->fetchAll('SELECT `user`, `id`, `optionId` FROM `tiki_user_votings` WHERE `id` LIKE ? ORDER BY `user`, `id`, `optionId`', array('test.%')); ## lib/tikilib.php: $query = "select count(\*) from `tiki_user_votings` where `user`=? and `id`=?"; $userVotings = $this->table('tiki_user_votings'); $vote = $this->getOne("select `optionId` from `tiki_user_votings` where `user` = ? and `id` = ? order by `time` desc", array( $user, $id)); ## lib/trackers/trackerlib.php: $userVotings = $this->table('tiki_user_votings'); ... ## lib/userslib.php: $this->query('update `tiki_user_votings` set `user`=? where `user`=?', array($to, $from)); ## lib/wiki-plugins/wikiplugin_votings.php: $votings = TikiDb::get()->table('tiki_user_votings'); ## From other pages {CODE(wrap="0")}$ grep -C5 -iR "wiki_simple_ratings" \* | grep -v -e templates_c -e temp\\/cache #redacted out the above templates/admin/include_rating.tpl- {preference name=ip_can_be_checked} templates/admin/include_rating.tpl- templates/admin/include_rating.tpl- templates/admin/include_rating.tpl- <fieldset>templates/admin/include_rating.tpl- <legend>{tr}Wiki{/tr}</legend> templates/admin/include_rating.tpl: {preference name=wiki_simple_ratings} templates/admin/include_rating.tpl: <div class="adminoptionboxchild" id="wiki_simple_ratings_childcontainer">templates/admin/include_rating.tpl: {preference name=wiki_simple_ratings_options} templates/admin/include_rating.tpl- </div>templates/admin/include_rating.tpl- </fieldset>templates/admin/include_rating.tpl- templates/admin/include_rating.tpl- <fieldset>templates/admin/include_rating.tpl- <legend>{tr}Articles{/tr}</legend> \-- templates/admin/include_wiki.tpl- templates/admin/include_wiki.tpl- {preference name=feature_wiki_ratings} templates/admin/include_wiki.tpl- <div class="adminoptionboxchild" id="feature_wiki_ratings_childcontainer">templates/admin/include_wiki.tpl- [{icon _id="key" alt="{tr}Permission{/tr}"}](tiki-objectpermissions.php?permType=wiki&textFilter=ratings&show_disabled_features=y "{tr}Permission{/tr}") templates/admin/include_wiki.tpl- </div>templates/admin/include_wiki.tpl: {preference name=wiki_simple_ratings} templates/admin/include_wiki.tpl: <div class="adminoptionboxchild" id="wiki_simple_ratings_childcontainer">templates/admin/include_wiki.tpl: {preference name=wiki_simple_ratings_options} templates/admin/include_wiki.tpl- </div>templates/admin/include_wiki.tpl- templates/admin/include_wiki.tpl- {preference name=feature_backlinks} templates/admin/include_wiki.tpl- <div class="adminoptionboxchild" id="feature_backlinks_childcontainer">templates/admin/include_wiki.tpl- {preference name=wiki_backlinks_name_len} </div></fieldset>