- make a link to the pdf
- use the pdf as the src for an img tag (like including a .png image)
Hi,
Was there any success in attaching link to local pdf files to .pg file?
I want to upload an assignment in PDF to file manager of the course and release on Webwork Assignment for students. But, when I open it: Webwork throws an error message:
No display module found for path '/CourseName/assignment_name/1/template/file.pdf/
Here, I am trying to access the file.pdf uploaded in File Manage. Any input will be appreciated.
WeBWorK is not designed to provide direct access to files in the templates directory.
From within a pg file you can use the following to create a link to a pdf file:
\{ htmlLink( alias('file.pdf'), "link to file", "TARGET='_blank'" ) \}
If you are using PGML you would use this instead:
[@ \{ htmlLink( alias('error2.pdf'), "link to file", "TARGET='_blank'" ) @]*
Note that the alias subroutine is hard-coded to only handle certain file formats, so pdfs are okay, but if you try to link to some exotic file format you might get an error.
Danny's code works for when `file.pdf` is in the same directory as the pg file, as OP describes.
An alternative that is better in some (not all!) situations, is to put the file in the course's html/ folder. That folder is parallel to templates/, so you navigate up one level in the File Manager to get there.
And then replace `alias('file.pdf')` with:
`alias("${htmlDirectory}file.pdf")`
And if you really want to hard code a link to that file in one specific course's html/ folder, then replace `alias('file.pdf')` with:
`'https://webwork.myschool.edu/webwork2_course_files/mycourse/file.pdf'`
where `myschool` and `mycourse` are edited appropriately.
To decide what is best, think about the consequences of how the .pg file is coded, and what will happen if it propagates to other courses.