Google Forms quizzes have one scoring rule: a right answer gets its points, everything else gets 0. A wrong answer and a blank answer score the same. That's fine for a pop quiz, but many real exams (Spanish civil-service exams and many entrance tests) take marks off for wrong answers: −1/3, −1/4, +4/−1 and so on. Run a mock exam in Forms and every student's mark comes out too high.

We built a small add-on, Nota Justa, that fixes this inside Forms itself. This post shows the approach, since most of it is plain Apps Script you can reuse.

The idea: write a negative score per question

Forms won't let you set "wrong = −1/3" in the editor, but the Apps Script FormApp API lets you set any score on a response item, negative included. So:

  1. Read the answer key from the form.
  2. For each response, decide right / wrong / blank from the key.
  3. Give each wrong answer a negative score, and give right and blank answers their usual points and 0.
  4. Save the grades back to the response.

The total Forms shows (and the score students see when you release grades) is now the penalised mark.

Reading the key

Multiple-choice and checkbox items expose their points and which choices are correct:

const q = item.asMultipleChoiceItem(); const points = q.getPoints(); const correct = q.getChoices() .filter(c => c.isCorrectAnswer()) .map(c => c.getValue()); 

Writing the score back

This is the core of it. For each question you want to change:

function grade(response, itemsById, scores) { Object.keys(scores).forEach(id => { const ir = response.getGradableResponseForItem(itemsById[id]); ir.setScore(scores[id]); // e.g. -0.33 for a wrong answer worth 1 point response.withItemGrade(ir); }); } // then, once per batch of responses: form.submitGrades(responses); 

Two details took a while to get right:

  • Judge from the key, never from the current score. After the first pass, the score Forms holds is already your penalised one. If you infer "wrong" from "score is 0", a second run goes wrong. Re-deriving right/wrong/blank from the answer key every time makes rescoring safe to repeat.
  • Rounding. A −1/3 penalty can't be stored exactly. We round each penalty to 2 decimals and put the leftover on the last penalised question, so the total equals the exact mark rounded once.

Existing responses: work in chunks

Apps Script stops a run at 6 minutes. A form with a few thousand responses can hit that, so the rescore works in chunks: it processes responses for a fixed time, calls form.submitGrades() every 50, saves its position in PropertiesService.getDocumentProperties(), and the sidebar calls it again until it's done. If the sidebar closes halfway, nothing is lost: the next open carries on from the saved position.

New responses: an installable trigger

For new responses, the add-on installs an onFormSubmit trigger once:

ScriptApp.newTrigger('onSubmit_').forForm(form).onFormSubmit().create(); 

In the handler, take a document lock (two students can submit at the same moment), rescore only e.response, and call form.submitGrades([response]).

Scopes

It runs with forms.currentonly (only the form it's installed in), script.container.ui for the sidebar, script.scriptapp for the trigger, drive.file for the optional results sheet, and userinfo.email, used only to make a hashed ID for the Pro licence check. Responses never leave Google.

What it doesn't do

It doesn't build the quiz. It isn't on the Workspace Marketplace yet: you paste two files into Extensions → Apps Script, one form at a time. Grid questions can't be rescored through this API, so they're only counted in the results sheet.

Try it or read the code

The free version has −1/3, −1/4 or your own rule and the class average out of 10 in the sidebar, with no response limit. Pro adds more rules (−1/2, by number of options, groups of wrong answers, +4/−1), any scale, your own pass mark and a results sheet with ranking and the most-missed questions.