Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Olivier
Peer-graded student exercises
Commits
86f49bc1
Commit
86f49bc1
authored
May 04, 2019
by
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
Changes
1
Hide whitespace changes
Inline
Side-by-side
M6_match_peers/match_peers.py
View file @
86f49bc1
...
...
@@ -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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment