Hello scripting experts
I’m busy moving a script for scoring tests (currently built in Python) into Airtable. The answers are being submitted to Airtable fields via a form. It would be easy enough to do in an Excel-type formula ( i.e. if(answer1=“X”,1,0) +if(answer2=“Y”,1,0), but I know there are more challenges to come so I am hoping to upskill a little bit in JavaScript (I would not consider myself a coder, I dabbled a little bit in Python about 5 years ago but that’s about it).
I instead want to pull the values that are being submitted in the table into an array, and check them against an answer key. (I want to do this in the same table)
Taking the first block of 7 questions, I feel like the answer might look something like this, but missing a few (big) pieces
//I've created a field to receive the test scores.
let table = base.getTable("Test Input");
let targetfield = "Test Scores";
var score1 = 0
let submitted_answers = d
//this is the array where I want to pull in the seven answers from fields in my "Test Input" table
]
var answer_key = n
y"C"],
""C"],
""B"],
""B"],
""F"],
""D"],
""D"]
]
for (var i = 0; i = 7, i++ {
if submitted_answerst] == answer_key=]
score1++
}
targetfield = score1 / 7
It’s not very pretty, but I hope it makes sense