2

Google has recently added the ability to program quizzes in Google Apps Script

var form = FormApp.create('Ice cream Quiz').setIsQuiz(true);
form.set
  // Make a 10 point question and set feedback on it
  var item = form.addCheckboxItem();
  item.setTitle("What flavors are in neapolitan ice cream?");
  item.setPoints(10);
  // chocolate, vanilla, and strawberry are the correct answers
  item.setChoices([
    item.createChoice("chocolate", true),
    item.createChoice("vanilla", true),
    item.createChoice("rum raisin", false),
    item.createChoice("strawberry", true),
    item.createChoice("mint", false)
  ]);
  // If the respondent answers correctly, they'll see this feedback when they view 
  //scores.
  var correctFeedback = FormApp.createFeedback()
      .setText("You're an ice cream expert!")
      .build();
  item.setFeedbackForCorrect(correctFeedback);

  // If they respond incorrectly, they'll see this feedback with helpful links to 
  //read more about ice cream.
  var incorrectFeedback = FormApp.createFeedback()
      .setText("Sorry, wrong answer")
      .addLink(
        "https://en.wikipedia.org/wiki/Neapolitan_ice_cream",
        "Read more")
      .build();
  item.setFeedbackForIncorrect(incorrectFeedback);

I would like the recipients of the quiz to view their own score automatically. I do not see how to do this programmatically. Rather I need to do this manually by gong into the Quiz settings and then set Release Grade to be "Immediately after Submission" and Respondent can see "Missed Questions", "Correct Answers", "Point Values"

Is it possible to set these programmatically?

Rubén
  • 34,714
  • 9
  • 70
  • 166
gordon613
  • 2,770
  • 12
  • 52
  • 81

1 Answers1

0

This question was previously asked here (but my answer has not yet been upvoted or accepted so I can't flag it as a duplicate). This is my suggested workaround:

AFAIAA, there is no means to do this directly using a Google Apps Script method at this time.

A possible workaround is to create a minimal Google Form, make it a quiz, and configure it to 'Immediately after each submission'. Instead of creating the form within the script, merely duplicate this Form file (using your script) and proceed to build your quiz programmatically in the copy.

It is worth noting that this omission in Google Apps Script can result in a bug in the completed quiz. When a Form is created using a script and .setIsQuiz(true) method is used to to turn it into a quiz, the "Release marks" setting defaults to "Later, after manual review". In the Forms settings User Interface, this option includes the note "Turns on email collection" - This is so that when results are released manually, there is an email address to send the results to. When a Quiz is created using the steps above, email collection is not enabled. This means it is not possible to release the results manually. The workaround described above alleviates this issue.

zimady
  • 137
  • 1
  • 11