-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 84741d9
Showing
6 changed files
with
747 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*~ | ||
.*.sw[a-p] |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
The points system in [Question2Answer][1] allows for awarding points for | ||
accepting an answer to the user accepting the answer, which serves as an | ||
incentive to actually mark an answer as "best answer." However, the software | ||
awards the points regardless of whether the answer is from the person asking the | ||
question or someone else, and doesn't provide an option to change that behavior. | ||
This might tempt some people to increase their points by posting a lot of | ||
(trivial) questions and accepting their own (trivial) answer. | ||
|
||
This plugin changes the default behavior so that points are only awarded to the | ||
user accepting an answer if that answer wasn't posted by themselves. | ||
|
||
To activate it, copy the plugin directory to the plugins directory of your | ||
Question2Answer site (or clone this repository there), then log in as the site | ||
admin and enable the plugin under *Admin → Plugins*. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "No Self-Accept Points", | ||
"description": "Don't award points for accepted self-answers.", | ||
"version": "1.0.0", | ||
"date": "2020-08-09", | ||
"author": "Ansgar Wiechers", | ||
"author_uri": "https://ask.planetcobalt.net/", | ||
"license": "GPLv3", | ||
"min_q2a": "1.5", | ||
"load_order": "after_db_init" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
// don't allow this page to be requested directly from browser | ||
if (!defined('QA_VERSION')) { | ||
header('Location: ../../'); | ||
exit; | ||
} | ||
|
||
/** | ||
* Override the formula for calculating points for accepting answers to remove | ||
* accepted self-answers. | ||
*/ | ||
function qa_db_points_calculations() { | ||
$points_calculations = qa_db_points_calculations_base(); | ||
|
||
if (array_key_exists('aselects', $points_calculations)) { | ||
$points_calculations['aselects']['formula'] = "COUNT(*) AS aselects FROM ^posts AS userid_src JOIN ^posts AS answers ON userid_src.selchildid=answers.postid WHERE userid_src.userid~ AND userid_src.type='Q' AND (answers.userid <> userid_src.userid)"; | ||
} else { | ||
// if key 'aselects' is missing: throw a warning, but continue regardless | ||
trigger_error("Missing key 'aselects' in points calculations array", E_USER_WARNING); | ||
} | ||
|
||
return $points_calculations; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
/* | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
More about this license: https://www.gnu.org/licenses/gpl-3.0.html | ||
*/ | ||
|
||
// don't allow this page to be requested directly from browser | ||
if (!defined('QA_VERSION')) { | ||
header('Location: ../../'); | ||
exit; | ||
} | ||
|
||
qa_register_plugin_overrides('points.php'); |