How to use User Points for storing Quiz scores? How can I add points directly to the User Points database? I have a quiz site and would like to use the User Points module to store quiz scores, instead of creating something from scratch. I have created a taxonomy "Quiz" for such points. 

Every quiz ends by showing the score made (between 0 to 100 depending on how many answers they got right). I would like to go on and store this in the userpoint database.

I am using the following code but I'm getting 2 error messages:


  Notice: Undefined variable: user in ...
  Notice: Trying to get property of non-object in .... 


The code I am using is the following one:

$params = array (
  'uid' =&gt; $user-&gt;uid,
  'description' =&gt; 'Totals points from quizes',
  'points' =&gt; $percentage,
  'tid' =&gt;127,
);

userpoints_userpointsapi($params);
Userpoints has an API.

See especially userpoints_userpointsapi() Something like this: userpoints_userpointsapi(array('uid'=&gt;$some_user, 'points'=&gt;9000));

You might also be interested in the Quiz module which supports Userpoints.