Quantcast
Channel: Adobe Community : Popular Discussions - JavaScript
Viewing all articles
Browse latest Browse all 12130

can someone tell me if this would work...andif not why....

$
0
0

I want to grade a test that uses radio buttons to indicate the answers...there are 58 questions with five answers to select from for each question...I'm using a button that when clicked it will look at the radio buttons that ARE the correct answers and if they are selected a counter is increments by 1 if the correct answer is not selected there will be no increment.

 

This will allow me to perform a simple match calculation to achieve a test score. I'm not a programmer but I'm learning thanks to you guys on the forums...so what I got so far is below let me know if I'm on the right track ....My issue is how to develop a counter that will store the increments and allow me to use the results in a formula then place that number in a text box to be displayed ( I can probably figure the text box display thing out).

Radio button info:

Name: Q1

Tooltip: Question 1

Button Style: Circle

Radio Button Choice: a

 

 

Var Answer = this.getfield("Q1".value

Var Grade = 0;                             //don't know how to declare this variable should it be 0 only to have the else statement make it 0

 

If(Answer =="a") {             // "a" is the correct answer this time but will vary from a, b, c, d, e not sure how to loop so is my only other choice is to dupi such as Var Answer1, Var Answer 2, etc...

var Grade = "1"

}

else {Grade = "0",           // not sure if I even need the or else

}

 

I would perform this for each question because coding an array is beyond my abilities...

 

Here's my attempt at a counter

 

Var CounterCorrectAnswer = 0                                                     // sets the counter to Zero? correct

for (var i =1; i <= 58; i++){                                                           // set the value of i to 1 and the number of times to count to 58?...is the i++ means to increment i by 1 if the results = "2" ???    

 

var result =this.getField("Grade"+ i).value;   //now does the var Grade above get 1 added to it here..???..so what does ".value" represent here
if(result =="2"){                             // verifying that var result equals "2" 
  CounterCorrectAnswer
++                        //if result equals "2" then increment counterCorrectAnswer to 1...?    
}

 

this.getField("SumCorrect").value = CounterCorrectAnswer;   // SumCorrect will be the text box field that holds the total number of correct answers.

 

what confuses me again  is how do I loop through the questions "Q1 thru Q58" to see if the right answer was selected.


Viewing all articles
Browse latest Browse all 12130

Trending Articles