-
Notifications
You must be signed in to change notification settings - Fork 0
/
clean.ts
47 lines (40 loc) · 1.37 KB
/
clean.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/**
* For all projects, unlinks the peer assessment forms and
* deletes the sheet gathering responses.
* Also clears all links/ids of PA forms.
*/
function deletePASheets() {
let projects = getProjects();
let pas = getPAs();
for (let i = 0; i < pas.length; i++) {
for (let p = 0; p < projects.length; p++) {
let pp = getPaProject(pas[i].id, projects[p].data.key);
if (pp == null || pp.data.formId == "") { continue; }
let form = FormApp.openById(pp.data.formId);
let sheet = getFormResponseSheet_(form.getId());
form.removeDestination();
SpreadsheetApp.getActive().deleteSheet(sheet);
DriveApp.getFileById(form.getId()).setTrashed(true);
}
}
deletePALinks();
}
function deleteRegVerSheets() {
deleteRegistrationSheet_();
deleteVerificationSheet_();
deleteLinks();
}
function deleteRegistrationSheet_() {
let form = FormApp.openById(getRegistrationFormId());
let sheet = getFormResponseSheet_(form.getId());
form.removeDestination();
SpreadsheetApp.getActive().deleteSheet(sheet);
DriveApp.getFileById(form.getId()).setTrashed(true);
}
function deleteVerificationSheet_() {
let form = FormApp.openById(getVerificationFormId());
let sheet = getFormResponseSheet_(form.getId());
form.removeDestination();
SpreadsheetApp.getActive().deleteSheet(sheet);
DriveApp.getFileById(form.getId()).setTrashed(true);
}