...
 
Commits (9)
......@@ -16,7 +16,7 @@ Conditions:
"""-------------------------Hard coded input--------------------------------"""
# Output file name
csv_file_name = 'grades.csv' # Output csv file name (to store grades)
csv_file_name = 'script_output/grades.csv' # Output csv file name (to store grades)
"""-------------------------------------------------------------------------"""
# Import modules
......@@ -25,7 +25,7 @@ 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()
list_of_files = os.listdir(path='.')
# Filter only ".pdf" files
list_of_pdf_files = []
......@@ -42,7 +42,8 @@ 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()
#text_boxes_data = reader.getFormTextFields() # Deprecated, now getFields() works
text_boxes_data = reader.getFields()
# Create headers for the csv file
headers = []
......@@ -61,12 +62,13 @@ for pdf_file in list_of_pdf_files:
reader = PyPDF2.PdfFileReader(object)
# Get values from text boxes in the PDF
text_boxes_data = reader.getFormTextFields()
#text_boxes_data = reader.getFormTextFields() # Deprecated, now getFields() works
text_boxes_data = reader.getFields()
# Get grades for the student
student_grades = []
for i in range(len(text_boxes_names)):
grade = text_boxes_data.get(text_boxes_names[i], "")
grade = text_boxes_data.get(text_boxes_names[i], "").get("/V")
student_grades.append(str(grade))
# Add pdf file-name and the student's grades to the "line_data" array
......
......@@ -23,13 +23,13 @@ for submissionpdf in submissions/*.pdf; do
echo "#"
echo "building assignment PDF for $IDA …"
mv -v solutions/graded_solution1_$IDA.pdf ./solution.pdf
mv -v solutions/solution*_$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
pdftk A=solution.pdf B=submission.pdf cat A B output done/Solution_submission_$IDA.pdf
done
......
......@@ -18,7 +18,7 @@ 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/
rsync -avh --delete ../M3_generate_assignments/script_output/solution* $inputfolder/solutions/
# Clear output folder
rm -rvf $outputfolder/*
......
This diff is collapsed.
......@@ -17,7 +17,7 @@ mv -vf $inputbackupname archives/
# Import output of M11 into input of M12
rsync -avh --delete ../M11_generate_graded/done/ $inputfolder/pdfs/
rsync -avh --delete ../M11_generate_graded/script_output/done/ $inputfolder/pdfs/
# Clear output folder
......
......@@ -30,7 +30,7 @@ for assignmentfile in assignment*.tex; do
done
for solutionfile in graded_solution*.tex; do
for solutionfile in solution*.tex; do
echo "#"
echo "#"
......
......@@ -7,10 +7,9 @@ Script: Match Peers
"""-------------------------Hard coded input--------------------------------"""
# Input files paths
students_info_path = 'script_input/output_assignments.csv'
submission_pdfs_path = 'script_input/pdf/' # input pdf path
submission_pdfs_path = 'script_input/pdfs/' # path to folder containing input PDFs
# Output files paths
peers_csv_path = 'script_output/peers.csv'
rename_assignment_to = "" #Rename assignments ID_A.pdf to ...
"""-------------------------------------------------------------------------"""
# Import modules
......@@ -60,8 +59,8 @@ ID_G_peer2 = ['']*len(custom_ID_G)
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(custom_ID_G[i])
random_peers2.append(custom_ID_G[i])
random_peers1.append(custom_ID_G[i] + 'A')
random_peers2.append(custom_ID_G[i] + 'B')
copy_randp1 = random_peers1 # Save a copy of the array "random_peers1"
copy_randp2 = random_peers2 # Save a copy of the array "random_peers2"
......@@ -81,11 +80,11 @@ while counter<len(names) and iterations<10000:
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 (custom_ID_G[counter] == random_peers1[0] or
custom_ID_G[counter] == random_peers2[0] or
random_peers1[0] == random_peers2[0]):
# Make sure that the last student in the list does not end up without a
# peer, in the case that the last peer to be assigned is themselves.
if len(random_peers1) == 1 and (custom_ID_G[counter] == random_peers1[0][0:-1] or
custom_ID_G[counter] == random_peers2[0][0:-1] or
random_peers1[0][0:-1] == random_peers2[0][0:-1]):
random_peers1 = copy_randp1 # Resets "random_peers1" array
random_peers2 = copy_randp2 # Resets "random_peers2" array
counter = 0 # This resets counter
......@@ -93,9 +92,9 @@ while counter<len(names) and iterations<10000:
continue
# If student==peer or peer1==peer2 repeat iteration
if (custom_ID_G[counter] == random_peers1[0] or
custom_ID_G[counter] == random_peers2[0] or
random_peers1[0] == random_peers2[0]):
if (custom_ID_G[counter] == random_peers1[0][0:-1] or
custom_ID_G[counter] == random_peers2[0][0:-1] or
random_peers1[0][0:-1] == random_peers2[0][0:-1]):
iterations = iterations + 1 # Update iterations counter
continue # "counter" is not updated, iteration will be repeated
......@@ -114,16 +113,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','peer1_ID_G','peer2_ID_G'])
'submitted','peer1_ID','peer2_ID'])
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]),ID_G_peer1[i],
ID_G_peer2[i]])
# Copy and rename the submission PDF files (custom_ID_A -> custom_ID_G)
# Copy and rename the submission PDF files
# (custom_ID_A -> customID_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/pdfs/" + rename_assignment_to + custom_ID_G[i] + ".pdf")
"script_output/pdfs/" + custom_ID_G[i] + ".pdf")
# End of script
......@@ -19,9 +19,12 @@ mv -vf $inputbackupname archives/
# Clear output folder
rm -rvf $outputfolder/*
# Create subdir "pdfs" in output folder
mkdir -pv $outputfolder/pdfs
# Import output of M5 into input of M6
rsync -avh --delete ../M5_collect_submissions/renamed\ pdfs/ $inputfolder/pdf/
rsync -avh --delete ../M5_collect_submissions/renamed\ pdfs/ $inputfolder/pdfs/
rsync -avh ../M2_customize_assignments/script_output/output_assignments.csv $inputfolder/
......
......@@ -14,28 +14,33 @@ 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
# Pick up all the "A" 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//')
# Construct IDGA and IDGB codes out of IDG code
APPENDA='A'
APPENDB='B'
IDGA=$IDG$APPENDA
IDGB=$IDG$APPENDB
echo "#"
echo "#"
echo "building assignment PDF for $IDG …"
mv -v solutions/solution1_$IDG.pdf ./solution.pdf
mv -v solutions/solution*_$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
pdftk A=solution.pdf B=submission.pdf C=form.pdf cat A B C output done/$IDGA.pdf
# Create clone of PDF file with B code
cp -v done/$IDGA.pdf done/$IDGB.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
......
......@@ -16,10 +16,14 @@ 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/
# Import output of M3 into input of M7
# Folder must be cleared manually, because wildcard matching for rsync prevents deletion of surrogates
rm -rvf $inputfolder/solutions/*
rsync -avh --delete ../M3_generate_assignments/script_output/solution* $inputfolder/solutions/
# Import output of M5 into input of M7
rsync -avh --delete ../M6_match_peers/script_output/pdfs/ $inputfolder/submissions/
# Clear output folder
rm -rvf $outputfolder/*
......