Closed damianhxy closed 2 months ago
Also, is there a way to shorten the url in the case of duplicates, "test778-cf1a1964-f358-4cff-8136-8c9791b40ec6" this seems a little too long. Would it make sense if we generated a random string usingSecureRandom and took the difference to get a shortened slug that is still unique.
Also, is there a way to shorten the url in the case of duplicates, "test778-cf1a1964-f358-4cff-8136-8c9791b40ec6" this seems a little too long. Would it make sense if we generated a random string usingSecureRandom and took the difference to get a shortened slug that is still unique.
Modified the code to tiebreak by appending the attachment's id
Not sure if this is desired but when for existing attachments, the url does not include the attachment name, it only includes after I rename the attachment or upon creating a new attachment
That was intended and IMO it's fine, attachments don't seem to be widely used yet, and this change is more to facilitate attachments in future courses.
According to the documentation, you'd have to do something similar to User.find_each(&:save)
. If you feel like it's important to generate slugs retroactively, I could put this in the migration
Description
Motivation and Context
Some classes might use assessments as "placeholders" to distribute course materials (via writeups), as compared to attachments, since assessments can be easily bulk imported and the URL is "static" (only need to change course name between semesters). This PR further facilitates that workflow by allowing students to quickly download an assessment writeup from a course landing page by clicking on a badge. This is also useful for students to view writeups of normal assessments quickly.
This PR also switches to slugged URLs for attachments, i.e. the URL is generated from the attachment name. This would be helpful down the road if a way were added to mass import attachments since attachments would become a viable replacement for assessments.
This PR also fixes a docs syntax highlighting issue introduced by #2131.
Resolves #2035
How Has This Been Tested?
Slugged Attachments
Writeup badges
Badge appears only for assessments with writeups. Clicking on the badge brings you to the writeup.
Docs highlighting
Run
mkdocs serve
locally and ensure that the bash commands on e.g. the docker compose installation page now render correctly.Before
After
Types of changes
Checklist:
overcommit --install && overcommit --sign
to use pre-commit hook for linting