MarkUs Blog

MarkUs Developers Blog About Their Project

User preferences

with one comment

User preferences will soon be added to the Assignment->Submissions page and here is a little overview of what to expect.

Entries per page, Sort order

The number of entries per page and the sort order (column name, asc/desc) will now be saved after the user sets them. Those settings are user/assignment dependent, therefore they can be set independently when the user/assignment change.

Show/hide columns

The user will be able to change which columns are shown/hidden via a pop-up triggered by clicking the pencil at the end of the table’s header (see picture below). Those settings will only be user dependent (for a specific page), therefore, if the user chooses to hide a specific column, this column will remain hidden for all the assignments’ submissions this specific user sees.

Cookies

For the moment, independent cookies are created for every setting saved as a preference. As an example, the show/hide columns preference is stored in the cookies as “[userId]_submissions_columns”. The number of entries per page is stored in the cookies as “[userId]_submissions_[assignmentId]_sort_by”. Therefore, you can test individual cookies/setting more easily.

There are multiple ways to save cookies:

1: cookies[(cookie name)] = “Cookie content”

This will create a temporary cookie which will be deleted when the user’s browser is closed.

2: cookies.signed[(cookie name)] = “Cookie content”

This will create a temporary cookie which will be deleted when the user’s browser is closed. A signed cookie can’t be tempered with manually by users. The cookie is signed with a unique app token.

3: cookies.permanent[(cookie name)] = “Cookie content”

This will create a permanent (20 years) cookie. If the user chooses to clear his browser’s cookies, those will still be deleted.

4: cookies.permanent.signed[(cookie name)] = “Cookie content”

This will create a signed permanent cookie. If the user chooses to clear his browser’s cookies, those will still be deleted.

User preferences are currently saved in unsigned permanent cookies (#3).

For more info, you can check: http://api.rubyonrails.org/classes/ActionDispatch/Cookies.html

Tips & Tricks

In Chrome, you can easily see all your cookies in a “user readable” way:

  1. In the main menu (top-right, next to the URL bar), click Settings.
  2. Scroll down, click “Show advanced settings”.
  3. Under Privacy, click “Content settings…”.
  4. Under Cookies, click “All cookies and site data…”.
  5. You can then search all your cookies by entering the desired host name. If you enter “localhost”, you should see all the cookies your local Markus creates. You can then choose one and see all its content/metadata.

This can be very useful when you need to debug/develop using unsigned cookies (signed cookies are not user readable). I don’t know if Firefox offers something similar though.

Final word

There would probably be better ways to handle single/multiple cookies (maybe with a specific gem). If any of you have any ideas regarding user preferences, don’t hesitate and let me know! I will probably be working on implementing them for other pages, so it will not be difficult to change some aspects while I’m at it.

Written by e-morency

November 18th, 2012 at 9:08 pm

One Response to 'User preferences'

Subscribe to comments with RSS or TrackBack to 'User preferences'.

  1. If you’re using Chrome, another way that you can see all of the cookie data is to use the Chrome debugger. Press Control-Shift-i to load it, and browse to the Resources tab, and then Cookies on the left menu. This will show you the cookies being stored by the current domain, and all of the data in each cookie.

    Joey Perry

    25 Nov 12 at 4:15 pm

Leave a Reply