1

I've made a fillable multiple-choice test to send out for assessments on ships without reliable net connections. The questions each have three options, generally with radio buttons and a single correct answer (one question has checkboxes instead with two correct options).

Questions with radio buttons

As things stand, the answers can be checked manually. I would prefer to automate the checking process, marking correct answers on the answer sheet with a green tick (and incorrect answers with a red X, presumably using Wingdings for simplicity?) and displaying a message to proceed to the certificate when they get 100% correct.

Answer sheet with cells showing correct answer

I'm not at all familiar with coding in Acrobat forms. Is there a relatively easy way of accomplishing this?

Andrew Perry
  • 217
  • 1
  • 4
  • 16
  • 2
    It's not really clear what you want to do: who would trigger the checking process? the user? someone else? Is the answer sheet in the same file, or in a separate file? What is the second image in your post for ? – 1NN Dec 10 '21 at 13:25
  • It's all in a single PDF. The aim is to calculate as they go, so that when they get to the page with the answers - the second picture - each answer is already marked with a tick or a cross and a message appears to tell them to fill out the certificate. – Andrew Perry Dec 15 '21 at 09:05
  • 1
    See this: https://stackoverflow.com/questions/27471285/acrobat-xi-pro-checking-status-of-a-checkbox-to-affect-calculation, and then this: https://answers.acrobatusers.com/Can-calculated-cell-PDF-form-conditional-formatting-change-colors-q150129.aspx – 1NN Dec 15 '21 at 11:06

1 Answers1

1

You'll need to use Javascript to do this. I'll put here a stub, as a complete answer would require extensive coding, and is off-topic here.

The code goes into each field's "custom validation script".

To check whether the correct checkbox is checked, for each field in your verification table, you'll need to insert an if.. else.. statement (copied from this answer on stackoverflow)

if (this.getField("myCheckBox").value != "Off") { 
   // the box is checked 
   // do what should be done when the box is checked 
} else { 
   // the box is not checked 
   // do what should be done when the box is not checked 
}

To set the color of your field, according to this post you need the code:

event.target.fillColor = color.green;

So, in total, this would become something like:

if (this.getField("myCheckBox").value != "Off") { 
   // the box is checked 
   event.target.fillColor = color.green;
} else { 
   // the box is not checked 
   event.target.fillColor = color.red;
}

where myCheckBox is the name of the checkbox for the correct answer.

I have not validated this code, as this should be done by you. If you need further help for your code, ask a question on the stack overflow community

1NN
  • 5,232
  • 1
  • 17
  • 37
  • Thanks - I think that'll get me pointed in the right direction. I'll have a play with that code, then head over to the Stack if I have any followups! – Andrew Perry Dec 16 '21 at 15:26