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
|
|
@ -1133,6 +1133,11 @@ sub www_edit {
|
|||
$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;\""
|
||||
});
|
||||
$var{'karmaScale.form'} = WebGUI::Form::integer($self->session, {
|
||||
name=>"karmaScale",
|
||||
value=>$self->getValue("karmaScale"),
|
||||
defaultValue=>1
|
||||
});
|
||||
$var{'form.preview'} = WebGUI::Form::submit($self->session, {
|
||||
value=>$i18n->get("preview","Asset_Collaboration")
|
||||
});
|
||||
|
|
|
|||
|
|
@ -108,8 +108,23 @@ sub definition {
|
|||
},
|
||||
lastPostDate => {
|
||||
noFormPost=>1,
|
||||
fieldType=>"hidden",
|
||||
fieldType=>"dateTime",
|
||||
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 "") {
|
||||
$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->{'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 $sql = "select asset.assetId, asset.className, assetData.revisionDate as revisionDate, assetData.url as url from asset
|
||||
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 ( )
|
||||
|
||||
The web method to unarchive all the posts in this thread.
|
||||
|
|
|
|||
|
|
@ -405,6 +405,10 @@ sub definition {
|
|||
postGroupId =>{
|
||||
fieldType=>"group",
|
||||
defaultValue=>'2'
|
||||
},
|
||||
defaultKarmaScale => {
|
||||
fieldType=>"integer",
|
||||
defaultValue=>1
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -515,7 +519,17 @@ sub getEditForm {
|
|||
-hoverHelp=>$i18n->get('karma rating multiplier description'),
|
||||
-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 {
|
||||
$tabform->getTab("properties")->hidden(
|
||||
-name=>"defaultKarmaScale",
|
||||
-value=>$self->getValue("defaultKarmaScale")
|
||||
);
|
||||
$tabform->getTab("properties")->hidden(
|
||||
-name=>"karmaPerPost",
|
||||
-value=>$self->getValue("karmaPerPost")
|
||||
|
|
@ -548,6 +562,7 @@ sub getEditForm {
|
|||
userDefined4=>$i18n->get('user defined 4'),
|
||||
userDefined5=>$i18n->get('user defined 5'),
|
||||
);
|
||||
$options{karmaRank} = $i18n->get("karma rank") if ($self->session->setting->get("useKarma"));
|
||||
$tabform->getTab("display")->selectBox(
|
||||
-name=>"sortBy",
|
||||
-value=>[$self->getValue("sortBy")],
|
||||
|
|
|
|||
|
|
@ -60,6 +60,11 @@ our $HELP = {
|
|||
description => 'posts/page description',
|
||||
namespace => 'Asset_Collaboration',
|
||||
},
|
||||
{
|
||||
title => 'default karma scale',
|
||||
description => 'default karma scale help',
|
||||
namespace => 'Asset_Collaboration',
|
||||
},
|
||||
{
|
||||
title => 'karma/post',
|
||||
description => 'karma/post description',
|
||||
|
|
|
|||
|
|
@ -2,6 +2,24 @@ package WebGUI::i18n::English::Asset_Collaboration;
|
|||
|
||||
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' => {
|
||||
message => q|Collaboration System|,
|
||||
context => q|label for Asset Manager|,
|
||||
|
|
@ -19,8 +37,8 @@ our $I18N = {
|
|||
},
|
||||
|
||||
'karma rating multiplier' => {
|
||||
message => q|Karma Rating Multiplier|,
|
||||
lastUpdated => 0,
|
||||
message => q|Karma Given To Poster on Rating|,
|
||||
lastUpdated => 1141142205,
|
||||
},
|
||||
|
||||
'delete file warning' => {
|
||||
|
|
@ -891,8 +909,8 @@ submitted by a user.|,
|
|||
},
|
||||
|
||||
'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.|,
|
||||
lastUpdated => 1119070429,
|
||||
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 => 1141142205,
|
||||
},
|
||||
|
||||
'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.
|
||||
<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>
|
||||
The web safe title for previewing a post.
|
||||
<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.
|
||||
<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>
|
||||
A conditional indicating that the current user is a Visitor.
|
||||
<p>
|
||||
|
|
@ -175,7 +191,7 @@ The description of the collaboration system that this post is a part of.
|
|||
<p>
|
||||
|
||||
|,
|
||||
lastUpdated => 1140982574,
|
||||
lastUpdated => 1141142205,
|
||||
},
|
||||
|
||||
'assetName' => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue