Scoring questions via an answer key

Topic Labels: Scripting extentions
910 2
Showing results for 
Search instead for 
Did you mean: 
5 - Automation Enthusiast
5 - Automation Enthusiast

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 = [
//this is the array where I want to pull in the seven answers from fields in my "Test Input" table

var answer_key = [

for (var i = 0; i = 7, i++ {
	if submitted_answers[] == answer_key[]

targetfield = score1 / 7

It’s not very pretty, but I hope it makes sense :slightly_smiling_face:

2 Replies 2

Welcome to the Airtable community!

The Airtable scripting environment is a great place to practice JavaScript skills. It isn’t such a great place to learn JavaScript from the ground up. If you aren’t comfortable with JavaScript, I suggest learning the basics of JavaScript first, then add in Airtable concepts. If you are already comfortable with JavaScript, examine the sample scripts that Airtable provides to learn the Airtable specific tasks…

Things to do in JavaScript:

  • create an array
  • loop through an array
  • compare values

Airtable specific things to do:

  • input a record
  • read a cell value
  • write a cell value

Once you can do all the individual parts, then combine them for your entire script.

Best of luck in your coding journey!

Thanks @kuovonne - guess I’ll have to do some JS on the side before getting back to this. Appreciate the response!