-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfaculty_submission_response.R
238 lines (208 loc) · 11.2 KB
/
faculty_submission_response.R
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# Generates form emails to reply to faculty based on what was decided for
# submissions.
# Requires the faculty submission sheet to be downloaded into a csv
# that sheet should be modified to include the columns
# Decision - 0 or 1 if selected for matching fund
# Email greeting - first or nickname
# Program - Destination for submission, one of DSI, DFG, CC, Stats,
# or None. 'None' projects are useful for not-emailing
# someone.
### VARIABLES TO UPDATE #####
# Everything from here to VARIABLES END will likely need to be changed.
# Credentials file created from gmail; set to where the file can be found.
# It is unique to every user and needs to be create before creating drafts.
# Info on creating it can be found at https://github.com/r-lib/gmailr#setup
credentials_file <- "gmail_credentials.json"
# Configure as desired.
email_from <- "Ipek Ensari <[email protected]>"
email_from_display <- "Ipek Ensari"
email_replyto <- "[email protected]"
email_cc <- "[email protected]"
# When sending a project to Campus Connections, manually forward their
# submission first. This will currently cc Violet in this email, in addition
# to that forward.
campus_connections_cc <- "[email protected]"
# Projects file is downloaded csv from faculty submission form referenced above.
data_dir <- "~/Documents/GitHub/"
data_file <- "scholars_faculty_responses.csv"
project_term <- "Spring/Summer"
project_year <- "2023"
student_application_url <-
"https://forms.gle/bAeynKTWiYQgUwe18"
library(glue, quietly = FALSE)
email_signature <- glue("
<p>All the best,<br/>Ipek</p>
<p style='margin-bottom:1cm;'></p>
<p>
--<br/>
Ipek Ensari, PhD<br/>
Columbia University Data Science Institute<br/>
Northwest Corner #1401,<br/>
550 W 120th St
New York, NY 10027<br/>
ipekensari.com</p>")
# These are auto-generated when the project pages are created and are relative
# to the date which they are posted under. It should only need updating if
# the files are generated in one month, but the emails are sent in another.
url_prefix <- format(Sys.Date(), "%Y/%m")
#url_prefix <- "2023/02" # If necessary to set manually, uncomment this.
# If TRUE, prints emails to console instead of creating them as drafts.
test_only <- FALSE
### VARIABLES END ###
if (!require(gmailr, quietly = TRUE)) {
remotes::install_github("r-lib/gmailr")
library(gmailr, quietly = TRUE)
}
library(dplyr, quietly = FALSE)
library(magrittr, quietly = FALSE)
library(gmailr)
projects <- read.csv(file.path(data_dir, data_file))
projects$Email.Greeting <- projects$email_greeting
projects %<>%
mutate(funding = Are.you.applying.for.DSI.need.based..matching.stipend.funding..up.to..2500...) %>%
mutate(funding = case_when(grepl("unpaid", funding) ~ "unpaid",
grepl("own funding", funding) ~ "self",
TRUE ~ "matching"),
student_selected = Do.you.have.a.student.selected.for.this.position.already. == "Yes")
subject_prefix <- glue("[DSI-Scholars {project_term} {project_year}]")
gm_auth_configure(path = credentials_file)
for (i in seq_len(nrow(projects))) {
with(projects[i,], {
if (Program %in% "None") return(invisible(NULL))
cc <- email_cc
body <- glue("
<p>Dear {Email.Greeting},</p>
<p>Thank you for submitting your project '{Project.title}' to the DSI \\
Scholars program for {project_term} {project_year}. ")
include_application_link <- FALSE
# Projects that applied for a matching fund and were not selected.
if (Decision == 0 && !(Program %in% "DFG") && !(funding %in% "unpaid")) {
subject <- glue(subject_prefix, "Project Submission")
body %<>% glue("
Unfortunately, we received more proposals than we have available \\
funds and are unable to offer yours financial support. ")
if (Program == "CC") {
body %<>% glue("
We think your project would be best able to find support through \\
the Data Science Institute's Campus Connections program. We have \\
forwarded your proposal to our colleagues who should be in touch \\
shortly, and will help you recruit talent.</p>")
cc %<>% glue(", {campus_connections_cc}")
} else if (Program == "Stats") {
body %<>% glue("
We think your project would be best able to find support through \\
the Statistics Department consulting program. We have forwarded \\
your proposal to our colleagues who should be in touch shortly, and \\
will help provide you with expertise.</p>")
} else {
if (student_selected) {
body %<>% glue("
However, we are still able to offer educational support, so if \\
you would like to continue with your selected student researcher \\
and have them be able to participate in the intellectual \\
activities organized by the DSI Scholars program (boot camp, \\
meetups, and fall poster session), please reply to this \\
email with their contact information. If you wish to recruit \\
additional students, we will be happy to include your project in \\
our call for student applications.</p>")
} else {
body %<>% glue("
If you are interested in making your project available as an \\
unpaid research internship, please respond to this email and we \\
will include it in our call for student applications.</p>")
}
}
body %<>% glue("
<p>We are deeply grateful to you for taking the time to apply and \\
this program wouldn't exist without faculty mentors such as yourself.\\
</p>")
} else {
# All other projects
title <- trimws(Project.title)
if (endsWith(title, "."))
title <- trimws(substr(title, 1, nchar(title) - 1))
title_lowercase <- gsub("--", "-", gsub("[:,'?()]", "", gsub("[ /]", "-", tolower(title))))
url <- glue("https://cu-dsi-scholars.github.io/DSI-scholars/{url_prefix}/project-{title_lowercase}")
if (Program %in% "DSI") {
subject <- glue(subject_prefix, " Project Confirmation")
if (funding %in% "matching")
subject <- glue(subject, " and Stipend Fund")
if (funding %in% "matching") {
body %<>% glue("
We are pleased to inform you that we are able to offer you a \\
matching fund of up to $2,500 that can be used towards a stipend \\
for research interns who will work on your project. This means that \\
DSI will contribute the same amount that you are contributing. For\\
example, if you contribute $2,000, DSI will match it with another $2,000\\
for a total of $4,000 dispersed to the student via their columbia student\\
account. To do this we use chartstring and process the funds internally.")
if (student_selected) {
body %<>% glue("
In order to provide a matching fund for your selected scholar, \\
you will be asked to complete the faculty form with the requested information\\
(name and UNI of the selected scholar, name and email of your departmental
administrator, and the chart string from which you will contribute.\\
Further instructions on arranging payment will follow in the coming weeks.\\
If you wish to recruit additional students, we will be happy to include your project \\
in our call for student applications.</p>")
} else {
body %<>% glue("
We have created a <a href='{url}'>page</a> for your project \\
based on the information provided in your submission that will \\
be shared with prospective students. The tags and clipart will \\
be modified to suit your project accordingly. Please double \\
check carefully all the information on the page and notify us \\
if you'd like to make any changes.</p>")
include_application_link <- TRUE
}
} else {
if (student_selected)
stop("unexpected condition: student selected for internship not ",
"requesting matching fund")
body %<>% glue("
We have created a <a href='{url}'>page</a> for your project based \\
on the information provided in your submission that will be \\
shared with prospective students. The tags and clipart will be \\
modified to suit your project accordingly. Please double check \\
carefully all the information on the page and notify us if you'd \\
like to make any changes.</p>")
include_application_link <- TRUE
}
} else if (Program %in% "DFG") {
subject <- glue(subject_prefix, "Project Submission")
body %<>% glue(body, "
We found your project to be very exciting and would like to know if \\
you would be interested in participating in our Data For Good \\
program. Rather than having a single student in a research \\
internship, Data For Good projects recruit teams of volunteers who \\
work together. Although there is some turnover, these volunteers \\
tend to be highly motivated and experienced. To support project \\
coordination, the DSI provides a small stipend to one student. If \\
this sounds appealing, please let me know. If you prefer to have \\
your project continue as a research internship in the DSI Scholars \\
program, we are happy to do that as well.</p>")
}
}
if (include_application_link)
body %<>% glue("\n
<p>We have prepared an umbrella student application \\
<a href='{student_application_url}'>website</a> for all DSI Scholars \\
projects that are open for application. Your project is listed on the \\
application form. Applications to your project will be collected and \\
passed on to you in a folder for review by March 16th. You will be able to\\
review applicants based on what you deem is appropriate (e.g., one-on-one interview,\\
request for portfolio of previous work, brief evaluation of student coding skill). </p>")
body %<>% glue("\n", email_signature)
if (test_only) {
print(body)
return(invisible(NULL))
}
email <- gm_mime(to = Email.Address,
from = email_from,
replyto = email_replyto,
cc = email_cc,
subject = subject) %>%
gm_html_body(paste0(body, collapse = "\n"), content_type = "text/html", charset = "utf-8")
gm_create_draft(email)
})
}