2

I am a member of a social organization and run its Drupal 7 website. We will be starting a campaign in a couple of weeks to challenge members to pledge to accomplish certain points-based tasks (not related to the website), and want to track the pledges, completions, and rolled-up sums.

  1. There are roughly 100 tasks, with different point values and descriptions. Tasks are individual: more than one member can pledge to do a task.
  2. A member would sign up on a per-user page to complete certain tasks. The sums of a member's pledged tasks and completed tasks should be displayed on the per-user page, and there should be a summary of all members' pledged and completed points and tasks available as well.
  3. A member needs to be able to return to his/her page to update pledges and completions.

I believe I can do something for this with Webform, but it may be somewhat awkward. I'm not sure I can do the per-member sums and the rollups easily. User Points might help a bit, but it's not really oriented toward this. I could write a module as well, but I'm not sure I have time to do that. Suggestions for other modules or implementing this quickly are welcome.

3

There's a way to use Rules, Webform and Webform Rules together, by adding a number field with initial value 0 in your user fields. Every time user completes a task, validating a form submission, a value will be added to your field. That's the points field, which would be, in this case, unique. There is no sum in this case, but the field value will be automatically calculated by Rules.

Number field, your points field, should be available in your display, not in your user register form, with the right permissions.

That's what I'm thinking as a solution right now, if tasks are webforms. Not sure about awards or how to keep track of each completed task.

I hope that would get you started.

2

Goals module

You may want to look at the Goals module (disclosure: I'm its maintainer) as a possible alternative. To start using it only requires typical administration tasks (configuration), though it does come with various hooks also for custom module development (if you want to).

Using the Goals Extras sub-module it integrates with the User Points module also: each goal can be configured (using the admin UI) to automatically grant an amount of user points to some user, after that user completed the goal.

Since the Goals module is entity based, it has out-of-the-box integrations with modules such as Views, Rules, Flag, etc.

Requirements mapping

I can think of multiple ways to implement your requirements. For the sake of simplicity, here is one that IMO is the most straight forward implementation.

1) There are roughly 100 tasks, with different point values and descriptions. Tasks are individual: more than one member can pledge to do a task.

Create a content type, say Task, and add any custom fields you may need, eg for storing your point values and descriptions. For each of your "roughly 100 tasks" (referred to as Task-I below), create a node of type Task.

Use the Flag module to create these (non global) flags to be used for flagging nodes of type "Task":

  • Pledge: to indicate a pledge by the flagging user, related to Task-I.

  • Complete: to indicate the completion of Task-I by the flagging user.

Make sure to authorize all relevant users to use these flags (of course). That way, "more than one member can pledge to do a task" (as in your question).

Use the Goals module to configure 1 goal (referred to as Goal-I below) related to Task-I, which consists of only completing 1 thing (= a "task" as defined within the Goals module): flag the Task-I node. While configuring Goal-I, also indicate how many points (using the Userpoints module) should be granted automatically by Goals after a user completes Goal-I.

Use the Rules module to allow Goals to "record the progress of the completion of the task related to Goal-I". To do so, create a rule like so:

  • Rules Event: A node is flagged (by flag "completed")
  • Rules Condition: The node's nid corresponds to the nid of Task-I
  • Rules Action: Mark the completion of the task related to Goal-I

A more advance way to use (configure) goals, is that there could be multiple tasks, and/or they might have to be repeated multiple times, and/or they might have to happen within a given timeframe, and/or they may require some amount of time to expire in between any 2 similar tasks, .... However, Goal-I was configured to only consist of 1 task. So after the above Rules Action is executed, Goals will automatically mark Goal-I as completed.

To avoid you'd have to create (roughly) 100 such rules (1 for each Goal-I), you could consolidated them all in a single rule, by transforming the Rules Action to performing an equivalent Rules Component (using node's nid as a parameter of the Rules Component), whereas you'd move the Rules Condition to that Rules Component also. Other alternative could be to use the Conditional Rules module

2) A member would sign up on a per-user page to complete certain tasks.

That's simply a standard user registration, where you want to ensure that such users have read access to all the Task-I nodes, and also that they are allowed to use both flags.

The sums of a member's pledged tasks and completed tasks should be displayed on the per-user page,

Use the Views module to build the appropriate displays. Because of the modules mentioned above, they all integrate with Views very well (so creating such views should be straight forward).

There should be a summary of all members' pledged and completed points and tasks available as well.

To create these summaries, use the Views module (also), and/or have a look at the views (block) that comes with Goals (title = "Your completed goals").

3) A member needs to be able to return to his/her page to update pledges and completions.

That's a matter of flagging and unflagging Task-I.

More details

For more details about the Goals module, refer to my answer to "How to implement gamification in a Drupal site and award incentives?".

  • I had similar question and this answer was perfect for me, thanks! – Benas Plentas Mar 12 '18 at 11:29
0

I ended up choosing to write my own module, after discovering that Views includes the capability to create a form based on a view. This is a feature of Views that is not that well known (at least by me). There's an excellent tutorial on how to use the feature: Programmatically Creating Forms with Views in Drupal 7. Input fields can be added to a view using this feature, and their values are submitted with the form.

Each task described in the original question can now be a node. To do the point totals I will embed the view in a page and add some code to compute the totals. Eventually I may Ajaxify the page.

A key feature here is storing per-user data associated with a node, which is not that common. My module uses its own db table to store this. The Flag module can also associate store per-user data per node, but it only stores a boolean and does not handle multi-valued Flags.

The module I'm working on is currently a sandbox project, Task Pledge.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.