Commit 86f49bc1 authored by Olivier's avatar Olivier
Browse files

M6: identify peers with G code rather than A code

The code in this commit is contributed by Germán Santa Maria.
parent 0d626422
......@@ -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
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment