It allows you to pull up each page of the PDF as an image in a web browser window, to add annotations to the page and then return the newly-annotated PDF to the student.
It works on the server with a combination of ghostscript, FPDI and TCPDF, with some Mootools thrown in on the client. There is no need for any plugins to be installed on the client side.
It is yet not ready for a production server (I've only just finished it after a couple of weeks work) and there are a few ideas I haven't yet implemented (automated coversheet adding being the main one, as well as alternative annotation colours and possibly boxes / lines).
Any suggestions / bug reports / fixes would be very welcome...
As it is a bit too large to attach to this post (due to the TCPDF library which I have included to save a separate download), you can find it here:
http://dl.getdropbox.com/u/933969/uploadpdf.zip
I've tested it with Moodle 1.8 and 1.9.
Oh and I haven't put and License info in it yet, but I'm sure I'll be putting it out under the GPL (once I've double-checked all the licenses for the files I'm bundling with it).
If there are problems with the text when you first view it, then that is an issue with GhostScript. First, could you make sure you have the most up-to-date version of GhostScript installed.
Second, can you try the running following command line:
(For Windows):
<path to ghostscript install>/gswin32c -sDEVICE=png16m -dGraphicsAlphaBits=4 -dTextAlphaBits=4 -sOutputFile=image%d.png <name of PDF to test>
(For Linux)
gs -sDEVICE=png16m -dGraphicsAlphaBits=4 -dTextAlphaBits=4 -sOutputFile=image%d.png <name of PDF to test>
(Where <name of PDF to test> should, obviously, be replaced with the name of a PDF).
Look at the images produced (which should be called image1.png, image2.png, and so on for each page) and see if they are alright. If not, see if you can file a bug report on the GhostScript website.
If there are problems with the comments added to the file, then I will have to check out whether my code is properly supporting UTF8 (which it is supposed to be doing).
If you move to a different page in the document (whilst editing comments) then move back to the previous page, do all the comments display correctly?
Are there problems with the main text of the final file? (or just the comments?)
Problems with the output will be down to the FPDI/TCPDF libraries I have used.
Are you able to attach a small example of a PDF that does not work (and possibly an example of the result produced)?
From what I could make out in your attached file, the ghostscript side of things seems to be working, but not the export (is everything OK in the top part of the picture?)
I may be able to fix the question marks in the comment output, by switching to a different font, but I have no way of testing this as I am unable to enter (or understand) Chinese characters.
As for the distortion in the original text, I don't really have any control over that at all, my code just calls the FPDI library to load the original PDF and copy each page, one at a time - the only modifications I make are using the TCPDF library to add the extra annotations on top. Maybe you could try and find out if that is a known problem with those libraries (again, without any PDFs in Chinese, it is difficult for me to attempt a fix).
I have the problem when using the uploadpdf module. It display "??" for the chinese character in the response.pdf. Please advise the solution.
By the way, I find the chinese.php, chinese-unicode.php files that can make fpdi support unicode. But I don't know how to manipulate it.
Actually this plugin is good for onscreen marking. I can only draw straight line using the plugin. If I would like to draw other symbol like circle, tick, insert (i.e. /\) etc. Is it difficult to modify the code to get that? Which file in your plugin should I modify?
I did not add any other forms of drawing as I wanted to keep the user interface simple & quick to use - n/p to choose page, click to add text, ctrl+click to add a line.
However, if you want to add other shapes to your local version, you will need to edit the following files (off the top of my head - I don't have any code in front of me at the moment):
- assignment.class.php - add any extra UI elements to select the shape, add code to handle the new shape data coming back from the client + save to the database, add code to pass the new shapes onto the PDF drawing routines
- lang/en_utf8/assignment_uploadpdf.php - add any extra language strings needed by the UI
- scripts/annotate.js - add code to allow drawing of the shapes (probably the largest bit of work) and communicate the data back to the server
- mypdflib.php - add code to draw all the shapes onto the PDF
If you can come up with a neat way of adding this without overcomplicating the UI, then I might be interested in updating the module, but I don't want to add anything unnecessary to it.
One way I think is to edit the annotate.js by adding another function for inserting the graphics onto the pdf.
I have tried to make the source code as clear as possible, but unfortunately there is a lot that it needs to do, so there is a limit to how clear I can make it.
There are quite a few parts to the changes that you will need to make:
- Change the page layout to add the interface for adding ticks, crosses, etc. (this is in 'assignment.class.php' - function 'edit_comment_page')
- Add code to annotate.js to allow the positioning of the symbols (you should read up on MooTools, as that is the javascript library I used, before I realised that Moodle uses YUI)
- Add code to annotate.js to send this information back to the server.
- Add code to 'assignment.class.php' - function 'update_comment_page' to handle this and save to database (you might want to just use the 'addannotation' code and send a different 'type' in step 3 - e.g. 'tick' or 'cross' for the type, this would mean you could miss out step 4 altogether).
- Create a new function in mypdflib.php that will draw the images into the PDF (you will have to look at the TCPDF documentation for this, as I've not tried to do that)
- Adjust the code in 'assignment.class.php' - function 'create_response_pdf' to call the function created in step 5, if the annotation type is something other than 'line'
Please feel free to ask any more questions, or email me directly on moodle AT davosmith DOT co DOT uk, if you want more help.
Hi David,
I found that I cannot grade the exercise after students' submission. I try to give marks, comments and then click "save changes" to save the mark/grade. But the page refreshes and show nothing in the comment text box, and the marks cannot be updated in the grade column.
Please advise if it's the problem on the module or my moodle site.
However, it may still be something I've done wrong, somewhere along the line. Please could you tell me exactly where it is going wrong - are you using the 'view all submissions' page (with the big table showing all of the submissions), or the 'grade one submission' view (which shows just a single submission, in a separate window)?
Could you try running updating the comments via the other method and see if that works (either the 'single' or 'all submissions' view, depending on which you have already tried)?
Also, could you try setting the debug level to 'All' and see if any error messages appear?
Thanks for this, I just installed it without any problems and played with it a little.
The only problem I encountered so far is that, when creating/updating the assignment, clicking one of the validation buttons ("Save and return to course" or "Save and display") leads to a blank page. Navigating back and reloading the course page or module page shows that the creation/modification actually occured without any problems. Could there be missing an HTTP redirect ?
besides all is working perfectly well on my Moodle 1.9.2 / Apache 2.0.52 / PHP 5.2.9 / Debian Linux 4 / "gs" package installed.
I shall hopefully post further comments in a few weeks, as soon as my colleagues have the time to have a look at it.
Regards,
Nicolas.
Edit: Just re-read your original post and realised you were talking about the comment form, not my 'annotation' form. Will have to have a closer look at that.
I am currently working on a number of fixes/changes, which I will hopefully upload once they are done. Including:
1. Retaining the upload order of the files (so the combined PDF is in the right order).
2. Allowing non-PDF files to be uploaded as well (so that interactive elements, e.g. a working spreadsheet, can be checked alongside the 'printout').
3. Adding coversheets, with templates to insert student name, submission date and initials, to indicate 'this is all my own work'.
It installs fine but when I try to edit templates I get the error message "your site is not configured correctly".
I'm not that good technically - i use Apache and Linux
I've installed ghostscript in the public html directory and written the path $CFG->gs_path='http://www.mysite.net/gs';
Have you any idea where I could figure out how to install the ghostscript
Thanks
alan
It does work if you save the assignment then click on 'update this assignment'. But to avoid having to do that, there is a new, fixed version available here:
http://tracker.moodle.org/secure/attachment/17033/uploadpdf.zip
(Which also fixes an issue with marking an assignment, then clicking 'revert to draft' and a couple of issues with the 'templates' list on the settings page not updating immediately when you create/delete a template).
As for installing ghostscript, it depends what type of server you are on.
If it is a Debian/Ubuntu Linux server, type on the command line: sudo apt-get install ghostscript
For a Red Hat or Fedora version, it will be something like: su -c 'yum install ghostscript' (note I have no real experience of Red Hat/Fedora Linux versions, so that might be slightly wrong).
Either way you should be able to run ghostscript just by typing 'gs' on the command line. If that works, then the correct setting in uploadpdf_config.php should be:
$CFG->gs_path = 'gs';
(Side note: this tells my plugin where to find the ghostscript program on your local computer, not how to find it from the web server)
I hope that helps to clarify the situation - please feel free to ask for any extra help.
Many thanks for that
I'll try that out
Best regards
alan
نظر در مورد: Re: Online PDF marking/annotation assignment module
Hi
I download the uploadpdf tool for moodle. I follow the instructions in readme file. when I click on "submisson.pdf" I get the following error:
"C:\Program Files\Ghostscript\gs8.64\bin\gswin32c.exe -q -sDEVICE=png16m -dBATCH -dNOPAUSE -r100 -dFirstPage=1 -dLastPage=1 -dGraphicsAlphaBits=4 -dTextAlphaBits=4 -sOutputFile="C:\xampp\htdocs/moodledata/2/moddata/assignment/1/5/images/image_page1.png" "C:\xampp\htdocs/moodledata/2/moddata/assignment/1/5/submission/submission.pdf" 2>&1
operable program or batch file."
Unable to generate image from PDF - check ghostscript is installed and this module has been configured to use it
I install Ghostscript and I set the path in uploadpdf_config.php file. to "C:\Program Files\Ghostscript\gs8.64\bin\ gswin32c.exe \
please help me with this issue.
Regards,
leila
Re: نظر در مورد: Re: Online PDF marking/annotation assignment module
I think it has to do with the space in \Program Files\
I moved the \gs\ folder to \xampp\gs\ and edited the config file accordingly and now it works.
Hope that helps you!
Justin
Re: نظر در مورد: Re: Online PDF marking/annotation assignment module
I'll try to fix the README.txt and config.php files to reflect this information.
Davo
Re: نظر در مورد: Re: Online PDF marking/annotation assignment module
I have the same error message.
How can i resolve this.
Re: نظر در مورد: Re: Online PDF marking/annotation assignment module
http://moodle.org/mod/data/view.php?d=13&rid=2350
Secondly, make sure you have installed Ghostscript to somewhere that does not have a space in the pathname (e.g. in Windows, make sure the path is 'c:\gs' NOT 'c:\Program files\gs') and make sure the 'uploadpf_config.php' file is set correctly.
Please see the above link for more detailed install instructions.
If that does not work, please could you copy & paste the line out of 'uploadpdf_config.php' that shows what you have set the path to as well as the full error message that you see from the plugin.
Thanks
Re: نظر در مورد: Re: Online PDF marking/annotation assignment module
hi have the same problem i have no spaces in the config file,
can some talk me thoruh seting it up with php
Re: نظر در مورد: Re: Online PDF marking/annotation assignment module
You will need to copy & paste the error message, before I can suggest any ways to fix it.
http://tracker.moodle.org/secure/attachment/17018/uploadpdf.zip
could you maybe post a screen shot of the annotation screen. Does the annotation feature allow freehand annotations made with a Tablet PC?
Many thanks
best Fritz
There is a screenshot on the plugins page (but I'm not sure if that has been aproved by the moderator yet).
I've linked to the screenshot below:
I'm afraid that tablet annotation is out - this works with Javascript and that is not very good for capturing drawings (maybe things will improve it IE ever implements the Canvas tab, but I can't see that happening anytime soon). (Plus, half the point of this plugin was to get away from my terrible handwriting on printed assignments! )
The annotations in this plugin are all text boxes.
Whilst I think of it, now that this plugin has been accepted into the contrib section of Moodle CVS, all future versions of it will be found here:
http://download.moodle.org/download.php/plugins/mod/assignment/type/uploadpdf.zip
With bugs / suggestions going here:
Problem install moodle-weekly-19 on local server xampp-win32-1.5.4-installer.exe
Hallo every body,
I am Indonesian, and I am still newbie about moodle. when I install moodle-weekly-19 in on local server xampp-win32-1.5.4-installer.exe, there is problem under
The PHP memory limit is set quite low ... you may run into problems later.
Where I can get the local server to solve the problem can you help me. please
Re: Problem install moodle-weekly-19 on local server xampp-win32-1.5.4-installer.exe
You should post your question (or maybe find the answer already posted here) in the adequate forum : "Installation problems".
You also can find general information about Moodle installation here : http://docs.moodle.org/en/Installing_Moodle
Re: Problem install moodle-weekly-19 on local server xampp-win32-1.5.4-installer.exe
I just wanted to test the new version of this assignment module you provided in you last post, and encountered repeatedly the same problem : when the student submits his work ("Validate for evaluation"), he (after confirmation) always gets the following error :
TCPDF ERROR: Unable to find pointer to xref table
Any ideas ?
Regards,
Nicolas.
Re: Problem install moodle-weekly-19 on local server xampp-win32-1.5.4-installer.exe
I don't know anything about the internals of that library - I just use it to load the PDFs for editing. However, it would be helpful if you could let me know the following information:
* What software did the student use to create the PDF?
* What PDF version number was it? (open the PDF in Adobe Reader, click File, Properties and that should tell you)
Davo
Re: Problem install moodle-weekly-19 on local server xampp-win32-1.5.4-installer.exe
One file is a "PDF version 1.4 (Acrobat 5.x)" generated by Adobe Acrobat Pro, while the other one is a "PDF vetrsion 1.3 (Acrobat 4.x)" generated by Mac OS X 10.5.
Regards,
N.-
Is there any chance you could create a PDF that doesn't work (using Acrobat Pro or Mac OS X) and attach it to this bug report: http://tracker.moodle.org/browse/CONTRIB-1286 ?
I quite understand if you don't want to post a student's original work.
Alternatively, I have had great success using PDFCreator (free download) to print PDFs that work with UploadPDF.
Davo
My second example actually was generated only for testing this module by my Mac-using colleague, so I attached it to your module's tracker.
Are you attaching a coversheet to the submissions? Could that be the file that the upload is struggling with?
I'm not using any coversheet. I'll double-check all the internals on my server and let you know if anything comes out.
http://download.moodle.org/download.php/plugins/mod/assignment/type/uploadpdf.zip
Main difference is that old generated image files are now cleared out using a cron job (to save cluttering up the moodle data folders).
There are a few more minor tweaks and fixes on the way (search on tracker.moodle.org for items I plan to look at and to add any other suggestions for me to fix)
Davo
C:\gs -q -sDEVICE=png16m -dBATCH -dNOPAUSE -r100 -dFirstPage=1 -dLastPage=1 -dGraphicsAlphaBits=4 -dTextAlphaBits=4 -sOutputFile="C:\moodle\server/moodledata/2/moddata/assignment/6/9/images/image_page1.png" "C:\moodle\server/moodledata/2/moddata/assignment/6/9/submission/submission.pdf" 2>&1
In your case, the path you should give is:
c:\gs\gswin32c.exe
OR
c:\gs\bin\gswin32c.exe
(depending on exactly which folder the 'gswin32c.exe' file is in)
Davo
TCPDF ERROR: Cannot open C:\moodle\server/moodledata/2/ !
Any help on this greatly appreciated
The second error is a bit odd - it seems to be looking for a file, but only generating half the file path needed. Could you let me know exactly what you were doing when you got that error, including whether or not you were using a coversheet (and the path to the coversheet if you were).
Davo
I had a similar problem uploading a submission. Initially I did include a coversheet. After some tinkering, I added a coversheet and all works fine. It seems a coversheet is necessary for the upload to function.
Happy it is working now!
- Alan.
I still have no idea how to fix the Chinese characters bug as I don't have any idea how to enter Chinese characters on my home (Ubuntu) computer. That means I can't even start to debug it.
I have now reproduced the problem and created a bug here: http://tracker.moodle.org/browse/CONTRIB-1798
However, I am at a loss as to how to solve it - it certainly will involve working out how to get the TCPDF library to write Chinese characters to a file, but I don't know how to do that and the relevant example on the TCPDF website (example 38 on this page: http://www.tecnick.com/public/code/cp_dpage.php?aiocp_dp=tcpdf_examples ) gives me blank space where the Chinese writing should be.
Anyone got any ideas?
Which file and path should I modify so I can make TCPDF to support Chinese character? Do I modify the files under the TCPDF folder?
You could try downloading the latest version of TCPDF from here:
http://www.tcpdf.org
You will then need to copy the file 'arialunicid0.php' from the 'fonts' folder, into 'moodle/mod/assignment/type/uploadpdf/tcpdf/fonts'.
Then open up the file:
'moodle/mod/assignment/type/mypdflib.php'
and change the two lines that look like this:
$this->SetFont('helvetica','', 12.0 * $this->scale);
to:
$this->SetFont('arialunicid0','', 12.0 * $this->scale);
If this works, then great. If this doesn't work, then I don't have any other suggestions, at the moment.
We have installed it on 1.9 and it seems to work well with one exception. When teacher clicks on an uploaded assignment an error message pops up indicating it is trying to open page 2 and there is only 1 page in the document. If the cancle button is clicked the box closes and the teacher can proceed making comments and grading and saving with no other problems.
Is it still a problem for you?
The 'download' link just downloads the PDF and opens it in Adobe Reader (or whatever other PDF reader you have installed on your computer), so that will no longer be connected to the marking system.
As you are able to add comments, javascript appears to be up and running in your browser.
I assume you have the two navigation buttons at the top of the page (next, prev) and a dropdown list of pages in between them.
Are the next/prev buttons enabled?
Does anything happen when you click on them?
Are there any pages (other than page 1) in the drop-down list?
What happens if you click on one of them?
Can you copy the address (at the top of the page), paste it into a new window, then add '&pageno=2' to the end of the address (so it looks something like http://[moodleserver]/mod/assignment/type/uploadpdf/editcomment.php?id=123&userid=345&pageno=2 - the 123 and 345 will depend on your particular set up).
If you are able to, a screenshot of the page might also help with figuring out what is going wrong.