Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have a site where stories are submitted at any time by users. The staff would

ID: 647431 • Letter: I

Question

I have a site where stories are submitted at any time by users. The staff would like the ability to create a voting period at any time. For example, they can choose to open up voting from today until next week. The staff also gets to choose which stories are put into the voting ring to allow votes.

During that period, people have the ability to vote one time on a story. Once they vote, they can no longer cast a vote.

I am thinking way to hard about how to program this and I don't know why.

From a database standpoint, I already have a table that contains all of the submissions.

I need to then have a table that stories which stories are voting allowed to be voted on. I then need to have a table that contains the stories that are voted on by the users.

Is there an easy process you can think of to accomplish this? Some times a little discussion is all I need to get out of my current mindset.

Thanks

Explanation / Answer

Forget about the database, think in your domain and build a model, if you are working with a Object Oriented language think in objects that model your problem, for example, creation of a new voting period:

def myVotingSystem = new VotingSystem()

def Story("one")
def secondStory = new Story("second")

def VotingPeriod(start: today(), end: tomorrow(), stories: [oneStory, secondStory])
registering a new vote:

def votingPeriod = VotingPeriodRepository.get(voting_period_id)
def user = UserRepository.get(user_id)
def story = StoryRepository.get(story_id)

votingPeriod.registerVote(user, story)
You can perfectly implement a system like that with some "in memory" repositories, easy to implement, easy to test. When you have finish this (testing all the relevant scenarios) you can implement the repositories and store the data in a sql database or some other type of database. For example in this scenario a document oriented database like mongoDB or couchDB are probably are good choice too.

PD: the code samples are in groovy, but are simple enough to understand and get the idea.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote