Step 2: Create Google Apps Script
- In your Google Sheet, click Extensions →
Apps Script
- Delete any existing code and paste this exactly:
function doPost(e) {
try {
const data = JSON.parse(e.postData.contents);
const sheet = SpreadsheetApp.getActiveSheet();
sheet.appendRow([
data.studentName,
data.q1,
data.q2,
data.q3,
new Date().toISOString()
]);
return ContentService.createTextOutput(JSON.stringify({
success: true,
message: 'Response recorded successfully'
})).setMimeType(ContentService.MimeType.JSON);
} catch (error) {
return ContentService.createTextOutput(JSON.stringify({
success: false,
error: error.toString()
})).setMimeType(ContentService.MimeType.JSON);
}
}
- Click Deploy → New Deployment
- Type: Select Web app
- Execute as: Your Google account
- Who has access: Anyone
- Click Deploy