added a karma ranking system to cs threads for conducting popularity contests
This commit is contained in:
parent
0400beba05
commit
f2b2832524
9 changed files with 133 additions and 6 deletions
|
|
@ -42,12 +42,16 @@
|
||||||
- [ 1433525 ] 6.9: Compilation errors
|
- [ 1433525 ] 6.9: Compilation errors
|
||||||
- base36 removed from Utility.t because it no longer exists in WebGUI::Utility.pm
|
- base36 removed from Utility.t because it no longer exists in WebGUI::Utility.pm
|
||||||
- Add tests that verify the integrity of the WebGUI Database.
|
- Add tests that verify the integrity of the WebGUI Database.
|
||||||
|
- Added a karma ranking system to CS threads for conducting popularity
|
||||||
|
contests.
|
||||||
|
|
||||||
6.8.8
|
6.8.8
|
||||||
- fix [ 1437186 ] 6.8.7 deploy DataForm package does not copy fields
|
- fix [ 1437186 ] 6.8.7 deploy DataForm package does not copy fields
|
||||||
- fix [ 1437563 ] Data picker intermittent for Admin
|
- fix [ 1437563 ] Data picker intermittent for Admin
|
||||||
- fix broken link to top of CS Assets configured as FAQs
|
- fix broken link to top of CS Assets configured as FAQs
|
||||||
- fix [ 1437977 ] richeditor selectbox options not versioned, trashed appear
|
- fix [ 1437977 ] richeditor selectbox options not versioned, trashed appear
|
||||||
|
- fixed a bug in the rich editor where the page chooser didn't have scroll
|
||||||
|
bars
|
||||||
|
|
||||||
6.8.7
|
6.8.7
|
||||||
- fix [ 1431098 ] op=becomeUser can become non-existent userIds
|
- fix [ 1431098 ] op=becomeUser can become non-existent userIds
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,15 @@ addDatabaseCache();
|
||||||
|
|
||||||
finish($session); # this line required
|
finish($session); # this line required
|
||||||
|
|
||||||
|
#-------------------------------------------------
|
||||||
|
sub addCsPopularityContest {
|
||||||
|
print "\tAdding collaboration system popularity system based upon karma.\n";
|
||||||
|
$session->db->write("alter table Collaboration add column defaultKarmaScale integer not null default 1");
|
||||||
|
$session->db->write("alter table Thread add column karma integer not null default 0");
|
||||||
|
$session->db->write("alter table Thread add column karmaScale integer not null default 1");
|
||||||
|
$session->db->write("alter table Thread add column karmaRank decimal(5,6) not null default 0");
|
||||||
|
}
|
||||||
|
|
||||||
#-------------------------------------------------
|
#-------------------------------------------------
|
||||||
sub addDatabaseCache {
|
sub addDatabaseCache {
|
||||||
print "\tAdding database cache.\n";
|
print "\tAdding database cache.\n";
|
||||||
|
|
|
||||||
|
|
@ -1133,6 +1133,11 @@ sub www_edit {
|
||||||
$var{'form.submit'} = WebGUI::Form::submit($self->session, {
|
$var{'form.submit'} = WebGUI::Form::submit($self->session, {
|
||||||
extras=>"onclick=\"this.value='".$i18n->get(452)."'; this.form.func.value='editSave'; this.form.submit();return false;\""
|
extras=>"onclick=\"this.value='".$i18n->get(452)."'; this.form.func.value='editSave'; this.form.submit();return false;\""
|
||||||
});
|
});
|
||||||
|
$var{'karmaScale.form'} = WebGUI::Form::integer($self->session, {
|
||||||
|
name=>"karmaScale",
|
||||||
|
value=>$self->getValue("karmaScale"),
|
||||||
|
defaultValue=>1
|
||||||
|
});
|
||||||
$var{'form.preview'} = WebGUI::Form::submit($self->session, {
|
$var{'form.preview'} = WebGUI::Form::submit($self->session, {
|
||||||
value=>$i18n->get("preview","Asset_Collaboration")
|
value=>$i18n->get("preview","Asset_Collaboration")
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -108,8 +108,23 @@ sub definition {
|
||||||
},
|
},
|
||||||
lastPostDate => {
|
lastPostDate => {
|
||||||
noFormPost=>1,
|
noFormPost=>1,
|
||||||
fieldType=>"hidden",
|
fieldType=>"dateTime",
|
||||||
defaultValue=>undef
|
defaultValue=>undef
|
||||||
|
},
|
||||||
|
karma => {
|
||||||
|
noFormPost=>1,
|
||||||
|
fieldType=>"integer",
|
||||||
|
defaultValue=>0
|
||||||
|
},
|
||||||
|
karmaRank => {
|
||||||
|
noFormPost=>1,
|
||||||
|
fieldType=>"hidden",
|
||||||
|
defaultValue=>0
|
||||||
|
},
|
||||||
|
karmaScale => {
|
||||||
|
noFormPost=>1,
|
||||||
|
fieldType=>"integer",
|
||||||
|
defaultValue=>1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
@ -489,6 +504,10 @@ sub processPropertiesFromFormPost {
|
||||||
if ($self->get("subscriptionGroupId") eq "") {
|
if ($self->get("subscriptionGroupId") eq "") {
|
||||||
$self->createSubscriptionGroup;
|
$self->createSubscriptionGroup;
|
||||||
}
|
}
|
||||||
|
if ($self->getParent->canModerate) {
|
||||||
|
my $karmaScale = $self->session->form("karmaScale","integer") || 1;
|
||||||
|
$self->update({karmaScale=>$karmaScale, karmaRank=>$self->get("karma")/$karmaScale});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -730,6 +749,18 @@ sub view {
|
||||||
$var->{'lock.url'} = $self->getLockUrl;
|
$var->{'lock.url'} = $self->getLockUrl;
|
||||||
$var->{'unlock.url'} = $self->getUnlockUrl;
|
$var->{'unlock.url'} = $self->getUnlockUrl;
|
||||||
|
|
||||||
|
$var->{'transfer.karma.form'} = WebGUI::Form::formHeader($self->session, {action=>$self->getUrl})
|
||||||
|
.WebGUI::Form::hidden($self->session, {
|
||||||
|
name=>"func",
|
||||||
|
value=>"transferKarma"
|
||||||
|
})
|
||||||
|
.WebGUI::Form::integer($self->session, {
|
||||||
|
name=>"karma",
|
||||||
|
value=>10
|
||||||
|
})
|
||||||
|
.WebGUI::Form::submit($self->session)
|
||||||
|
.WebGUI::Form::formFooter($self->session);
|
||||||
|
|
||||||
my $p = WebGUI::Paginator->new($self->session,$self->getUrl,$self->getParent->get("postsPerPage"));
|
my $p = WebGUI::Paginator->new($self->session,$self->getUrl,$self->getParent->get("postsPerPage"));
|
||||||
my $sql = "select asset.assetId, asset.className, assetData.revisionDate as revisionDate, assetData.url as url from asset
|
my $sql = "select asset.assetId, asset.className, assetData.revisionDate as revisionDate, assetData.url as url from asset
|
||||||
left join assetData on assetData.assetId=asset.assetId
|
left join assetData on assetData.assetId=asset.assetId
|
||||||
|
|
@ -843,6 +874,26 @@ sub www_subscribe {
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 www_transferKarma ( )
|
||||||
|
|
||||||
|
Transfers karma from the current user to this thread.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub www_transferKarma {
|
||||||
|
my $self = shift;
|
||||||
|
my $amount = $self->session->form->get("karma","integer");
|
||||||
|
# cant have them giving more karma then they have
|
||||||
|
if ($amount <= $self->session->user->karma) {
|
||||||
|
$self->session->user->karma($amount, "Thread ".$self->getId, "Transferring karma to a thread.");
|
||||||
|
my $newKarma = $self->get("karma")+$amount;
|
||||||
|
$self->update({karma=>$newKarma,karmaRank=>$newKarma/$self->get("karmaScale")});
|
||||||
|
}
|
||||||
|
return $self->www_view;
|
||||||
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 www_unarchive ( )
|
=head2 www_unarchive ( )
|
||||||
|
|
||||||
The web method to unarchive all the posts in this thread.
|
The web method to unarchive all the posts in this thread.
|
||||||
|
|
|
||||||
|
|
@ -405,6 +405,10 @@ sub definition {
|
||||||
postGroupId =>{
|
postGroupId =>{
|
||||||
fieldType=>"group",
|
fieldType=>"group",
|
||||||
defaultValue=>'2'
|
defaultValue=>'2'
|
||||||
|
},
|
||||||
|
defaultKarmaScale => {
|
||||||
|
fieldType=>"integer",
|
||||||
|
defaultValue=>1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -515,7 +519,17 @@ sub getEditForm {
|
||||||
-hoverHelp=>$i18n->get('karma rating multiplier description'),
|
-hoverHelp=>$i18n->get('karma rating multiplier description'),
|
||||||
-value=>$self->getValue("karmaRatingMultiplier")
|
-value=>$self->getValue("karmaRatingMultiplier")
|
||||||
);
|
);
|
||||||
|
$tabform->getTab("properties")->integer(
|
||||||
|
-name=>"defaultKarmaScale",
|
||||||
|
$i18n->get("default karma scale"),
|
||||||
|
-hoverHelp=>$i18n->get('default karma scale help'),
|
||||||
|
-value=>$self->getValue("defaultKarmaScale")
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
|
$tabform->getTab("properties")->hidden(
|
||||||
|
-name=>"defaultKarmaScale",
|
||||||
|
-value=>$self->getValue("defaultKarmaScale")
|
||||||
|
);
|
||||||
$tabform->getTab("properties")->hidden(
|
$tabform->getTab("properties")->hidden(
|
||||||
-name=>"karmaPerPost",
|
-name=>"karmaPerPost",
|
||||||
-value=>$self->getValue("karmaPerPost")
|
-value=>$self->getValue("karmaPerPost")
|
||||||
|
|
@ -548,6 +562,7 @@ sub getEditForm {
|
||||||
userDefined4=>$i18n->get('user defined 4'),
|
userDefined4=>$i18n->get('user defined 4'),
|
||||||
userDefined5=>$i18n->get('user defined 5'),
|
userDefined5=>$i18n->get('user defined 5'),
|
||||||
);
|
);
|
||||||
|
$options{karmaRank} = $i18n->get("karma rank") if ($self->session->setting->get("useKarma"));
|
||||||
$tabform->getTab("display")->selectBox(
|
$tabform->getTab("display")->selectBox(
|
||||||
-name=>"sortBy",
|
-name=>"sortBy",
|
||||||
-value=>[$self->getValue("sortBy")],
|
-value=>[$self->getValue("sortBy")],
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,11 @@ our $HELP = {
|
||||||
description => 'posts/page description',
|
description => 'posts/page description',
|
||||||
namespace => 'Asset_Collaboration',
|
namespace => 'Asset_Collaboration',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title => 'default karma scale',
|
||||||
|
description => 'default karma scale help',
|
||||||
|
namespace => 'Asset_Collaboration',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title => 'karma/post',
|
title => 'karma/post',
|
||||||
description => 'karma/post description',
|
description => 'karma/post description',
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,24 @@ package WebGUI::i18n::English::Asset_Collaboration;
|
||||||
|
|
||||||
our $I18N = {
|
our $I18N = {
|
||||||
|
|
||||||
|
'karma rank' => {
|
||||||
|
message => q|Karma Rank|,
|
||||||
|
context => q|a label used in sorting threads by karma divided by karma scale|,
|
||||||
|
lastUpdated => 0,
|
||||||
|
},
|
||||||
|
|
||||||
|
'default karma scale' => {
|
||||||
|
message => q|Default Karma Scale|,
|
||||||
|
context => q|a label indicating the default scale of all threads in the system|,
|
||||||
|
lastUpdated => 0,
|
||||||
|
},
|
||||||
|
|
||||||
|
'default karma scale help' => {
|
||||||
|
message => q|This is the default value that will be assigned to the karma scale field in threads. Karma scale is a weighting mechanism for karma sorting that can be used for handicaps, difficulty, etc.|,
|
||||||
|
context => q|hover help for the default karma scale field|,
|
||||||
|
lastUpdated => 0,
|
||||||
|
},
|
||||||
|
|
||||||
'assetName' => {
|
'assetName' => {
|
||||||
message => q|Collaboration System|,
|
message => q|Collaboration System|,
|
||||||
context => q|label for Asset Manager|,
|
context => q|label for Asset Manager|,
|
||||||
|
|
@ -19,8 +37,8 @@ our $I18N = {
|
||||||
},
|
},
|
||||||
|
|
||||||
'karma rating multiplier' => {
|
'karma rating multiplier' => {
|
||||||
message => q|Karma Rating Multiplier|,
|
message => q|Karma Given To Poster on Rating|,
|
||||||
lastUpdated => 0,
|
lastUpdated => 1141142205,
|
||||||
},
|
},
|
||||||
|
|
||||||
'delete file warning' => {
|
'delete file warning' => {
|
||||||
|
|
@ -891,8 +909,8 @@ submitted by a user.|,
|
||||||
},
|
},
|
||||||
|
|
||||||
'karma rating multiplier description' => {
|
'karma rating multiplier description' => {
|
||||||
message => q|If karma is enabled on your site, this amount multiplied by the rating the user gives a post will be the amount of karma the original author of the post receives.|,
|
message => q|If karma is enabled on your site, this will be the amount of karma the original author of the post receives when another user rates the post.|,
|
||||||
lastUpdated => 1119070429,
|
lastUpdated => 1141142205,
|
||||||
},
|
},
|
||||||
|
|
||||||
'filter code description' => {
|
'filter code description' => {
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,10 @@ A yes/no button to lock the thread, so that no posts can be added or edited.
|
||||||
A conditional that is true if the user is editing an existing post.
|
A conditional that is true if the user is editing an existing post.
|
||||||
<p>
|
<p>
|
||||||
|
|
||||||
|
<b>karmaScale.form</b><br>
|
||||||
|
A form element that allows moderators to set the scale of an individual thread. This is only available for threads.
|
||||||
|
<p>
|
||||||
|
|
||||||
<b>preview.title</b><br>
|
<b>preview.title</b><br>
|
||||||
The web safe title for previewing a post.
|
The web safe title for previewing a post.
|
||||||
<p>
|
<p>
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,22 @@ our $I18N = {
|
||||||
message => q|The variables below are available in the Thread template. In addition, all variables from the Post Template can be used. Labels for URLs for actions like <b>unlock.url</b>, <b>stick.url</b>, etc. are provided by the Collaboration Labels. The Pagination Template variables are also available to display multiple pages of posts and threads.
|
message => q|The variables below are available in the Thread template. In addition, all variables from the Post Template can be used. Labels for URLs for actions like <b>unlock.url</b>, <b>stick.url</b>, etc. are provided by the Collaboration Labels. The Pagination Template variables are also available to display multiple pages of posts and threads.
|
||||||
<p>
|
<p>
|
||||||
|
|
||||||
|
<b>karma.transfer.form</b><br>
|
||||||
|
A variable that displays a small form that allows a user to transfer an amount of karma from their account to the thread.
|
||||||
|
<p>
|
||||||
|
|
||||||
|
<b>karma</b><br>
|
||||||
|
Indicates the amount of karma this thread has.
|
||||||
|
<p>
|
||||||
|
|
||||||
|
<b>karmaScale</b><br>
|
||||||
|
A weighting factor for difficulty, complexity, or handicap in contests.
|
||||||
|
<p>
|
||||||
|
|
||||||
|
<b>karmaRank</b><br>
|
||||||
|
This is karma divided by karma scale.
|
||||||
|
<p>
|
||||||
|
|
||||||
<b>user.isVisitor</b><br>
|
<b>user.isVisitor</b><br>
|
||||||
A conditional indicating that the current user is a Visitor.
|
A conditional indicating that the current user is a Visitor.
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -175,7 +191,7 @@ The description of the collaboration system that this post is a part of.
|
||||||
<p>
|
<p>
|
||||||
|
|
||||||
|,
|
|,
|
||||||
lastUpdated => 1140982574,
|
lastUpdated => 1141142205,
|
||||||
},
|
},
|
||||||
|
|
||||||
'assetName' => {
|
'assetName' => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue