Voting/Polling version 0.9
joan
Joined: 2002-10-21
Posts: 3473 |
Posted: Wed, 2003-02-26 02:30 |
****UPDATE****** 13 September 2003 Sorry this has taken so long, but here is the latest version. Features
<LI> Completely configurable from album properties <LI> voting can be either rank (voters choose one 1st, one 2nd, one 3rd etc) or critique (each image is evaluated independently). <LI> Rank voting is done using radio buttons, critiques on a pull down menu, or if th ere is a single choice - a checkbox. <LI> Voting results can be hidden, or displayed in summary form on the album pages, plus there is a page with complete results. <LI> Both the displayed names and the value for each polling option is configurable for each album. <LI> voting can be completely open (recorded against session id), or restricted to members only (using UID). <LI> Poll can be stopped and started at will <LI> If "nobody" can vote, and results aren't displayed, then to users the album looks exactly the way it does now. <LI> Results are shown graphically in ranking order and in broken down form for each photo. <LI> Graphical displays include links to each photo <LI> Votes can be changed at any time while the poll is open <LI> For rank voting, your current choices are displayed at the top of page one <LI> Any number of voting options are available (including just a checkbox "I like this picture") <LI> For rank voting, total score is based on a weighted sum of all votes <LI> For critique voting, total score is based on the average of votes cast **UPDATE** This code now lives at http://sourceforge.net/tracker/?func=detail&aid=693373&group_id=7130&atid=307130[/] |
|
Posts: 86
Sorry if this is a dumb question but how do I run the patch file. If it needs to be run using ssh, I would be totally lost. Could you guide me? Thank you so much. I really appreciate your time and not to mention your brain. :grin:
Posts: 3473
Have you got ssh access? If so, ftp the patch file into your gallery directory, then SSH in.
From the SSH terminal, change directory to your gallery directory (eg cd public_html/gallery), then type
patch -p0 < vote_release_candidate.patch
If you don't see any error messages, then it's time to test it.
Posts: 172
That DOESNT work, or maybe it doesnt work with CVS versions eh?
Posts: 144
bash-2.05$ patch -p0 < vote_release_candidate.patch
patching file util.php
patching file view_album.php
patching file view_photo.php
patching file classes/Album.php
Hunk #3 succeeded at 861 (offset -8 lines).
patching file classes/AlbumItem.php
patching file css/embedded_style.css.default
Hunk #1 FAILED at 52.
1 out of 1 hunk FAILED -- saving rejects to file css/embedded_style.css.default.
rej
i got it working it looks great! but when you vote it displays this
Poll results: th place overall.
is what i get when i run the patch...i hope it works
Posts: 3473
No, the last test I ran (about 24 hours ago) was against a freshly checked out HEAD revision of the CVS source.
What errors did you see?
Posts: 3473
That's ok! It means your warning text won't be blue - but I think you can live with that.
Known behaviour - though it looks like it should be fixed. The Rank is only recalculated when drawing the thumbnail page. If you go to the thumbnail page, then back to the image page, you should get a correct value.
Now you know why it's version 0.9!
Posts: 172
I am using 1.3.4-CVS-B15
it tells me all errors for all files like failed all the way and it doesnt work
Posts: 3473
I just downloaded that version. The patch works.
It doesn't sound like you are in the right directory. Patch will fail if it can't find the named files.
You need to run the patch in the gallery directory, ie the same directory that albums.php etc are in.
eg
cp Desktop/downloads/vote_release_candidate.zip public_html/gallery
cd public_html/gallery
unzip vote_release_candidate.zip
patch -p0 < vote_release_candidate.patch
Posts: 172
The error says:
-bash-2.05b$ patch -p0 < vote_release_candidate.patch
patching file util.php
Hunk #1 FAILED at 2.
Hunk #2 FAILED at 1275.
2 out of 2 hunks FAILED -- saving rejects to file util.php.rej
patching file view_album.php
Hunk #1 FAILED at 1.
Hunk #2 FAILED at 51.
Hunk #3 FAILED at 98.
Hunk #4 FAILED at 257.
Hunk #5 FAILED at 310.
Hunk #6 FAILED at 363.
Hunk #7 FAILED at 503.
Hunk #8 FAILED at 593.
Hunk #9 FAILED at 644.
Hunk #10 FAILED at 665.
Hunk #11 FAILED at 687.
Hunk #12 FAILED at 710.
Hunk #13 FAILED at 723.
Hunk #14 FAILED at 777.
14 out of 14 hunks FAILED -- saving rejects to file view_album.php.rej
patching file view_photo.php
Hunk #1 FAILED at 2.
Hunk #2 FAILED at 54.
Hunk #3 FAILED at 213.
Hunk #4 FAILED at 282.
Hunk #5 FAILED at 456.
5 out of 5 hunks FAILED -- saving rejects to file view_photo.php.rej
patching file classes/Album.php
Hunk #1 FAILED at 2.
Hunk #2 FAILED at 75.
Hunk #3 FAILED at 869.
Hunk #4 FAILED at 1294.
4 out of 4 hunks FAILED -- saving rejects to file classes/Album.php.rej
patching file classes/AlbumItem.php
Hunk #1 FAILED at 2.
Hunk #2 FAILED at 36.
Hunk #3 FAILED at 194.
3 out of 3 hunks FAILED -- saving rejects to file classes/AlbumItem.php.rej
patching file css/embedded_style.css.default
Hunk #1 FAILED at 52.
1 out of 1 hunk FAILED -- saving rejects to file css/embedded_style.css.default.rej
-bash-2.05b$
Now What?
Posts: 3473
can you email me one of your files, say classes/AlbumItem.php? Run zip or gzip on it first, so it doesn't get converted in anyway. email it to gallery @ mcgalliard.freeuk.com
[I tried the experiment again (this time on a Linux machine), unpacking a fresh gallery from gallery.1.3.4-cvs-b15.tar.gz. My patch ran fine. As yours failed on every change, my guess is that your repository and mine differ in some way on every single line, so what I am looking for is DOS line feeds on every line, or something similar.]
Posts: 18
This is FANTASTIC Joan!! Thank You!!!
It installed quite easily with my first try :grin:
I'm only seeing one issue so far (note I've had it installed all of five minutes...)
In one album at
http://www.picolio.com/Gallery/Max
I voted for three pictures giving two of the pics a "2" and one of the pics a "1" where one is the highest.
But the results are showing what should have been the "1st place pic" as being in 3rd place...
-----
Results Breakdown Max-02-02-2003b
Poll results: 1st place overall.
2=Nice Pic: 1 vote
11-20-2001_max_out_cold
Poll results: 2nd place overall.
2=Nice Pic: 1 vote
Maxamus_01
Poll results: 3rd place overall.
1=Great Pic: 1 vote
-----------
Any ideas?
Posts: 18
Nevermind Joan... I pulled out my old 1st grade math book and think I figured it out :grin:
Posts: 3473
No, you've done good, because visiting your site helped me discover a major, major
BUUUUUGGG!!!!!!!!!!
Watch this space
Posts: 3473
Bug fix:
Open poll_properties.php. Everywhere it says "Everyone" replace it with "Everybody". That's three changes.
Then open util.php. Replace getVotingID and canVote with these versions.
<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE>
function getVotingID()
{
global $gallery;
if ($gallery->album->getVoterClass() == "Logged in")
{
return $gallery->user->getUid();
}
else if ($gallery->album->getVoterClass() == "Everybody")
{
return session_id();
}
else
{
return NULL;
}
}
function canVote()
{
global $gallery;
if ($gallery->album->getVoterClass() == "Everybody")
{
return true;
}
if ($gallery->album->getVoterClass() == "Logged in"
&& $gallery->user->isLoggedIn())
{
return true;
}
return false;
}
</TD></TR></TABLE><!-- BBCode End -->
Posts: 3473
NOTE: After fixing the bug, click on poll properties, and make sure "Who can vote" is still set to the correct value.
Posts: 18
Ok the edits have been made.
When I made the edits it did change "Everybody" to logged in..but I've updated that back to everybody.
Would you like to re-test?
Everything's looking good to me .. but what do I know? LOL
Posts: 3473
Yup, looks much better. Before, all votes were recorded as user NULL, so there was only ever one voter, now you have 3.
Big WHOOPS there.
Posts: 18
Well so far I'm THRILLED to have this feature. Again THANK YOU for continuing to work on it!!!!
You've done great :smile:
If I had a feature request it would simply be the ability to "Apply properties to all sub-albums".
Overall this is a great addition and kudos for the ease of installation!!!
Posts: 3473
This is because the position is only updated when the graph is drawn on the main page - so if your vote would (for example) move something from first to second position, you won't see that until you go back to the thumbnails page.
This should fix this, save it, and run it on a gallery you have already modified using the release candidate voting patch. You'll need to do the above getVoterClass fix by hand.
<!-- BBCode Start --><A HREF="http://www.mcgalliard.org/content/gallery/vote_release_candidate_bugfix.patch" TARGET="_blank">vote_release_candidate_bugfix.patch</A><!-- BBCode End -->
Posts: 3473
latest version is <!-- BBCode Start --><A HREF="http://www.mcgalliard.org/content/gallery/vote_release_candidate_0.9.1.zip" TARGET="_blank">vote_release_candidate_0.9.1.zip</A><!-- BBCode End -->
This includes both the fixes described in this thread so far.
Posts: 11
Hi joan,
thanks a lot for your great work.
I discovered a small bug in poll_results.php:
Line 128 reads <!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE> $ranks=array_keys(showResultsGraph($num_rows)</TD></TR></TABLE><!-- BBCode End -->.
There's one ')' missing at the end:
It must be <!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE> $ranks=array_keys(showResultsGraph($num_rows))</TD></TR></TABLE><!-- BBCode End -->
Cheers
Mathias
Posts: 172
I did just a fresh install, I dont get it either ...
it has to be your script not mine, becuase my scripts are brandly NEW and updated!
Posts: 3473
Good catch. Probably should put a semi colon at the end, viz:
$ranks=array_keys(showResultsGraph($num_rows));
Posts: 3473
Ok, but it works for me on a fresh installation - and other people have installed it successfully.
If you are really struggling, here is a patched version of 1.3.4
<!-- BBCode Start --><A HREF="http://www.mcgalliard.org/content/gallery/gallery.1.3.4-cvs-b15_vote.tar.gz" TARGET="_blank">gallery.1.3.4-cvs-b15_vote.tar.gz</A><!-- BBCode End -->
Posts: 68
I think this may be a bug
Fatal error: Call to a member function on a non-object in /home/htdocs/latexnballoons/www/members/gallery/classes/User.php on line 90
I used the fully built patched version of the script. it dose this when i try to revote
Posts: 3473
I can't reproduce it. Can you post a link to your site (or PM me) with details on exactly how to get this error. Once I see it, I can try to reproduce it locally.
thanks
Posts: 3473
Goths problem turns out to be one that occurs on his server, but not mine. Something to do with session variables, I think. Anyway, if you have a similar problem (or just want nicer URLs), you can make this change to view_album.php.
From:
<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE>
}
if ($showPolling) {
! echo makeFormIntro("view_album.php",
array("name" => "vote_form", "method" => "POST"));
}
</TD></TR></TABLE><!-- BBCode End -->
To:
<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE>
}
if ($showPolling) {
! echo makeFormIntro($gallery->session->albumName,
array("name" => "vote_form", "method" => "POST"));
}
</TD></TR></TABLE><!-- BBCode End -->
Posts: 86
Sorry, but I'm not really comfortable with using ssh. Could I do it manually? Thanks for all your help.
Posts: 3473
You could use a Windows version of patch, see this <!-- BBCode Start --><A HREF="http://gallery.sf.net/forums.php?topic=3586" TARGET="_blank">thread</A><!-- BBCode End -->
or just grab a complete patched version <!-- BBCode Start --><A HREF="http://www.mcgalliard.org/content/gallery/gallery.1.3.4-cvs-b15_vote.tar.gz" TARGET="_blank">gallery.1.3.4-cvs-b15_vote.tar.gz</A><!-- BBCode End -->
I can't suggest you do it by hand, as you'd add or modify 810 lines across 6 files.
Posts: 11
Hi!
In case you want to see joan's scripts 'voting' and 'extra_fields' in action, check out my gallery:<!-- BBCode Start --><A HREF="http://www.matadler.de/gallery/" TARGET="_blank">My personal travel pictures</A><!-- BBCode End -->.
Voting is only enabled in this album: <!-- BBCode Start --><A HREF="http://www.matadler.de/gallery/RoadSigns" TARGET="_blank">Funny road signs</A><!-- BBCode End -->, because it is a lot of work to enable it in every single (sub)album...
CU Mathias
Posts: 3473
Sorry - the results code can't cope with negative numbers! I had a look at how to change it, but it opened all new issues about how the graphh should be drawn, so instead I suggest you add the lines indicated with +s to poll_properties.php <!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE> --- 42,51 ----
{
//convert values to numbers
$nv_pairs[$i]["value"]=0+$nv_pairs[$i]["value"];
+ if ($nv_pairs[$i]["value"] < 0)
+ {
+ $nv_pairs[$i]["value"] = 0;
+ }
}
$gallery->album->fields["vote_nv_pairs"]=$nv_pairs;
$gallery->album->fields["vote_hint"]=$vote_hint;</TD></TR></TABLE><!-- BBCode End -->
ps I'll look at applying to sub albums. Promise!
Posts: 86
Hi, Joan. I have finally been able to patch it by asking my hosting company since they could not grant me access to the patch command in ssh. It seems to be working but I need to confirm with you as I receive a few error messages when the patch was ran. Could you tell me if any of the error messages are important? If so, how do I correct them?
patching file util.php
patching file view_album.php
Hunk #4 succeeded at 295 (offset 38 lines).
Hunk #6 succeeded at 401 (offset 38 lines).
Hunk #7 succeeded at 504 (offset 1 line).
Hunk #8 succeeded at 635 (offset 42 lines).
Hunk #9 succeeded at 650 (offset 6 lines).
Hunk #10 succeeded at 707 (offset 42 lines).
Hunk #11 succeeded at 693 (offset 6 lines).
Hunk #12 succeeded at 752 (offset 42 lines).
Hunk #13 FAILED at 765.
Hunk #14 succeeded at 776 (offset -1 lines).
1 out of 14 hunks FAILED -- saving rejects to file view_album.php.rej
patching file view_photo.php
Hunk #3 succeeded at 256 (offset 39 lines).
Hunk #5 FAILED at 460.
1 out of 5 hunks FAILED -- saving rejects to file view_photo.php.rej
patching file classes/Album.php
patching file classes/AlbumItem.php
patching file css/embedded_style.css.default
Hunk #1 succeeded at 184 with fuzz 1 (offset 132 lines).
BTW, I added some extra codes to the patched files to achieve what I want. Basically, I cut the caption to only show 40 characters and also in the full results view, I replaced the captions with the thumbnail.
Thank you so much for all your effort.
Posts: 3473
Can't tell if that's a problem. Have a look at the .rej files. They contain the before and after snapshot of what failed to change. You should be able to work out how to do those changes by hand.
If you can't understand them, send them to me: gallery @ mcgalliard.freeuk.com
Posts: 37
Help l just installed Joans new mod to my gallery and even did a fresh install with here version and l get this error how do l correct this
Fatal error: Call to undefined function: getvoterclass() in /home/sites/site59/web/modules/gallery/util.php on line 1462
l have set permissions on all the folder and did follow the install but still doesnt work any help would be appreciated thanks
dds
Posts: 3473
That function should be in classes/Album.php. Have you got the right version with that in it?
Posts: 37
Thanks Joan for responding this is the version l downloaded from your previouse post in this section of the forum gallery.1.3.4-cvs-b15_vote.tar i unpacked it and FTP all the contents up and did a clean install setting all the folders to 777 and then ran the setup everything went well but when l go to creat a folder or add a folder it gives me this error is it possible l dont have the right version you mean if so where can l get it l seen this one in a previuse post that you had mentioned that it was a full install with the hack already applied ..
and thank youy in advance for getting back to me so soon looking forward to hearing from you again .
DDS :razz:
ps sorry for my spelling it sucks l know ...lol :eek:
Posts: 3473
See, that's where my problem is. I just downloaded http://www.mcgalliard.org/content/gallery/gallery.1.3.4-cvs-b15_vote.tar.gz, unpacked it and tested it and it works fine. Something is corrupted in yours, and we need to find out what. Did you ftp the stuff in the classes directory to the correct place? I suspect you have up to date files in your gallery directory, but out of date ones in the subdirectories.
Posts: 38
i get
here: http://picdump.dhs.org/gallery/daofunnynet?&page=3
it appears to happen only when trying to vote on the third page of the album, voting works on the first two pages.
i've done the change described above to remove the line 90 error, but this persists.
here is another album hosted on my site with voting turned on: http://picdump.dhs.org/gallery/forum
This one allows me to vote no matter which page I'm using.
Posts: 3473
It's a bug! Good work. The fix is simple. Open view_album.php. Find this line:
for ($index=$start; $index < $start+$perPage; $index ++)
and replace it with this one:
for ($index=$start; $index < $start+$perPage && $index <= $numPhotos; $index ++)
Posts: 5
i am getting this error:
Fatal error: Call to undefined function: isitemowner() in /gallery/reset_votes.php on line 39
where is this function located. I have V1.33 and have done a search but cannot find it. Is it a new function to 1.34?
isowner function appears to works
But i can't find an isItemOwner
the vote button at the bottom of the page doesn't work either (ie. after thumbnails) - this is probably part of the same error.
Posts: 38
thanks for the quick reply. as soon as I can get internet connectivity back for my server from my school (long story) i'll apply the change and see how it works.
Posts: 114
2 questions.
My first:
Is it possible to setup the polling to be "Show Polling" always?
What I mean is that I don't want to have to tell users that they need to press on "show polling". Can I make a certain album as show polling by default?
My second:
how can I make the visitors be able to vote only once per month?
Is there a setting I need to change for cookies or sesson ID registration somewhere in the code?
Thanks, This is exactly what I was looking for! YOU HAVE MADE MY DAY!
I have started a new site for Electric Flying Wings (R/C) www.ElectricWings.com, and wanted to have a contest. But I could not find anything (script) to make this work. Until my wife said "have the users vote on the best picture since you already have a Photo Album in use.
Then I came here and found exactly what I needed. Installed it, and it works great!
My only problem is that I don't want users to vote more than once per month.
Regards,
NPereira
Posts: 114
Hey I see alot of people having problems with there hoster not having shell or ssh access. Check this hoster out. They are GREATE and INEXPENSIVE !
I STRONGLY SUGGEST THESES GUY'S !
http://redcheckhosting.com/?aid=34
Posts: 3473
1) Sure. Edit view_album.php and find
and replace it with
and delete
2) There's no date information recorded with the votes. You'd have to write it yourself. I'd just make only registered users allowed to vote, and have a new competition every month, but that's me.
Posts: 114
Hey Joan,
How does the Voting/Polling work when you don't want a person to vote more than once per month. My poll properties are setup as 'everybody'. Is there a way to have it so no one can vote more than once per month?
Please advise!
Posts: 3
joan, is there a version that only does voting/polling of the albums and not the photos? Also for it to possibly rank them in order of highest votes.
thanks.
Posts: 3473
No, but it could be written. Not high on my priorities
It does that, within an album.
Posts: 38
I'd like to upgrade to 1.3.4-RC3, but the link to this patch seems to be dead. is there an updated version of this patch available? thanks.
Posts: 3473
I've update the link on page one. But this is still a 1.3.3 patch, and I have not time table for upgrading it - though I hope to introduce a version in 1.3.5
Posts: 114
Joan,
Is this the lastest release of the vote candidate?
Let me know if there is one better!
Nelson