DavidMoritz / rcv

Ranked Choice Voting app for free use.
https://rankedchoices.com
MIT License
64 stars 14 forks source link

Installation / Usage #3

Closed tpitman closed 7 years ago

tpitman commented 7 years ago

Sorry if this is a stupid question, but can you tell me how to use the RCV repository on an actual web server?

I am running apache2 with php7 (can install php5 if needed).

DavidMoritz commented 7 years ago

Also, I updated the README with consumption instructions. Please have a look at those and feel free to correct any confusing wording.

tpitman commented 7 years ago

So i have it mostly working. I can create a ballot, add entries and everything shows up in the db.

When I enter a code into vote now or results, however, it keeps saying it can't find the code or the time is wrong.

I get-candidates is returning the error string.

I took the query and manually ran it in mysql workbench and it comes back with results.

Any suggestions on how to debug this?

tpitman commented 7 years ago

One thing I tried was to modify the get-candidates.php code with some debugging type output. I changed the query and the error message.

The error message that came back was still the same?????

I restarted apache with /etc/init.d/apache2 restart and it said it restarted, but the php change didn't seem to take.

Any idea?

DavidMoritz commented 7 years ago

When I debug the api, I put a breakpoint at the place before sending, (to see the info being sent) and one on return (to see the response). If the sending looks good and the response is bad, I then adjust my api file to do things like "echo $variable" and such and look at what it says.

DavidMoritz commented 7 years ago

Are you sure you are modifying the file in the correct location? Like, modifying in dist/ or src/ won't do you any good for live edits.

DavidMoritz commented 7 years ago

Here's a thought. Run your page parallel with RankedChoices.com. Go there and open the main.js file. Put a breakpoint on lines 254 and 256. Type "tues" in the shortcode and press enter. Verify that "tues" is listed as the $s.shortcode and look at the resp on 256. Each step, do the same in your environment and see if anything is different.

tpitman commented 7 years ago

yea, modifying the one in /var/www/html/api

tpitman commented 7 years ago

Now this is getting really weird.

I did that on your site and it works fine. tues is shown as the short code and the results of the api call are the array of entries as it should be.

I have a ballot in my db with a short code of 3gop. I put that in and it gives the error.

I manually changed the short code of that SAME ballot to tues just for the fun of it. When I do that the query WORKS!!!???

If I manually change the short code of the same ballot back to 3gop, IT FAILS.

If I copy the query from the php code into mysql workbench and query for 3gop it WORKS.

I am totally confused.

DavidMoritz commented 7 years ago

Are you somehow pointing to my DB?

DavidMoritz commented 7 years ago

I was able to store a shortcode of "3gop" in my DB without any problem.

DavidMoritz commented 7 years ago

So, does "gop3" work? Does it just not like it starting with a number for some odd reason?

tpitman commented 7 years ago

suddenly my modified php started being run and has an error (forgot a ;) now I can't get it to use the fixed version. Something with caching I am sure.

I will try the idea of starting with a number once I figure out how to clear the php cache.

DavidMoritz commented 7 years ago

Well, it sounds like you are really close! Worst case, you only use shortcodes that don't include a number. I've never had an issue with php caching, but I guess you could send additional GET params like "&v=263" to break any client-side caching.

DavidMoritz commented 7 years ago

Or, perhaps you need to restart Apache every time you change the file, idk

tpitman commented 7 years ago

LOLOLOL, you are going to love this.

What happens after you create a ballot and submit the entires? It takes you to a page that gives you the url to send to people along with a link to click on for you to vote.

What do those have as a url? Not the ip address of the server I am running locally. They have rankedchoices.com. I have been click on that.

I am an idiot.

Sorry for that. Might be a nice change, however, to use the local URL when building those links instead of your hard coded url. Otherwise the site will always redirect to your web site and not the web site that is running your code.

tpitman commented 7 years ago

That also answers why my changes to the php were not taking. I wasn't even pointing at my site when I was trying to run them. I was not really looking at the address line in my browser this whole time.

DavidMoritz commented 7 years ago

Oh! of course. I didn't think about that. lol Sorry about that

tpitman commented 7 years ago

Question. How do I set a ballot to be done if I didn't give a cut off time?

DavidMoritz commented 7 years ago

So, this goes to the registered user ideas that I was creating. I had a profile page that included all the ballots a particular registered user had created and gave that person the ability to clear votes, cut it off, edit candidates, etc. But none of that works if they person makes the ballot anonymously. I suggest uncommenting the code that relates to additional features for registered users and take a look at the GUI I created. If you have any improvements, please submit a PR! But, without any adjustment to the current code, the simplest way to do that on the fly would be to set the vote-cutoff to be in the past manually in the db.

DavidMoritz commented 7 years ago

remove the "//-" on line 14 of index.jade and rebuild to see what I am referring to.

tpitman commented 7 years ago

Sounds good. I will take a look at this and let you know if I come up with anything.

I think having users for admin type stuff is needed. I then think having voters as a separate things is also what I will need.

I still owe you an email. I will send that now so you have a better idea of my situation. It is Caucus night for our local party. I am a precinct chair and district chair and am trying to come up with a better way to vote at caucus night.

I am basing it all on the Raspberry Pi because they are cheap. I will give more detail in my email....

DavidMoritz commented 7 years ago

Oh, also remove the class ".hidden" from line 22 of src/jade/partials/form.jade

tpitman commented 7 years ago

btw, what is the "waiting" task that happens at the end of the grunt command? It just sits there forever. What is it waiting for? I usually just ctrl-c it to get it to end

DavidMoritz commented 7 years ago

If you make any changes to the src/ folder, it will automatically rebuild the dist/ folder

tpitman commented 7 years ago

oh, so you leave that running if you what auto build. cool.

tpitman commented 7 years ago

i see the register stuff in the source index.html, but it still is not showing up in the site.

DavidMoritz commented 7 years ago

Maybe there's still a hidden class or something? Try viewing in the console. Make sure it's not cached On Wed, Apr 26, 2017 at 11:30 AM tpitman notifications@github.com wrote:

i see the register stuff in the source index.html, but it still is not showing up in the site.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/DavidMoritz/rcv/issues/3#issuecomment-297467475, or mute the thread https://github.com/notifications/unsubscribe-auth/ADe-iGAYrZSLrIyBwZVpC2inB64axlLPks5rz3EzgaJpZM4NIAi- .

tpitman commented 7 years ago

Good call. There is an exception, though I don't have enough experience to know why:

cb=gapi.loaded_0:70 Uncaught Object {error: "idpiframe_initialization_failed", details: "Not a valid origin for the client: http://10.48.10…itelist this origin for your project's client ID."} details : "Not a valid origin for the client: http://10.48.10.43 has not been whitelisted for client ID 828084230115-98814hb54sbrs34jjiecfirgak4svths.apps.googleusercontent.com. Please go to https://console.developers.google.com/ and whitelist this origin for your project's client ID." error : "idpiframe_initialization_failed" proto : Object (anonymous) @ cb=gapi.loaded_0:70

tpitman commented 7 years ago

Looks like maybe a local ip can't be used in the google api for users?

DavidMoritz commented 7 years ago

oh, I see. It's that when you sign into Google or Facebook, you need to have an account that actually specifies where the app is located. In order for this to work, you need to create a Google and Facebook developer account and create an new project, then use the credentials of that project in your calls as well as represent your ip address on the whitelist.

tpitman commented 7 years ago

Thought that might be the case.

I think I might work on the scenario that I emailed to you and not use those credentials.

I will keep you posted.

tpitman commented 7 years ago

I sent you that email. Let me know if you didn't get it.

DavidMoritz commented 7 years ago

I got it! Just finished reading. Thank you for sending it! I was at lunch with a friend, but I'll reply soon.

tpitman commented 7 years ago

I guess we do have to eat lunch once in a while :-)

tpitman commented 7 years ago

Let me know if I should start a new issue thread for this:

I am wondering about the random selection to eliminate candidates. Is this the main standard way or did you just choose it because it is easy to implement?

What are the other options? I read about eliminating all candidates who tie when they are all lower than the rest of the candidates (tie for lowest votes all get dropped and reallocated).

How hard would it be to implement that version? That one seems more "fair". I can see people getting upset about a random number being used.

DavidMoritz commented 7 years ago

You are referring to the topic of the only other issue thread on my repo! lol

Please review the dialogue I had with Paul Lockett: https://github.com/DavidMoritz/rcv/issues/1

Although it's counter-intuitive random really is the most fair. Keep in mind, ties are extremely rare and typically, the other candidate is the next one out anyway, rending the order of the tie resolution moot.

That being said, it's important to remember the one of the core philosophies of RCV is "No Tactical Voting". Paul Lockett makes a good case that if there is a method anything other than random, that could lead to people voting tactically, rather than honestly. But, with random, there is no such value in anything but honesty.

Again, the shear odds of two candidates having a tie for last and the outcome of a random determination of the order of their dismissal having any changed outcome on the final result in a legitimate election are staggeringly low.

DavidMoritz commented 7 years ago

Also, making a randomizer that provides consistent results for front-end consumption is not easier to implement.

tpitman commented 7 years ago

Sounds like using a random selection like you do now is actually preferred. That is good. I wonder if there are any good sites explaining that using a random pick is official.

One of the things I am planning when using this is to show some short videos that explain RCV so people know will will happen. If you know of one that includes using random tie breaking, I will use that.

DavidMoritz commented 7 years ago

https://youtu.be/l8XOZJkozfI That's a great video for it!

However, they call it "single transferable vote" (the older, less popular name) and they go more into detail about the value for multi-winner elections rather than being more instructional in nature.

DavidMoritz commented 7 years ago

But, I was thinking it would be cool to have an advanced option for tie-break method. Something like:

Random(official) ... Weighted ... No Winner

Then, the person making the pole can determine for themselves how they want to deal with tie-breaks.

tpitman commented 7 years ago

That is even better.

I think I watched that video after first coming to your github site. I found a couple others, but none of them talk about ties.

Implementing it as options would be best.

DavidMoritz commented 7 years ago

I appreciate you bringing this up! I have supplied instructions in the README file for proper consumption. Closing.