-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreate_spreadsheet.py
94 lines (72 loc) · 3.04 KB
/
create_spreadsheet.py
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
import csv
import json
from docx import Document
def get_submitted_apps():
'''
Get list of all JSON records corresponding to submitting applications
'''
APP_FILE_NAME = "think_apps_1_1.json"
# Read in applications JSON file
with open(APP_FILE_NAME) as json_file:
data = []
for line in json_file:
data.append(json.loads(line))
# Get list of all applications with non-empty file name submission
submitted_apps = []
for application in data:
if len(application["projectSubmission"]["fileName"]) > 0:
submitted_apps.append(application)
return submitted_apps
def create_judging_spreadsheet():
'''
Convert JSON file into CSV spreadsheet for judging
'''
submitted_apps = get_submitted_apps()
print("# of Applications: ", len(submitted_apps))
OUTPUT_FILE_NAME = "apps_cleaned_1_1.csv"
bad_submissions = 0
# Write username, project title, project areas, and Dropbox link to CSV file
with open(OUTPUT_FILE_NAME, 'w') as csvfile:
application_writer = csv.writer(csvfile, delimiter=',')
application_writer.writerow(["Username", "Title", "Project Areas", "Dropbox Link", "Submitted?", "Partner?"])
for app in submitted_apps:
username = app["username"]
project_title = app["projectSubmission"]["projectTitle"]
areas = app["projectQuestions"]["projectAreas"]
project_link = app["projectSubmission"]["fileLink"]
submitted = app["projectSubmission"]["submitted"]
partner = app["projectSubmission"]["partner"]
application_writer.writerow([username, project_title, areas, project_link, submitted, partner])
if len(project_link) == 0:
print("Bad Username: {}".format(username))
bad_submissions += 1
print("# of Bad Submissions: ", bad_submissions)
def create_response_doc():
'''
Create Word doc containing all student responses to 3 questions in application, along
with additional info
'''
submitted_apps = get_submitted_apps()
responses_doc = Document()
for app in submitted_apps:
write_user_responses(responses_doc, app)
responses_doc.add_page_break()
responses_doc.save("student_responses.docx")
def write_user_responses(document, application):
'''
Adds responses from a particular applicant into the provided Word document
'''
username = application["username"]
project_title = application["projectSubmission"]["projectTitle"]
document.add_heading(username + ": " + project_title, level=3)
document.add_heading("What kind of technical skills will be needed to complete your project?", level=4)
document.add_paragraph(application["projectQuestions"]["skills"])
document.add_heading("What do you anticipate being the biggest obstacles in your project?", level=4)
document.add_paragraph(application["projectQuestions"]["obstacles"])
document.add_heading("Where do you believe that THINK mentorship can benefit your project?", level=4)
document.add_paragraph(application["projectQuestions"]["mentorship"])
document.add_heading("Additional Info", level=4)
document.add_paragraph(application["projectSubmission"]["additional"])
if __name__ == '__main__':
# create_judging_spreadsheet()
create_response_doc()