2

I am a teacher and we are looking at going as paperless as possible. I learned (through searching here and asking a previous question) how to use Javascript to validate PDF form responses on an individual basis. I believe there are ways to validate an entire form prior to submitting it, but I haven't found out how to do that yet. The forms will be actually PDF documents, not web pages.

What my question is deals with that validation and submission. Is there a way to use javascript (or any other method) to:

  1. validate an entire form (which would be an entire assignment for a student to complete) with a click of the button?
  2. With that same click, submit the answers and "score" received to, say, a spreadsheet? My class has a website and domain that I can fully modify via cPanel to handle submissions, if I have to somehow set it up there.

Ideally, I want the submission and score, so students can't validate, change all their answers based on the validation, then submit a perfect assignment.

The alternative would be for students to fill out the form, validate, and have students print out their score. The only issue that I can see with that is with students reloading the PDF and changing their answers after validation.

Any insight or suggestions?

3
  • 1
    I can't imagine any way you could prevent people from running the validation and then re-doing the test. If you ship the validation code with the PDF file, then it'll be possible for somebody to find it. Commented Apr 18, 2013 at 18:17
  • I see no previous questions by you. Commented Apr 18, 2013 at 18:29
  • The previous question was not done under a regular user account, therefore I couldn't attach that question to this account, once it was created. Commented Apr 18, 2013 at 18:40

1 Answer 1

1

You can add JavaScript to the submit button and make it display the score and then submit the form field values to your website.

It is not fool proof. The Javascript error console in Adobe Acrobat/Reader may show leak information about your Javascript code. There are several PDF-processing tools that can extract JavaScript code from PDFs.

So, the best option is to have a simple submit button and have it submit the form field data to the server. On the server, you can have a script that evaluates the submitted form field data and send back a message to Adobe Reader in the form of a FDF stream. The FDF stream can contain the score.


  Response.ContentType = "application/vnd.fdf"
  Response.Write "%FDF-1.2" & VbCrLF & _
                 "1 0 obj<< /FDF << /Status (" & sAcroResponse & ") >>      >>endobj" & VbCrLF & _
                 "trailer" & VbCrLF & _
                 "<< /Root 1 0 R >>%%" & VbCrLF

The above script is in Classic ASP. The message (sAcroResponse) will be displayed within the Adobe Reader, not in a browser. You can adapt this script to whichever language that is supported on your web server.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.