Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save phillypb/2a7b1a98d9ab95952a97149a6ea5c438 to your computer and use it in GitHub Desktop.

Select an option

Save phillypb/2a7b1a98d9ab95952a97149a6ea5c438 to your computer and use it in GitHub Desktop.
function writeBack(form) {
// get the form values
var currentRow = form.currentRow;
var whoAmI = form.whoAmI;
Logger.log('whoAmI from Form is: ' + whoAmI);
var attendance1 = form.attendance1;
var contribution1 = form.contribution1;
var attitude1 = form.attitude1;
var comments1 = form.comments1;
Logger.log('Tutor 1 comments are: ' + comments1);
var attendance2 = form.attendance2;
var contribution2 = form.contribution2;
var attitude2 = form.attitude2;
Logger.log('Tutor 2 attitude is: ' + attitude2);
var comments2 = form.comments2;
// get spreadsheet
var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Group Feedback');
// check which Tutor so only relevant data written back to Sheet
if (whoAmI == 'You are 1') {
var rowValues1 = [[attendance1,contribution1,attitude1,comments1]];
ss.getRange(currentRow, 3, 1, 4).setValues(rowValues1);
}
else if (whoAmI == 'You are 2') {
var rowValues2 = [[attendance2,contribution2,attitude2,comments2]];
ss.getRange(currentRow, 7, 1, 4).setValues(rowValues2);
}
else {
Logger.log('You are not a Tutor');
var rowValues3 = [[attendance1,contribution1,attitude1,comments1,attendance2,contribution2,attitude2,comments2]];
ss.getRange(currentRow, 3, 1, 8).setValues(rowValues3);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment