Hi!

I have been using the Rate module (http://drupal.org/project/rate) to create a custom rating (basically every user can rate the node 1, 2, 3, 4 or 5, where each number corresponds non-related terms (e.g. yup, nah, not right now, ...)).

I run a site with a very limited number of users and would basically like to show a table where the users are shown vertically and the options horizontally. Then I would like to mark the users vote with an X in the corresponding row/column.

After searching for a module doing this for me and not finding one, my plan is to customize the node template, however I would if possible like some pointers. The Php code itself (and Html) is no problem, but I am not overly familiar with drupal-php yet.

In detail my plan is to create an array containing all users of the site (not sure exactly how yet) and get all votes cast on the current node in another array (using votingapi_select_results? or votingapi_select_single_vote_value?) and then in a loop basically create the table row by row. Seems simple enough, problem is I dont know where to start. Or if there is a better way.

So:
* Is there a better way to achieve what I am trying to do?
* If not...
- What votingapi function should I use? And arguments?
- Are the votingapi functions available in node templates or do they have to be "loaded" in some way?
- Any other pointers?

First: Thanks for reading this far, the post got quite long in the end :-S

And: Thanks a lot in advance!
/Victor

Comments

carvalhar’s picture

Hi,
I had a similar situation and looking at the database i could do this. Here's the code.

$result= db_query("SELECT * FROM votingapi_vote WHERE uid =" . $myUID. " AND content_id =" . $node->nid);
    while ($votesniduid = db_fetch_object($result)) {
	 echo t('Voted at') .date('d/m/Y', $votesniduid->timestamp) ;
     }

This code should be edited as a function at template or submodule to fit your needs.

pifagor’s picture

Status: Active » Closed (outdated)