Simple Voting App

Hi there all, just wanting to build a simple app that allows users to vote on their favourite film. I currently have a table that allows users to view films, and another table for voting.

I was thinking of using ‘Choice’ as the easiest way for users to select their preferred film, however I am having trouble collecting a tally from the choices.

Any suggestions? Happy to start all over again.

Thank you

Create a relation linking the film in the films table to the film in the votes table. Then create a Rollup column that uses the relation to count the matches.

2 Likes

Awesome will give it a go.
Cheers

1 Like

Ok having some trouble getting the buttons to create data. Have tried Choice a few times but the options seem to disappear once selected.

Ok having some trouble getting the buttons to create data. Have tried Choice a few times but the options seem to disappear once selected.


It sounds like you have your Choice component configured to read from and write to the same column. That won’t work.

But regardless, your Voting table looks odd. Can you explain what you would expect to happen when a user selects a Film? What should happen next? How would you expect to tally the votes for each Film?

1 Like

Hi Darren, thanks for the help again.

The idea is that people click on the film, watch it and the other film, then click on the choice button to vote for which film they think is the best.

It would be great to have people sign into the app or at least have a way to know who voted and for which film they voted for.

I see. So It’s comparing one film to another one. Will you only ever have two films? How will it work if you have more than two?

Yep, for sure. Here is another question - would you want to restrict voting in any way, or let folks vote as many times as they want?

Yes, ultimately we would have say 20 films. The form can be made to allow new films to be added so I know how that part can work. But for now let’s pretend we have 20 times already loaded into the table ‘Films’. And now that we have 20 films we would allow voting to happen.

Yes, we will want people to only vote once as a condition. If I learn how to do this then we can turn it off next year (if we decide to let people vote as many times as they like). So lets start with the condition of vote once and I can take off the condition later.

I was just wanting to set up the basics first. I am thinking I will delete all start from stratch.

Well, the important thing is to first try and get a clear picture of how you want it to work, which is why I’ve been asking questions (sorry).

And I have more questions, because I’m still not quite clear on how you want it to work.
For example, lets say we start with 20 films - now how will that work in terms of user experience?
With two films, we were just picking one from two choices. So when there are 20 films (or 100), is it the same thing - just pick your favourite film out of all those listed?

Anyway, let’s assume that’s how it should work. So… each person gets one vote only, and you want to be able to count how many votes each film gets.

I’ll describe one way to do this. It’s not necessarily the best or most efficient way, but it’s probably the easiest to understand and implement.

  • In your Voting table, you need to start with two columns:
    – FilmID: the RowID of the Film that was selected
    – UserID: the RowID from the Users table of the User that voted for that film
    – You might also want a Date/Time column as well, so you can keep track of when votes are cast, but that’s optional.
  • The idea is, every time a user votes, we will add a new row to the Voting table.
  • Now what you showed earlier is not a form screen. It was just a details screen with 3 components - a collection, some text and a choice. And this was basically where you were stuck, I believe.
  • So let’s fix that. Delete those three components from your Voting tab so that you are left with a blank screen.
  • Then add a single button. Configure the action on that button to “Show Form Screen”.
  • Click on the button and you should see a Form Screen with submit/cancel buttons, and probably some default input components.
  • The first thing to do is to target the form at the correct table. You’ll find that setting at the top-right. Target it at your Voting table.
  • Next, delete and any all components from the form so that you again have an empty screen. Then you just need to add the following:
    – A choice component
    — The source of the choice should be your Films table
    — The target should be the FilmID column
    – Next add a component to capture the UserID (RowID) from the User Profile and write it to the UserID column
    – And if you also want to capture the date/time, you can add a 3rd component to capture the current date/time

Now, every time you submit the form, you should see a new row appear in your Voting table.
Let me know once you get that part working, and I’ll give you the next steps to limit voting to once per user.

1 Like

Ok this is great, thank you Darren. I was just playing around cleaning out some experiments and I made a Form Screen for the voting.

So that when someone clicks on the Vote Button they are taken to the Form screen and the name of the film they click on is recorded as a new row.

I am getting the new rows with the film name that they chose coming through. It would be nice to be able to automatically tally up the number of times the film name comes up. I realise this is a pretty simple primitive method of voting and capturing data, but I am still on my beginners license with Glide.

I will keep going and incorporate you great suggestions.

Cheers

Okay, that’s good progress, well done :+1:

A couple of things:

  • Firstly, I see that you are saving Film name instead of FilmID (RowID). That’s fine, and it will work as long as you never edit the name of a Film. A better practise is to store the ID, but whatever.
  • Secondly, you don’t have a column in your Voting table to capture the ID of the User that voted. You will need this if you want to limit voting. To get it, you need use the “Additional Columns” section of the Form Container. Once you’ve added a column to store the UserID, configure the Additional Columns section so that it fills that column with the User Profile → RowID value.
  • Lastly, to get a count of votes per film, you are better doing this in your Films table. Add two columns as follows:
    – A multiple relation column that matches the Film name with the Film name in the Voting table
    – A rollup column that does a count via the multiple relation.
  • If you’ve done the above correctly, you will see a unique count for each row in your Films table.

Ok this is great Darren. I might try and screen record what I have and share it with you so you can see the things i am doing right and troubles i still have. Wondering if this would be possible?

I have mastered the counts, but linking to user / registered voters has be stumped …

I’m not seeing a UserID column in your Voting table?
You need that, as I indicated earlier…

Once you have that, to find out which users have voted then all you need is a relation in your Users table that matches the RowID with the UserID column in the Voting table. If that relation is not empty, then that user has voted.

Yes, by all means do that. I recommend loom.com

1 Like