Sunday, September 16, 2012

Graddit polls widgets

Graddit presents new widgets for polls that you can build into your blogs and sites. Here's a simple poll example:

{[['Bad','  |  '],['Average','  |  '],['Awesome']]}

Number of options and text can be changed. Take code from graddit page, options are set like this:

{[['Bad','  |  '],['Average','  |  '],['Awesome']]}, where '  |  ' are the separators between options; number of options should match the number that is passed to the script as a parameter (3 in this example).

I can be not just text, but any HTML valid element. For example, images:

Who rocks?
{[['','    '], ['','    '], ['']]}


And of course general polls. How do you like the new widgets?
{[['So so'],['Okay'],['Perfect']]}

27 comments:

  1. How to make star rating and poll in one post. I have star rating widget working and I want to add poll but it only shows stars.

    ReplyDelete
    Replies
    1. Are you talking about single rating/poll or you want ratings and polls (with same options) appear on each post?

      Delete
    2. I want this widget http://www.graddit.com/ratings-widget and this widget http://www.graddit.com/polls-widget on each post.
      When I install just one of them it works fine. When I try to install both of them just first work and second doesnt.

      Delete
    3. It is possible. Use this as a reference: http://pastebin.com/BVcbBxCY
      What to remember:
      - all IDs (for divs, ratings and polls) should be different, so you need to add a prefix;
      - if you want to change number of questions in your polls (defulat is 3) do it before applying to real blog; this number is stored in the database the very first time you send a request and can't be changed later easily (currently).

      Delete
    4. Thanks. It works exactly as I wanted but only on my test blog or new blog.

      On my main blog there are two problems:
      First is that when I check new template on preview, all previous stars votes are reset to 0.
      Second is that on the poll there are only 3 answers. I wanted 6. On test blog or new blog when I put 6 instead of 3 it works but on my main blog there is still 3.

      Is it possible to fix this?

      Delete
    5. > First is that when I check new template on preview, all previous stars votes are reset to 0.
      This can happen if you changed rating IDs that are passed to the server. Usually this ID are the post IDs that are passed right after number of stars in the parameters line (...rate/5/post.id...); for the ratings and polls to be on the same page you had to add a prefix, so the IDs changed and ratings numbers dropped. If you'll keep IDs the same for ratings and polls there will be a conflict. There's no workaround for this. The good news: it will work in future the way you want.

      > poll there are only 3 answers. I wanted 6
      There are 3 answers for all posts that called polls code at least once; the initial number of "stars" (questions if talking about polls) is saved and can not be changed later. The good news: it will work properly for all your new posts and for all old posts that were not yet displayed to anybody with 3 questions. What is your blog address?

      Delete
    6. http://mlodewino.blogspot.com/

      I'm not good at this. Do I really need to add prefix to IDs? Can you check it for me?
      This is my old template with star ratings and with working old votes.
      http://pastebin.com/s3ruWmvE
      (highlighted lines 1098-1104)

      and this is new template which reset all previous votes (when I check new template preview)
      http://pastebin.com/kA4xg1VW
      (highlighted lines 1100-1113)

      How should I change it to save previous votes?

      Delete
    7. To save old ratings in the second template in line 1108 where's the call http://www.graddit.com/rate/eng/5/rating_... just remove "rating_" and leave it like http://www.graddit.com/rate/eng/5/... - that should make the trick.

      Delete
    8. Thanks again. It's working. I will not use it because there still less then 6 answers in polls in older posts and I can't change it. But maybe it will be helpful for others.

      Delete
    9. Now when I know your blog address I can fix that for you and make it 6 answers for old posts if you want.

      Delete
    10. If this is not a big problem I would be grateful if you fix that.

      Delete
    11. Updated to 6. If you still see 3 this is cached version, it will update after some time or when somebody votes.

      Delete
    12. This comment has been removed by the author.

      Delete
    13. Thanks. Now It all works:)

      There was little issue with non-breaking space and whole template didnt work: "The entity "nbsp" was referenced, but not declared"

      Here is solution if someone need it:
      http://pastebin.com/7mGSZJzq

      Delete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Answers to the question in my poll are in digital form. Can I calculate and display the average of these numbers?

    For example, "Choose the number:" 1 (2) | 2 (0) | 3 (2) | 4 (0) | 5 (0) | 6 (1)

    Average of the selected numbers is: 2.8

    ReplyDelete
    Replies
    1. Use ...&callback=myFunctionThatDoesTheStuff&... parameter and do what you need in that JS function.

      Delete
  4. Hello. Please, can I simply reset all the ratings in my blog ?

    Arnaud

    ReplyDelete
    Replies
    1. Two questions:
      - by reset you mean drop everything to zeros (views, votes, etc.) or you have some issues with polls/ratings conflict and want to resolve it (as you're writing into polls topic)?
      - which blog?

      Delete
    2. Yes I mean drop everything to zeros. I had conflicts too, but I relsoved it by erasing articles and creating new articles.

      My blog is in french : http://quelleestladifference.blogspot.fr/ It is about the differences between similar ideas.

      Delete
    3. Ok, I also see that you tried both: thumbs up/down and 5-stars. Which one you want to keep? I can transform them all to one form.

      Delete
    4. I wish to keep thumbs up/down please. It would be wonderful !

      Delete
    5. (If it is not difficult, could you reset the thumbs up/down too ? Currently, almost all the votes are mine and they are not relevant.)

      Delete
    6. Dropped everything. If you don't see the changes it's probably caching, it will fix in few hours. Also if you're using tops widget it will be showing the old data for a while.

      Delete
  5. This comment has been removed by the author.

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete