3

I'm currently working on an educational project as a sort of final keystone project for my major in undergrad. The project is a online artwork trading game, in which students take on the role of being an art dealer/collector, and buy, sell, trade, and advertise artworks to each other on the site. I chose to use Drupal as a CMS due to its flexibility, but relative user-friendliness, as I won't be maintaining the project after my graduation in a few weeks.

I've polished off most of the site's features, with the exception of one, the currency system. At the moment, I have used the User Points module to create a virtual currency (guilders) for students to use when trading their artworks. I have also created the artworks as a custom content type. I am trying to make it so that students can buy/sell or just straight trade artworks between each other. I've attempted to install the Drupal Commerce module and pursue that route, which doesn't seem to be working. I've also tried making it so that students can manipulate node ownership, but it looked like that would create a permissions nightmare eventually, leaving me at a loss as of what to do. Due to the fact I won't be around to maintain the site, my original question of module recommendations really more is a recommendation of a solution that's not overly technical, and is fairly stable. My professor (who is an Art Historian) will be maintaining the project, and while he has taken an introductory computer science course, an astute programmer he is not.

TL;DR: I need a way for users to use userpoints to buy/sell a custom content type between themselves, and I need to keep the solution as stable as possible due to long-term maintenance concerns.

  • Welcome to Drupal Answers! So far, you simply stated facts, without asking any explicit question. It's not clear what part of implementing the feature is not clear to you. What is exactly the part that you aren't able to implement? What did you try so far, and why didn't it work for you? – kiamlaluno Apr 16 '17 at 17:19
3

Use the integration between the User Points module and the Rules module to create some custom rules to transfer user points from one account to another.

As a sample, have a look at this rule, which is used in combination with voting of a node, whereas the author looses "-2" points, and the voter looses "-1" points:

{ "rules_votedown_question" : {
    "LABEL" : "votedown_question",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "TAGS" : [ "answers" ],
    "REQUIRES" : [ "rules", "voting_rules", "userpoints_rules" ],
    "ON" : { "voting_rules_insert_node" : [] },
    "IF" : [
      { "node_is_of_type" : {
          "node" : [ "node" ],
          "type" : { "value" : { "answers_question" : "answers_question" } }
        }
      },
      { "voting_rules_condition_check_vote_value" : { "vote" : [ "vote" ], "value" : "-1" } }
    ],
    "DO" : [
      { "userpoints_action_grant_points" : {
          "user" : [ "node:author" ],
          "points" : "-2",
          "tid" : "0",
          "entity" : [ "" ],
          "description" : "Receive downvote to [node:type-name] \u0022[node:title]\u0022",
          "operation" : "QuestionDownvoteReceived",
          "reference" : "By uid=[vote:uid], for [node:type-name] to q=\u003Ca href=\u0022\/node\/[node:nid]\u0022\u003E[node:title]\u003C\/a\u003E",
          "display" : "1",
          "moderate" : "default"
        }
      },
      { "userpoints_action_grant_points" : {
          "user" : [ "vote:user" ],
          "points" : "-1",
          "tid" : "0",
          "entity" : [ "" ],
          "description" : "Issue downvote to [node:type-name] \u0022[node:title]\u0022",
          "operation" : "QuestionDownvoteIssued",
          "reference" : "From uid=[node:author:uid], for [node:type-name] to q=\u003Ca href=\u0022\/node\/[node:nid]\u0022\u003E[node:title]\u003C\/a\u003E",
          "display" : "1",
          "moderate" : "default"
        }
      }
    ]
  }
}

If you simply adapt the amount of points (-2 and -1) to something like (eg) +25 and -25, you've a prototype to transfer (25) user points from one user to another.

If you replace the Rules event by an event like "something is flagged" (created with the Flag module), a simple click could be used to indicate "I want to transfer 25 user points of mine to this user). You could take this even a step further: since flags are fieldable, you could add a field to indicate the amount of points to be "moved".

The above Rules example may need further refinements, e.g. if you want to ensure that after moving points van User A to User B, the remaining points for User A is not negative. Refer to "How to check whether one's current User Points are negative with the Rules module?" for details about how you can implement such refinement also.

PS: I'm assuming this question is about D7.

| improve this answer | |
  • 1
    Wow, this is a thorough response, thank you! I had not thought to use the Rules module, and was trying to go the eCommerce route, this seems a lot simpler! And yes, this is about D7, I neglected to mention that, apologies. – Taylor Cohron Apr 16 '17 at 23:15

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.