# How to allow users to attribute accumulating points to nodes?

I would want to make a thing in priori simple: allow users to attribute (grant) a selectable amount of accumulating points to nodes.

I tried various modules (Fivestar, etc.), but these modules are about a note (or a score like '4/5') and not of a number of accumulative points.

It would be necessary from a field (for example list of selection), make increase or decrease the value of another field.

Anybody has an idea?

Notes:

• Fivestar allows to give a note (for example: 4 on 5), while I wish to give points which accumulate. Points: simple value. Give X points to this node. For example: I give 5 points to this node because I find this a good node.
• Multiple users could give a different number of points. The functioning would be close to Fivestar, except that instead of having an overall average there would be a total number of points.
• There would be a field of a node which stores the accumulation of points, and possibly one other to give points.
• Fivestar allows to give a note (for example: 4 on 5), while I wish to give points which accumulate. Points: simple value. Give X points to this node. For example: I give 5 points to this node because that I find him good. Commented May 15, 2017 at 21:49
• OK, that helps a bit to better understand. More questions: who would trigger such increase or decrease of points to a node? Should it be possible for multiple users to do so (possibly each of them a different amount of points)? About that "other field": is that like a field of a node, which stores the accumulation (= the sum) of all the points attributed to some node? After you confirm / clarify my comment, I might be able to solve your question ... Commented May 16, 2017 at 9:48
• Yes, multiple users could give a different number of points. The functioning would be close of fivestar, except that instead of having an overall average there would be a total number of points. For fields: yes, there would be a field of a node who stores the accumulation of points, and possibly one other to give points. Thanks pierre.vriens for your help Commented May 16, 2017 at 10:18
• And thus, you know a solution? I thought in flag + rules, but the problem is that flags is independent, if I have several flags (ex: +1, +2, +3) I can click these three flags and not only one Commented May 16, 2017 at 15:10
• How many points would one user typically give? You can use a flag whose unflag text is the same as its flag text, and use rules to +1 the integer field on each. For low numbers, it works well as the user clicks once for each point they give. Commented May 17, 2017 at 1:37

### Step 1 - Use the Flag module

I'd definitely use the Flag module for what you're trying to achieve. To allow authorized users (to use such flag) to flag relevant nodes. Maybe you want to limit them to only selected content types also.

### Step 2 - Add a field to a Flag to specify the points

However, to also implement those points to nodes that get flagged, you should configure the flag (you only need 1 flag!) by attaching a field to such flag. Such field can then be used to enter, or select, any of the allowed values of points you want to be granted (appointed) to a node that gets flagged by such flag.

However when doing so, make sure to also be aware about (and do) what is described in Attaching fields to flags, i.e.:

By default, Flags use the "JavaScript toggle" link-type. While this allows entities to be flagged without reloading the page, users cannot set any field values with the Flag. In order for users to set a Flag's field values, you must use the "Form" link type.

Navigate to `Administration > Structure > Flags` page. Click the Edit link for the Flag. Scroll down to the Display Options box and select the Confirmation Form radio button.

### Step 3 - Add some 'Total points' field to your nodes

Define some other field in the content types for the nodes you want to use these points for, which will contain the total number of points. And which will get updated each time a node gets flagged with '+X' (or '-Y') points, as explained in the next step.

### Step 4 - Use the Rules module to maintain the value of the 'Total points'

The Rules module integrates extremely well with the Flag module. So it should be fairly simple to create a rule to maintain the value of the 'Total points'. Here is a blueprint (to avoid writing an entire manual ...) of this rule:

• Rules Event: when a node is flagged (with the flag you created in step 1)
• Rules Conditions: whatever you might need (if anything), on top of what is not yet covered by the way you configured the flag.
• Rules Action(s): Perform some Rules Actions that use the value of the points as specified by the user who flagged the node, and then adds that to the current value of the 'Total points' field. For an example of such calculation, refer to this answer to the question about "How to add up all items of a field collection field using Rules?". In your case here, you don't need the 'loop' (you're not processing a field collection, only 2 fields for which you want to calculate the sum of it).

### Summary

Using Flag (with 1 extra field) and Rules, and by adding a field (for 'Total points') to relevant content types, the above is how you can create something similar to what User Points can do, though with a summary like so:

provides `a technique` an API for `nodes` users to gain or lose points `for selected nodes` performing certain actions on your site.

And btw ... zero custom code involved ...