...
 
Commits (8)
# -*- coding: utf-8 -*-
"""
Author: Germán Santa Maria
Script: Process Grades
Description:
This script will read all pdf files in the folder where is contained and
will produce a CSV file with the values extracted from the all fillable
text boxes in each of the pdfs.
Conditions:
All the pdfs should come from the same form template (same number of
fillable text boxes).
"""
"""-------------------------Hard coded input--------------------------------"""
# Output file name
csv_file_name = 'grades.csv' # Output csv file name (to store grades)
"""-------------------------------------------------------------------------"""
# Import modules
import os
import PyPDF2 # For working with PDFs
import csv # For reading cvs files
# List of all the files in the directory
list_of_files = os.listdir()
# Filter only ".pdf" files
list_of_pdf_files = []
for i in range(len(list_of_files)) :
if list_of_files[i].endswith(".pdf"):
list_of_pdf_files.append(list_of_files[i])
#---------------Create the headers for the output csv file--------------------#
# Select first pdf in the list as calibration pdf
calibration_pdf = list_of_pdf_files[0]
# Read PDF file
object = open(calibration_pdf, 'rb') # rb means read binary
reader = PyPDF2.PdfFileReader(object)
# Get values from text boxes in the PDF
text_boxes_data = reader.getFormTextFields()
# Create headers for the csv file
headers = []
headers.append('pdf_name')
text_boxes_names = list(text_boxes_data.keys())
for i in range(len(text_boxes_names)):
headers.append(str(text_boxes_names[i]))
#------------------Extract grades from all the pdf files----------------------#
line_data = [] # Array with the data to be printed in each line of the CSV file
errors = [] # List of pdfs that could not be processed
for pdf_file in list_of_pdf_files:
try:
# Read PDF file
object = open(pdf_file, 'rb') # rb means read binary
reader = PyPDF2.PdfFileReader(object)
# Get values from text boxes in the PDF
text_boxes_data = reader.getFormTextFields()
# Get grades for the student
student_grades = []
for i in range(len(text_boxes_names)):
grade = text_boxes_data.get(text_boxes_names[i], "")
student_grades.append(str(grade))
# Add pdf file-name and the student's grades to the "line_data" array
line = []
line.append(pdf_file)
for j in range (len(student_grades)):
line.append(student_grades[j])
line_data.append(line)
except:
# Add pdf file-name and the student's grades to the "line_data" array
print("pdf file " + pdf_file + "could not be processed.")
errors.append(pdf_file)
#------------------------Store grades in csv file-----------------------------#
with open (csv_file_name,'w',newline='') as f:
writer = csv.writer(f)
writer.writerow(headers)
for i in range(0,len(line_data)):
writer.writerow(line_data[i])
if len(errors) > 0:
with open ("errors.csv",'w',newline='') as f:
writer = csv.writer(f)
for i in range(0,len(errors)):
writer.writerow([errors[i]])
# End script
#!/bin/bash
# Input parameters
inputfolder='script_input-real'
outputfolder='script_output-real'
timestamp=$(date "+%Y-%m-%d+%H%M%S")
outputbackupname="backup_output_$timestamp.tar"
inputbackupname="backup_input_$timestamp.tar"
# Create archive of output folder
mkdir -vp archives
tar -cvf $outputbackupname --exclude=old $outputfolder
mv -vf $outputbackupname archives/
tar -cvf $inputbackupname --exclude=old $inputfolder
mv -vf $inputbackupname archives/
# Import output of M9 and M6 into input of M10
rsync -avh --delete ../M9_collect_graded/pdfs/ $inputfolder/pdfs/
rsync -avh --delete ../M6_match_peers/script_output/peers.csv $inputfolder/
# Clear output folder
rm -rvf $outputfolder/*
echo "end of script."
#!/bin/bash
# Input parameters
inputfolder='script_input'
outputfolder='script_output'
# Prepare output folder
mkdir -pv $outputfolder/done
# Copy input into the output folder, change directory to output folder
cp -vrf $inputfolder/* $outputfolder/
cd $outputfolder
mkdir "done"
# Pick up all the files in input subfolder one by one
for submissionpdf in submissions/*.pdf; do
# Extract IDA code from submission pdf file name
IDA=$(echo "$submissionpdf" | sed -r 's/submissions\///' | sed -r 's/\.pdf//')
echo "#"
echo "#"
echo "building assignment PDF for $IDA …"
mv -v solutions/graded_solution1_$IDA.pdf ./solution.pdf
mv -v submissions/$IDA.pdf ./submission.pdf
# Concatenate all three PDFs that we have together now
# Note that pdftk is not available by default on Ubuntu 18.04,
# see https://askubuntu.com/a/1046476 for workaround install
pdftk A=solution.pdf B=submission.pdf cat A B output done/Solution_submisison_1_$IDA.pdf
done
echo "#"
echo "#"
echo "#"
echo "done building PDFs"
# Cleanup: remove temporary folders
rm -rvf form solutions submissions solution.pdf submission.pdf
cd ../
echo "end of script."
#!/bin/bash
# Input parameters
inputfolder='script_input-real'
outputfolder='script_output-real'
timestamp=$(date "+%Y-%m-%d+%H%M%S")
outputbackupname="backup_output_$timestamp.tar"
inputbackupname="backup_input_$timestamp.tar"
# Create archive of output folder
mkdir -vp archives
tar -cvf $outputbackupname --exclude=old $outputfolder
mv -vf $outputbackupname archives/
tar -cvf $inputbackupname --exclude=old $inputfolder
mv -vf $inputbackupname archives/
# Import output of M3 and M5 into input of M11
rsync -avh --delete ../M5_collect_submissions/renamed\ pdfs/ $inputfolder/submissions/
rsync -avh --delete ../M3_generate_assignments/script_output/graded* $inputfolder/solutions/
# Clear output folder
rm -rvf $outputfolder/*
echo "end of script."
This diff is collapsed.
#!/bin/bash
# Input parameters
inputfolder='script_input-real'
outputfolder='script_output-real'
timestamp=$(date "+%Y-%m-%d+%H%M%S")
outputbackupname="backup_output_$timestamp.tar"
inputbackupname="backup_input_$timestamp.tar"
# Create archive of output folder
mkdir -vp archives
tar -cvf $outputbackupname --exclude=old $outputfolder
mv -vf $outputbackupname archives/
tar -cvf $inputbackupname --exclude=old $inputfolder
mv -vf $inputbackupname archives/
# Import output of M11 into input of M12
rsync -avh --delete ../M11_generate_graded/done/ $inputfolder/pdfs/
# Clear output folder
rm -rvf $outputfolder/*
echo "end of script."
#!/bin/bash
# Input parameters
inputfolder='script_input-real'
outputfolder='script_output-real'
timestamp=$(date "+%Y-%m-%d+%H%M%S")
outputbackupname="backup_output_$timestamp.tar"
inputbackupname="backup_input_$timestamp.tar"
# Create archive of output folder
mkdir -vp archives
tar -cvf $outputbackupname --exclude=old $outputfolder
mv -vf $outputbackupname archives/
tar -cvf $inputbackupname --exclude=old $inputfolder
mv -vf $inputbackupname archives/
# Clear output folder
rm -rvf $outputfolder/*
# Import any PNG from input into output
rsync -avh --delete $inputfolder/*.png $outputfolder/
echo "end of script."
......@@ -4,11 +4,6 @@
inputfolder='script_input'
outputfolder='script_output'
# Cleanup output folder
mkdir -v $outputfolder/old
rm -rvf $outputfolder/old/*
mv -vf $outputfolder/* $outputfolder/old/
# Copy every tex file in the input folder into the output folder
cp -vf $inputfolder/*.tex $outputfolder/
cp -vf $inputfolder/*.png $outputfolder/
......@@ -34,9 +29,32 @@ for assignmentfile in assignment*.tex; do
mv -vf *.aux *.bbl *.bcf *.blg *.ilg *.log *.nav *.nlo *.nls *.run.xml *.snm *.toc *.out *.fls *.fdb_latexmk *.spl *-blx.bib *-eps-converted-to.pdf *bib.bak tmp/
done
for solutionfile in graded_solution*.tex; do
echo "#"
echo "#"
echo "building solution PDF for $solutionfile …"
# Empty up the tmp subfolder, if it exists
rm -rvf tmp/*
# Make a tmp folder
mkdir -pv tmp
# Compile the actual PDF file:
pdflatex $solutionfile
pdflatex $solutionfile
# Cleanup after pdflatex: move temporary files to tmp subfolder
mv -vf *.aux *.bbl *.bcf *.blg *.ilg *.log *.nav *.nlo *.nls *.run.xml *.snm *.toc *.out *.fls *.fdb_latexmk *.spl *-blx.bib *-eps-converted-to.pdf *bib.bak tmp/
done
cd ../
# Remove tex files from output folder
# Remove tex and tmp files/folders from output folder
rm -vf $outputfolder/*.tex
rm -vf $outputfolder/*.png
rm -vrf $outputfolder/tmp
echo "end of script."
#!/bin/bash
# Input parameters
inputfolder='script_input-real'
outputfolder='script_output-real'
timestamp=$(date "+%Y-%m-%d+%H%M%S")
outputbackupname="backup_output_$timestamp.tar"
inputbackupname="backup_input_$timestamp.tar"
# Create archive of output folder
mkdir -vp archives
tar -cvf $outputbackupname --exclude=old $outputfolder
mv -vf $outputbackupname archives/
tar -cvf $inputbackupname --exclude=old $inputfolder
mv -vf $inputbackupname archives/
# Import output of M2 into input of M3
rsync -avh --delete ../M2_customize_assignments/script_output/ $inputfolder/
# Clear output folder
rm -rvf $outputfolder/*
echo "end of script."
#!/bin/bash
# Input parameters
inputfolder='script_input-real'
outputfolder='script_output-real'
timestamp=$(date "+%Y-%m-%d+%H%M%S")
outputbackupname="backup_output_$timestamp.tar"
inputbackupname="backup_input_$timestamp.tar"
# Create archive of output folder
mkdir -vp archives
tar -cvf $outputbackupname --exclude=old $outputfolder
mv -vf $outputbackupname archives/
tar -cvf $inputbackupname --exclude=old $inputfolder
mv -vf $inputbackupname archives/
# Import output of M3 into input of M4
rsync -avh --delete ../M3_generate_assignments/script_output/ $inputfolder/
rsync -avh ../M2_customize_assignments/script_output/output_assignments.csv $inputfolder/
# Clear output folder
rm -rvf $outputfolder/*
echo "end of script."
......@@ -7,10 +7,10 @@ Script: Match Peers
"""-------------------------Hard coded input--------------------------------"""
# Input files paths
students_info_path = 'script_input/output_assignments.csv'
submission_pdfs_name = 'submission_a1_' # Name of the submitted PDFs
submission_pdfs_path = 'script_input/' + submission_pdfs_name #pdf path
submission_pdfs_path = 'script_input/pdf/' # input pdf path
# Output files paths
peers_csv_path = 'script_output/peers.csv'
rename_assignment_to = "" #Rename assignments ID_A.pdf to ...
"""-------------------------------------------------------------------------"""
# Import modules
......@@ -26,8 +26,8 @@ emails = [] # Student email address
custom_ID_A = [] # ID that the student uses to submit the solution
custom_ID_G = [] # ID that the student uses to grade the peers
did_their_homework = [] # List of students that actually submitted a solution
email_peer1 = [] # List of peers (first peer)
email_peer2 = [] # List of peers (second peer)
ID_G_peer1 = [] # List of peers (ID_G of first peer)
ID_G_peer2 = [] # List of peers (ID_G of second peer)
random_peers1 = [] # Temporary list of possible peers to assign
random_peers2 = [] # Temporary list of possible peers to assign
......@@ -43,7 +43,7 @@ with open(students_info_path, newline='') as f:
custom_ID_A.append(row[3])
custom_ID_G.append(row[4])
# Check which students actually submitted their solution to their assignment by looking
# Check which students actually submitted their solution to their assignment by looking
# for a file in the "script_input" folder with the name "ID.pdf"
for i in range(0, len(custom_ID_A)):
file_to_search = pathlib.Path(submission_pdfs_path+custom_ID_A[i]+'.pdf')
......@@ -52,16 +52,16 @@ for i in range(0, len(custom_ID_A)):
########## Assign two peers to each student who submitted a solution ##########
###############################################################################
# Allocate size of arrays "ID_peer1" and "ID_peer2"
email_peer1 = ['']*len(emails)
email_peer2 = ['']*len(emails)
# Allocate size of arrays "ID_G_peer1" and "ID_G_peer2"
ID_G_peer1 = ['']*len(custom_ID_G)
ID_G_peer2 = ['']*len(custom_ID_G)
# Create two temporal arrays with the peers to be assigned
for i in range(0,len(emails)):
for i in range(0,len(custom_ID_G)):
# Only students who submitted solution can recieve a peer role
if did_their_homework[i]==True:
random_peers1.append(emails[i])
random_peers2.append(emails[i])
random_peers1.append(custom_ID_G[i])
random_peers2.append(custom_ID_G[i])
copy_randp1 = random_peers1 # Save a copy of the array "random_peers1"
copy_randp2 = random_peers2 # Save a copy of the array "random_peers2"
......@@ -75,16 +75,16 @@ while counter<len(names) and iterations<10000:
# Make sure that peers are assigned only to students who submitted solution
if did_their_homework[counter]==False:
email_peer1[counter] = 'None'
email_peer2[counter] = 'None'
ID_G_peer1[counter] = 'None'
ID_G_peer2[counter] = 'None'
counter = counter + 1 # Update counter
iterations = iterations + 1 # Update iterations counter
continue # This jumps to the begining of the while loop
# Make sure that the last student in the list does not end up wihout a peer,
# in the case that the last peer to be assigned is themselves.
if len(random_peers1) == 1 and (emails[counter] == random_peers1[0] or
emails[counter] == random_peers2[0] or
if len(random_peers1) == 1 and (custom_ID_G[counter] == random_peers1[0] or
custom_ID_G[counter] == random_peers2[0] or
random_peers1[0] == random_peers2[0]):
random_peers1 = copy_randp1 # Resets "random_peers1" array
random_peers2 = copy_randp2 # Resets "random_peers2" array
......@@ -93,16 +93,16 @@ while counter<len(names) and iterations<10000:
continue
# If student==peer or peer1==peer2 repeat iteration
if (emails[counter] == random_peers1[0] or
emails[counter] == random_peers2[0] or
if (custom_ID_G[counter] == random_peers1[0] or
custom_ID_G[counter] == random_peers2[0] or
random_peers1[0] == random_peers2[0]):
iterations = iterations + 1 # Update iterations counter
continue # "counter" is not updated, iteration will be repeated
# If no conflicts are found assign peer1 and peer2
email_peer1[counter] = random_peers1[0] # Assign first peer
ID_G_peer1[counter] = random_peers1[0] # Assign first peer
random_peers1.pop(0) # Remove peer from "random_peers1"
email_peer2[counter] = random_peers2[0] # Assign second peer
ID_G_peer2[counter] = random_peers2[0] # Assign second peer
random_peers2.pop(0) # Remove peer from "random_peers2"
counter = counter + 1 # Update counter
iterations = iterations + 1 # Update iterations counter
......@@ -114,16 +114,16 @@ while counter<len(names) and iterations<10000:
with open (peers_csv_path,'w',newline='') as f:
writer = csv.writer(f)
writer.writerow(['name','lastname','email','custom_ID_A','custom_ID_G',
'submitted','email_peer1','email_peer2'])
'submitted','peer1_ID_G','peer2_ID_G'])
for i in range(0,len(names)):
writer.writerow([names[i],last_name[i],emails[i],custom_ID_A[i],
custom_ID_G[i],str(did_their_homework[i]),email_peer1[i],
email_peer2[i]])
custom_ID_G[i],str(did_their_homework[i]),ID_G_peer1[i],
ID_G_peer2[i]])
# Copy and rename the submission PDF files (custom_ID_A -> custom_ID_G)
for i in range(0, len(custom_ID_A)):
if did_their_homework[i]==True:
copyfile(submission_pdfs_path + custom_ID_A[i] + ".pdf",
"script_output/" + submission_pdfs_name + custom_ID_G[i] + ".pdf")
"script_output/pdfs/" + rename_assignment_to + custom_ID_G[i] + ".pdf")
# End of script
#!/bin/bash
# Input parameters
inputfolder='script_input-real'
outputfolder='script_output-real'
timestamp=$(date "+%Y-%m-%d+%H%M%S")
outputbackupname="backup_output_$timestamp.tar"
inputbackupname="backup_input_$timestamp.tar"
# Create archive of output folder
mkdir -vp archives
tar -cvf $outputbackupname --exclude=old $outputfolder
mv -vf $outputbackupname archives/
tar -cvf $inputbackupname --exclude=old $inputfolder
mv -vf $inputbackupname archives/
# Clear output folder
rm -rvf $outputfolder/*
# Import output of M5 into input of M6
rsync -avh --delete ../M5_collect_submissions/renamed\ pdfs/ $inputfolder/pdf/
rsync -avh ../M2_customize_assignments/script_output/output_assignments.csv $inputfolder/
echo "end of script."
#!/bin/bash
# Input parameters
inputfolder='script_input'
outputfolder='script_output'
# Prepare output folder
mkdir -v $outputfolder/done
# Copy input into the output folder, change directory to output folder
cp -vrf $inputfolder/* $outputfolder/
cd $outputfolder
# Copy grading form to work folder (it’s the same file for all )
cp -v form/gradingform.pdf ./form.pdf
# Pick up all the files in input subfolder one by one
for submissionpdf in submissions/*.pdf; do
# Extract IDG code from submission pdf file name
IDG=$(echo "$submissionpdf" | sed -r 's/submissions\///' | sed -r 's/\.pdf//')
echo "#"
echo "#"
echo "building assignment PDF for $IDG …"
mv -v solutions/solution1_$IDG.pdf ./solution.pdf
mv -v submissions/$IDG.pdf ./submission.pdf
# Concatenate all three PDFs that we have together now
# Note that pdftk is not available by default on Ubuntu 18.04,
# see https://askubuntu.com/a/1046476 for workaround install
pdftk A=solution.pdf B=submission.pdf C=form.pdf cat A B C output done/$IDG.pdf
# When the file returns filled from each student, we may use
# the following command to get only the last page
#pdftk returnfile_filled.pdf cat r1 output onlythefilledform.pdf
done
echo "#"
echo "#"
echo "#"
echo "done building PDFs"
# Cleanup: remove temporary folders
rm -rvf form solutions submissions form.pdf solution.pdf submission.pdf
cd ../
echo "end of script."
#!/bin/bash
# Input parameters
inputfolder='script_input-real'
outputfolder='script_output-real'
timestamp=$(date "+%Y-%m-%d+%H%M%S")
outputbackupname="backup_output_$timestamp.tar"
inputbackupname="backup_input_$timestamp.tar"
# Create archive of output folder
mkdir -vp archives
tar -cvf $outputbackupname --exclude=old $outputfolder
mv -vf $outputbackupname archives/
tar -cvf $inputbackupname --exclude=old $inputfolder
mv -vf $inputbackupname archives/
# Import output of M3 and M5 into input of M7
rsync -avh --delete ../M5_collect_submissions/renamed\ pdfs/ $inputfolder/submissions/
rsync -avh --delete ../M3_generate_assignments/script_output/solution* $inputfolder/solutions/
# Clear output folder
rm -rvf $outputfolder/*
echo "end of script."
# -*- coding: utf-8 -*-
"""
Author: Germán Santa Maria
Script: Email Grading Forms
"""
"""-------------------------Hard coded input--------------------------------"""
# Input files paths
input_csv_path = 'script_input/peers.csv'
attachments_path = 'script_input/'
# Output files paths
output_csv_path = 'script_output/sent_emails.csv'
# (Hard-coded email settings)
host="myhost.example.com"
port = 587
sender_email = "sender@example.com"
sender_username = "username"
cc = "cc_address@example.com"
password = input("Type your password and press enter:")
# Delay time between sending two emails, in seconds
# For example, set 240 seconds if you are limited to less than 30 emails/hour
# and 40 seconds if the limit is less than 30 emails/10 min
delay_time = 45
"""-------------------------------------------------------------------------"""
# Import email sender function
import csv # For reading cvs files
import pathlib # For working with local paths
import smtplib, ssl # For email
import time # For timer
from email import encoders
from email.mime.base import MIMEBase
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
# Initialize arrays to store data
names = [] # Student first name
last_name = [] # Student last name
emails = [] # Student email address
custom_ID_A = [] # Custom ID of the assignment for the student
custom_ID_G = [] # Custom ID of the grading file for the student
ID_G_peer1 = [] # List of peers (ID_G of first peer)
ID_G_peer2 = [] # List of peers (ID_G of second peer)
student_status = [] # True = Student is active; False = Student is not active
attachments = [] # Name of the attachments for each student
email_bodies = [] # Body of the email for each student
text_emails = [] # Array with the complete email text for each student
email_log = [] # Array with the log of successfully sent emails
# Store students data from csv file into variables
with open(input_csv_path, newline='') as f:
student_info_reader = csv.reader(f)
next(student_info_reader) # Skip header [name, last name, email, ...]
student_data = [row for row in student_info_reader]
active_student_data = [] # To store data of the active students only
for row in student_data:
status = row[5] # Status of the student
if status == 'True' or status == 'TRUE':
active_student_data.append(row)
# Store active student's data in arrays
for row in active_student_data:
names.append(row[0])
last_name.append(row[1])
emails.append(row[2])
custom_ID_A.append(row[3])
custom_ID_G.append(row[4])
student_status.append(row[5])
ID_G_peer1.append(row[6])
ID_G_peer2.append(row[7])
# Generate list of attachments for each student
for i in range(len(emails)):
attachment_peer1 = ID_G_peer1[i] + ".pdf"
attachment_peer2 = ID_G_peer2[i] + ".pdf"
# Attachments list for each student
student_attachments = [attachment_peer1, attachment_peer2]
# Append students attachments to full list of attachments to be mailed
attachments.append(student_attachments)
# Make sure that all the attachments are in the script_input folder by looking
# for a file with the correct file name
print('Checking attachments...')
for row in attachments:
for file in row:
file_to_search = pathlib.Path(attachments_path+file)
if file_to_search.exists() != True:
raise Exception('The file ' + str(file) +
' was not found, no emails were sent')
print('All the attachments were found in the input folder')
print(' ')
"""-----------------Build email text for each student-----------------------"""
# Write a personalized email body for each student
standard_body = """Dear XXstudent_firstnameXX,
congratulations for submitting your first coursework assignment!
Here is now the following part, where you are going to grade two of your peers.
(insert email body here)
%%% How to submit %%%
Attached, you will find two anonymized submissions from peer students, bundled with grading information. At the end of each document, there is a form. Please fill in the form following the included grading guidelines.
Once you are done, save both files, keeping their file name unchanged, and send them back to this address.
(insert email body here)
With best regards,
(author)
""" # End of email body
# Replace markers in the email body for each student
for i in range(0, len(names)):
# Replace student name in the email body marker
temp_body = standard_body.replace("XXstudent_firstnameXX", names[i])
# Save email body to array
email_bodies.append(temp_body)
# Compose email text for each student
for i in range(0, len(names)):
# Reciever email
receiver_email = emails[i]
# Email subject
subject = email_subject
# Email body
body = email_bodies[i]
# Attachments
filenames = attachments[i]
# Set headers
message = MIMEMultipart()
message["From"] = sender_email
message["To"] = receiver_email
message["Subject"] = subject
message["Cc"] = cc
# Add body to email
message.attach(MIMEText(body, "plain"))
# Add attachments
for filename in filenames:
attachment_path = attachments_path + filename # Attachment folder path
# Open PDF file in binary mode
with open(attachment_path, "rb") as attachment:
# Add file as application/octet-stream
part = MIMEBase("application", "octet-stream")
part.set_payload(attachment.read())
# Encode file in ASCII characters to send by email
encoders.encode_base64(part)
# Add header as key/value pair to attachment part
part.add_header("Content-Disposition",
f"attachment; filename= {filename}",)
# Add attachment to message and convert message to string
message.attach(part)
text = message.as_string()
text_emails.append(text)
"""-------------------------------------------------------------------------"""
# Send an email to each student with the corresponding attachment
"""------------------------------Send emails--------------------------------"""
# Create a secure SSL context
context = ssl.create_default_context()
# Check if the login data is correct
try :
server = smtplib.SMTP(host = host, port = port)
server.starttls(context = context) #Encryption
server.login(sender_username, password)
print('Login to: '+ sender_email + ' was successful ')
except Exception as e:
# Print error message
print('Login to: '+ sender_email +
' was not successful, no emails were sent ')
raise Exception(e)
server.close() # Logout
# Send email to each student
for i in range(0, len(names)):
try :
# Reciever email
receiver_email = emails[i]
# Email content
text = text_emails[i]
# Logging into email server
server = smtplib.SMTP(host = host, port = port)
server.starttls(context = context) #Encryption
server.login(sender_username, password)
# Send email
server.sendmail(sender_email, [receiver_email, cc], text)
# Logout
server.close() # Logout
# Print email log
local_time = time.time()
time_sent = time.ctime(local_time)
log_m = 'Email was sent to: ' + receiver_email + ' time: ' + time_sent
print(log_m)
except Exception as e:
# Print error
log_m = 'Error while trying to send email to: ' + receiver_email
print(log_m)
print(e)
log_m = 'Email could not be sent, error: ' + str(e)
# Save log
email_log.append(log_m)
# Wait before sending the next email
time.sleep(delay_time)
# Store email log in a csv file
with open (output_csv_path,'w',newline='') as f:
writer = csv.writer(f)
writer.writerow(['name','lastname','email','custom_ID_A','custom_ID_G',
'log'])
for i in range(0,len(names)):
writer.writerow([names[i],last_name[i],emails[i],custom_ID_A[i],
custom_ID_G[i], email_log[i]])
"""-------------------------------------------------------------------------"""
# End of the script
#!/bin/bash
# Input parameters
inputfolder='script_input-real'
outputfolder='script_output-real'
timestamp=$(date "+%Y-%m-%d+%H%M%S")
outputbackupname="backup_output_$timestamp.tar"
inputbackupname="backup_input_$timestamp.tar"
# Create archive of output folder
mkdir -vp archives
tar -cvf $outputbackupname --exclude=old $outputfolder
mv -vf $outputbackupname archives/
tar -cvf $inputbackupname --exclude=old $inputfolder
mv -vf $inputbackupname archives/
# Import output of M7 and M5 into input of M8
rsync -avh --delete ../M7_generate_grading/script_output/done/ $inputfolder/pdfs/
rsync -avh --delete ../M6_match_peers/script_output/peers.csv $inputfolder/
# Clear output folder
rm -rvf $outputfolder/*
echo "end of script."
......@@ -21,7 +21,7 @@ The code in this repository is published under the [GNU GPL v3](href="https://ww
## Structure
A total of nine modules (six of which being locally-run scripts) are needed to run the project.
A total of 12 modules (9 of which being locally-run scripts) are needed to run the project.
[ ] Module 1: Collect participant information
(through email)
......@@ -41,11 +41,20 @@ A total of nine modules (six of which being locally-run scripts) are needed to r
[x] [Module 6](M6_match_peers): Match peers
(in Python)
[ ] Module 7: Send peer grading assignments
[x] [Module 7](M7_generate_grading): Generate grading assignments
(in bash, with pdftk)
[x] [Module 8](M8_send_grading): Send peer grading assignments
(in Python)
[ ] Module 8: Process grades
[ ] Module 9: Collect peer-assigned grades
(through email)
[x] [Module 10](M10_process_grades): Process grades
(in Python)
[ ] Module 9: Send results to students
[x] [Module 11](M11_generate_graded): Generate graded PDFs
(in bash, with pdftk)
[x] [Module 12](M12_email_graded): Send results to students
(in Python)