Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+2 votes
495 views
in Q2A Core by

1 Answer

0 votes
by
For this you need a custom plugin.

To make it smoothly working with q2a core point system, you can just give extra BONUS points to users when they answer unanswered questions. So, by answering questions they will simply get a certain points inline with q2a core point system. Plus, for answering unanswered questions they will get a certain extra bonus points with a custom plugin.
by
Manually giving bonus points will be an Herculean task.

While submitting an answer if answer count for that question is less than zero then points should be 5x or so which can be predefined. If so there won't be any unanswered questions.
by
you dont have any manual task. Custom plugin will do this.
You can use define a function like below, in order to determine if postid is unanswered.

function is_unanswered ($postid) {
$result = qa_db_read_one_value(
    qa_db_query_sub(
        'SELECT postid
        FROM ^posts
        WHERE postid=$ AND acount = 0 AND type = 'Q',
        $postid
        ), true);

if ($result == $postid) {
            return 1;
        } else {
            return 0;            
        }
}

And if the function returns true, then write another function to give bonus points.
by
Can't we directly add points in this function itself?
Like if result==post id , add bonus points to user.
by
yes, you can do it. try this.

function is_unanswered ($postid,$userid) {
$result = qa_db_read_one_value(
    qa_db_query_sub(
        'SELECT postid
        FROM ^posts
        WHERE postid=$ AND acount = 0 AND type = 'Q',
        $postid
        ), true);

$add_amount = 15; //how much bonus you want to award

if ($result == $postid) {
            add_bonus ($userid, $add_amount);
        } else {
            return;             
        }
}

function add_bonus ($userid, $add_amount) {
    $current_bonus = qa_db_query_sub(
        'SELECT bonus
        FROM ^userpoints
        WHERE userid=$,
        $userid
        );
$new_bonus = $current_bonus +$add_amount;

qa_db_query_sub(
            "UPDATE ^userpoints
            SET bonus = $
            WHERE userid= #",
            $new_bonus ,$userid
        );
}
by
Sure I will try this. Thank you

If acount = 0 add amount= 15
If acount = 1 add amount = 5 etc can also be done.
Am I right?
by
If you do the function, yes you can.
...