Assignment 5: New feature for the “publications” app
Both assignments 4 and 5 are due 23-Nov.; automatic extension to 25-Nov. If you complete assignment 4 early, submit it, and we’ll see if we can get comments back to you early.
The publications application is useful, but there is no way to tell what people really like.
Your assignment is to implement some means to gauge the popularity or value of a publication. You must also write up how you decided on your strategy, and how you implemented it.
You must modify the application to
- Accept ratings, votes, or “likes” for individual publications (more on these terms below), or figure out some other way to determine popularity (for example, count clicks on links).
- Show a count or average of the ratings, votes, or “likes” on each publication.
- Sort the publications by your metric.
Now, in deciding how to determine popularity or value, you’re going to have to put on your design / usability / product features hat. We want your evaluation of popularity/value to stand up. Here are some considerations:
- Voting means that you can vote “up” or “down.” Most likely, a user or visitor should only get one vote. I would think that a user or visitor should be able to change his or her vote (perhaps the user made a mistake, or changed his or her mind).
- Another way to think about it is a rating from 0 to 5 stars. Again, users should be able to change their ratings.
- A “like” (as used on Facebook) it like voting, but there’s no negative vote. I don’t think you can “unlike” something on Facebook, but you would probably want to provide that if you go this route.
- To express an assessment of a publication, must the user be logged in? If not, you open the ratings system up to abuse, and it would be harder for a user to change a vote after leaving the site, and coming back. You’ll have to decide.
- Another way to do this is to track clicks. The way this works is you point the Amazon and Safari links to an action which writes a row into a clicks table. The clicks table would need to have a foreign key pointing to the publication; and you’d want to know whether the link was an Amazon or Safari link. After the click has been recorded, then you redirect the user to the place he or she originally wanted to go. Again, there is the question as to whether a click should be counted multiple times per user, or only once.
Do not worry about visual appearance! For voting, you can provide ordinary text links or buttons that say “Vote Up” or “Vote Down.” Similarly, for a rating, you can have links to text for “1″ “2″ “3″ “4″ and “5.” In other words, assume that for a real feature a designer would help you out.
Nice-to-haves . . . While there is no extra credit, the very best submissions may . . .
- Implement the voting / rating / like system with Ajax;
- OR, provide an administrative controller that provides a more analytic view of the collected data.
@Lateral Punk
Are you using fixtures?
You don't want to try and put anything in your test database. Rails and the testing framework build the database for you and handle the setup / teardown of test data.
My tests were failing for each controller unit test. I just commented out the lines where it says:
I came back to read over this and see if there whas something I was missing with needing to write unit tests. After I removed those lines though, it did work..
I'm curious -- how would a test like that fail?
@Ron Newman
About the only thing I can think of is that a controller or model is missing, but the test still exists, and the framework is causing problems because of that.
@Ron Newman
@john
I dove into this a little more. When I created the model for ratings, I used script/generate... It apparently created a file named ratings.yml, and in this file there were four lines, which I had to comment out. This fixed any issues that I was having.
The four lines were very familiar to what I saw in different yml files:
Hi,
Where should the writeup for assignment 5 be located?
Thanks,
Karin
@Karin Berger
You may put it in the top-level README, or a file called student-writeup.txt
In order of format preference: .txt, .pdf, .rtf, .doc (please, no .docx).
My directory already has a (short) student-writeup.txt for Assignment 4, so I'll rename that one to student-writeup-4.txt .
I'm finding this in my server log every so often. It doesn't seem to be in response to any particular action I'm taking on the web site. Is some daemon running automatically and failing?
@Ron Newman
Not that I know of. Um . . . Are you using Clearance?
Nope, no Clearance in my Assignment 5.
@Ron Newman
I won't be able to look at it for at least 24 hours, but if you like, ZIP your project and e-mail it to me.
@Ron Newman Why would assert true fail?
This is actually an example from the book's unit test chapter where it does fail. Short answer: configuration.
@John: OK, I just zipped up my project (which isn't quite done yet, as I still have to finish the student writeup) and e-mailed it to you. I can't correlate any action that I'm taking in the browser to these error messages in the log. No error is ever sent to the browser.