function createDynamicQuiz() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; var data = sheet.getDataRange().getValues(); var form = FormApp.create('NotebookLM Dynamic Quiz'); form.setIsQuiz(true); for (var i = 0; i < data.length; i++) { var row = data[i]; var question = row[0]; var correctAnswer = row[row.length - 1]; // Assumes the last column is the answer var item = form.addMultipleChoiceItem(); item.setTitle(question); var choices = []; // This loop looks at columns B through the second-to-last column for (var j = 1; j < row.length - 1; j++) { if (row[j] !== "" && row[j] !== null) { // Only add if the cell isn't empty var isCorrect = (row[j] == correctAnswer); choices.push(item.createChoice(row[j], isCorrect)); } } item.setChoices(choices).setPoints(1); } Browser.msgBox('Quiz Created Successfully!'); }