TWiki
>
ISG Web
>
AssignmentInfo
>
AssignmentSolutionPHPScriptGDLibrary
(2011-12-19,
YiLee
)
(raw view)
E
dit
A
ttach
---+ Assignment Solutions Request using PHP's GD Library %TOC% ---++ Background Information Several CS courses post solutions online with the student's Quest ID as a watermark. This page describes a PHP script that provides such a feature. The script uses PHP's GD image library. Students will see the solutions as a PNG image file. Sample output (shrunken): <img src="%ATTACHURLPATH%/sample.png" alt="Sample Output" width="300" height="244" /> There is another set of scripts (AssignmentSolutionPHPScript) which also adds watermarks. Those scripts use PHP too, but the image processing is done with a bash script and <nop>ImageMagick. ---++ Setting Up the Script *If your course has never used this script before:* Download the file <nop>WatermarkSolutions.zip at the bottom of this page, and save it somewhere on the course account. In a terminal, =cd= to where you saved it, and run: <verbatim> unzip WatermarkSolutions.zip cd WatermarkSolutions bash Install.sh </verbatim> Now, open =/u/csXXX/public_html/SolnsWatermark/generateWatermark.php= and edit the =$staff= array to include the term's ISC, tutors, and instructors. You can now open a Web browser and try going to these URLs. Use your actual course instead of csXXX. <verbatim> https://www.student.cs.uwaterloo.ca/~csXXX/SolnsWatermark/generateWatermark.php?assn=demosolns1 https://www.student.cs.uwaterloo.ca/~csXXX/SolnsWatermark/generateWatermark.php?assn=demosolns2 https://www.student.cs.uwaterloo.ca/~csXXX/SolnsWatermark/generateWatermark.php?assn=demosolns3 </verbatim> You should see some sample code with your Quest ID as a watermark. You can now edit requestAssnSoln.php. That file contains PHP, but it's mostly just HTML. It displays links to the solution files. Edit it so that it fits nicely with your course website's design. *Do this at the start of every term:* 1. Open =/u/csXXX/public_html/SolnsWatermark/generateWatermark.php= 1. Edit the =$staff= array to include the term's ISC, tutors, and instructors. ---++ What To Do For Each Assignment Obviously, wait until _after_ the assignment is due before posting solutions. ---+++ Step 1: Convert the solutions to a PNG image file If the solutions are in plain text, first convert it to a PDF. This can be done by printing the solutions to a PDF file. Then, convert the PDF to a PNG image file. *Method 1: Use an image editor* Open the PDF file in an image editor like Photoshop or Gimp. Then save the file as a PNG. *Method 2: Use <nop>ImageMagick's =convert= command* In a terminal, navigate to the directory containing your PDF file. Then use a command like: %BR% =convert PDF-to-convert.pdf -flatten -trim Output-picture.png= *Notes*: * The resulting PNG image should be at least 720 pixels wide and 720 pixels tall. If it isn't, resize it with an image editor. * Don't make the image too long, either. If it's getting really long, break the assignment up by question. * The image should be legible. Don't use a font that's too small. After you have the solutions in a PNG file, move it to =/u/csXXX/SolutionsRequest/filename.png=. Choose any filename you like. ---+++ Step 2: Release Solution and Add Link Open =/u/csXXX/public_html/SolnsWatermark/generateWatermark.php= and add an entry to the =$solution_files= array. Use any key you like. For the associated value, put the path to your PNG file. Add a link in requestAssnSoln.php. The link should point to =generateWatermark.php?assn=ASSNID=, where =ASSNID= is the key you used in =generateWatermark.php=. Try viewing the solutions to make sure it looks good. If the watermark is not transparent, open your PNG file in an image editor and re-save it. ---++ Who can view solutions? Only these people can view solutions: * *Students listed in /u/csXXX/.classlist* * *Students listed in /u/csXXX/.exceptions* %BR% You can manually grant access for specific students by putting them in this file. Each line in .exceptions should have this form: %BR% =studentIDno:QuestID= %BR% Please don't add any spaces or tabs at the end. Example line: =20401835:j9smith= * *Staff listed in the =$staff= array in generateWatermark.php* %BR% Staff can add a =u= variable at the end of the URL to change the watermark text. For example: %BR% =https://www.student.cs.uwaterloo.ca/~csXXX/SolnsWatermark/generateWatermark.php?assn=a00q1&u=whatever= ---++ Log File A log entry is made every time someone successfully views a solution. The log file is =/u/csXXX/course/SolutionsRequestLog.txt=. Each entry has the format: =Time, Watermark Text, Quest ID, assignment ID=
Attachments
Attachments
Topic attachments
I
Attachment
History
Action
Size
Date
Who
Comment
zip
WatermarkSolutions.zip
r3
r2
r1
manage
603.3 K
2011-12-19 - 22:38
YiLee
All the files you need and more!
E
dit
|
A
ttach
|
Watch
|
P
rint version
|
H
istory
: r4
<
r3
<
r2
<
r1
|
B
acklinks
|
V
iew topic
|
Ra
w
edit
|
M
ore topic actions
Topic revision: r4 - 2011-12-19
-
YiLee
ISG
ISG Web
ISG Web Home
Changes
Index
Search
Webs
AIMAS
CERAS
CF
CrySP
External
Faqtest
HCI
Himrod
ISG
Main
Multicore
Sandbox
TWiki
TestNewSandbox
TestWebS
UW
My links
People
CERAS
WatForm
Tetherless lab
Ubuntu Main.HowTo
eDocs
RGG NE notes
RGG
CS infrastructure
Grad images
Edit
Copyright © 2008-2025 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback