问题
I want to make auto-grading short-answer quiz using google forms.
The data is in spreadsheet.
- column A has questions.
- column B has correct answers.
- column C has explanations.
The code below makes quiz, but don't set correct answer in each question.
"item.createResponse(an);" seems not working.
How do I set correct answer?
let form = FormApp.openById(formID);
form.setIsQuiz(true);
// get data from sheet
let ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('문제');
let range = ss.getDataRange();
let data = range.getValues()
data.forEach(function(el){
// data
let qu = el[0]; //question
let an = el[1].trim().toUpperCase(); //correct answer
let ex = el[2]; //explanation
// create each question
let item = form.addTextItem();
item.setPoints(1);
item.setTitle(qu);
// create correct answer
item.createResponse(an);
// create explanation
let exp = FormApp.createFeedback().setText(ex).build();
if(ex != '') {
item.setGeneralFeedback(exp);
}
})
回答1:
It's not possible to set correct answers for Text items using the Apps Script. It's only possible from the user interface.
It has been requested on Google's Issue Tracker. You can click on the star next to the issue number to receive updates and to give more priority to the request.
来源:https://stackoverflow.com/questions/61629776/how-to-set-correct-answer-text-in-google-forms-from-spreadsheet-using-script