Expand my Community achievements bar.

SOLVED

Handling scoring in a form

Avatar

Level 7

I'm not sure how to handle this situation:

I have a form with a number of sections, with multiple questions in each section. All questions can be answered with Yes, No or N/A. I've set up a table for the questions with the three possible answers to each question in a drop-down list in the second column.

The way the scoring works is this: Yes is worth a certain number of points (not always the same) and No is zero points. The N/A answer is worth zero points but also decreases the possible number of points for the section. The total is calculated as a percentage.

For example, if there are 50 questions with a possible perfect score of 50. Each Yes answer = 1 point and a score of 100% and each No answer decreases the total score. Therefore, if there are 2 answers of No, the score is 96%.

If the answer to 1 question is N/A and the other 49 questions are answered Yes, the score would still be 100%.

I'm not sure how to handle the scoring. Any help would be appreciated.

Thanks,

MDawn

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi Margaret,

Here is a sample with five questions: https://acrobat.com/#d=ZK6RKqwW8DIICImPj2wsDg

The script is in the marks available and marks scored calculate events.

It is based on looping through the dropdowns and looking at their values. Yes = 1, No = 0 and N/A = -1.

Hope that helps,

Niall

View solution in original post

17 Replies

Avatar

Correct answer by
Level 10

Hi Margaret,

Here is a sample with five questions: https://acrobat.com/#d=ZK6RKqwW8DIICImPj2wsDg

The script is in the marks available and marks scored calculate events.

It is based on looping through the dropdowns and looking at their values. Yes = 1, No = 0 and N/A = -1.

Hope that helps,

Niall

Avatar

Level 7

Thanks. I'll give this a try. I didn't think to use a negative number.

Margaret Dawn

Supervisor - Documentation

W: 630-850-1065

Avatar

Level 7

I'm reading the script wanting to make sure I understand what it's doing so I can put it in my form. I notice that all of your Drop Down Lists are named DropDownList1. How would I change the script if all my drop down lists have a different name?

Thanks, (sorry for being a newbie!)

Margaret Dawn

Supervisor - Documentation

W: 630-850-1065

Avatar

Level 10

Hi Margaret,

The loop script is using the fact that the dropdowns have the same name. The loop is set up to run a variable 'i' from 0 to 4 (in your case 0 to 49). The loop looks at the .rawValue of each of the dropdowns and then takes appropriate action.

dropdown1[i].rawValue

You probably have two choices.

  1. Rename your dropdowns so that they have the same name, eg dropdown1[0], dropdown1[1],..., dropdown1[49]. This will make the scripting for the scores so much easier.
  2. Keep the names of the dropdowns the same, but the script for the scores will become much longer, as you will have to manually script the .rawValue of each individually named dropdown.

If it were me, I would go with option 1, as you can copy the name and quickly go through the hierarchy and rename the objects.

You may have to look out for table/subform names, if the drop downs are in different sections.

Niall

Avatar

Level 7

Thank you.

Margaret Dawn

Supervisor - Documentation

W: 630-850-1065

Avatar

Level 7

I'm renaming the drop-down lists as you suggested in Option 1 below. However, I'm not sure how to get the , , etc. to appear.

I know when I created the form, before I renamed the objects the system named them DropDownList , DropDownList[1].

Thanks,

Margaret Dawn

Supervisor - Documentation

W: 630-850-1065

Avatar

Level 7

I thought of another question. Does the script change if the score of some of the Yes answers are greater than 1? For example for one questions Yes=4, another Yes=2.

Thanks,

Margaret Dawn

Supervisor - Documentation

W: 630-850-1065

Avatar

Level 10

Sorry if I am confusing the issue.

You don't put in the [0] in the object name, LC Designer does that for you automatically.

Here are three dropdowns with the same name 'DropDownList1'.

Parallels Desktop11.png

When you select the first one in the hierarchy and click a second time to edit the name, LC Designer drops the [0] and just displays the object name.

Parallels Desktop10.png

When you finish the edit, if another object exists with that name, then LC Designer will put in the appropriate instance number (eg [2]).

You can also edit the object name in the Object > Binding tab. Select the dropdown and you will see that the editable area does not show the '[2]' and allows you to edit just the object name. In the area to the right, the instance number of the select object is shown (this area is not editable).

Parallels Desktop12.png

So you can edit the object names in both location and don't worry about the instance numbers.

One last thing, when setting up the loop, just make sure you are setting the variable i to go from 0 up to and including the last instance of the dropdown DropDownList1[49]. For example:

for (var i=0; i<=49; i++)

{

     ...

}

Hope that helps,

Niall

Avatar

Level 10

Yes Margaret,

It will affect the script for the 'Marks available' object. I have uploaded a revised example: https://acrobat.com/#d=a4WER8D067GlbSD2z7fZ9A

Basically there is an additional if statement in the loop to check if the score is greater than '1'.

this.rawValue = 0;

for (var i=0; i<=4; i++)

{

     var vScore = xfa.resolveNode("DropDownList1[" + i + "]").rawValue;

     if (vScore >= 0)

     {

          if (vScore > 1)

          {

                    this.rawValue += Number(vScore);

          }

          else

          {

               this.rawValue += 1;

          }

     }

}

Hope that helps,
Niall

Avatar

Level 7

That's very helpful thank you.

Margaret Dawn

Supervisor - Documentation

W: 630-850-1065

Avatar

Level 7

Thanks again. I really appreciate your help.

Margaret Dawn

Supervisor - Documentation

W: 630-850-1065

Avatar

Level 7

I have changed the name of the dropDownLists but the instance number is not changing although all 25 questions have the same drop down list name. Not sure what I'm doing wrong.

Margaret Dawn

Supervisor - Documentation

W: 630-850-1065

Avatar

Level 10

Hi Margaret,

Without seeing the form it is a bit difficult. However what I suspect is that the dropdowns are grouped in different subforms. This separates the dropdowns, so that they only see the objects in their own subform that have the same name.

For example here is the hierarchy for 12 dropdowns in the same subform, [0] to [11]

Parallels Desktop15.png

But when the dropdowns are grouped in three subforms the instance numbers only span for the objects of the same name in THAT subform, [0] to [3] AND [0] to [2] AND [0] to [4]:

Parallels Desktop16.png

You can still achieve what you want, but it will take a number of loop rather than one.

Maybe if you can show the hierarchy.

Niall

Avatar

Level 7

May I send you the form?

Margaret Dawn

Supervisor - Documentation

W: 630-850-1065

Avatar

Level 4

Niall,

I really must commend you for your efforts on this forum. We have novices without basic user-interface skills, who require scripting solutions, and you have the patience to take them on.

Kudos.

The next time you stop by the pub,  tell them your drinks and snacks are on me.

Avatar

Level 10

Thanks Iakov,

We all have something new to learn each day. I enjoy the community spirit.

Good luck,

Niall

Photoshop 2.png

Avatar

Level 7

Niall, thanks for the gracious response.

Margaret Dawn

Supervisor - Documentation

W: 630-850-1065