Archive for the ‘User Preferences’ Category
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.
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.
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:
- In the main menu (top-right, next to the URL bar), click Settings.
- Scroll down, click “Show advanced settings”.
- Under Privacy, click “Content settings…”.
- Under Cookies, click “All cookies and site data…”.
- 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.
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.