Last active
February 16, 2019 12:49
-
-
Save consnam/0d43e956c65165dc326d7c9c129f8e88 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function form_update() { | |
//구글 시트에서 설문지 입력 항목 데이터 가져오기 | |
var sh = SpreadsheetApp.openById('구글 시트 ID').getSheetByName('통계'); | |
var range = sh.getRange(8, 3, 6, 3) | |
var data = range.getValues(); | |
//Logger.log(data); | |
var seminars = []; | |
var temp = []; | |
//각 세미나 인원을 확인 후 인원이 초과되지 않은 세미나만 array로 생성 | |
for (j = 1; j < 3; j++){ | |
temp = []; | |
for (i = 0; i < data.length; i++){ | |
if(data[i][j] < 25){ //각 세미나 별 신청자 상한선 | |
temp.push(data[i][0]) | |
} | |
} | |
seminars.push(temp); | |
} | |
Logger.log(seminars); | |
//구글 설문지 항목 가져오기 | |
var form = FormApp.getActiveForm(); | |
var items = form.getItems(); | |
//인원이 초과되지 않은 세미나가 있는 경우 Description을 추가하고, 항목을 업데이트 | |
items[8].asMultipleChoiceItem().setChoiceValues(seminars[0]); | |
if(seminars[0].length < 6){ | |
items[8].asMultipleChoiceItem().setHelpText("마감된 과목을 제외하고, 현재 신청 가능한 선택과목들만 화면에 나타납니다"); | |
} | |
else{ | |
items[8].asMultipleChoiceItem().setHelpText(""); | |
} | |
items[9].asMultipleChoiceItem().setChoiceValues(seminars[1]); | |
if(seminars[1].length < 6){ | |
items[9].asMultipleChoiceItem().setHelpText("마감된 과목을 제외하고, 현재 신청 가능한 선택과목들만 화면에 나타납니다"); | |
} | |
else{ | |
items[9].asMultipleChoiceItem().setHelpText(""); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment