Commit 2caa7aed authored by Olivier's avatar Olivier
Browse files

M2: generate three tex files instead of two

For each participant, we now want to produce three tex files:
1) one for their assignment
2) one (containing the solution) for the grading assignment sent
   to their two peers
3) one (also containing the solution) for the graded solution they
   receive after having been graded.
parent 69104f7a
......@@ -24,17 +24,16 @@ rand_matrix = [] # These are the random numbers to customize the assignments
custom_values = [] # Matrix with all custom values for each student assingment
"""-------------------------Hard coded input--------------------------------"""
# Input files paths
assignment_path = 'script_input/hot_air_exhaust_assignment.tex'
assig_solution_path = 'script_input/hot_air_exhaust_solution.tex'
# Input file paths
assignment_path = 'script_input/assignment'+assignment_number+'.tex'
assig_solution_grading_path = 'script_input/solution_grading'+assignment_number+'.tex'
assig_solution_graded_path = 'script_input/solution_graded'+assignment_number+'.tex'
canoniccl_path = 'script_input/canonical.csv'
# Output files paths
output_csv_path = 'script_output/output_assignments.csv'
output_assignment_path = 'script_output/assignment1_'
output_solution_path = 'script_output/solution1_'
# Markers for values
markers = ['XXspeed_in1XX', 'XXspeed_in2XX'
]
output_assignment_preamble = 'script_output/assignment3_'
output_solution_grading_preamble = 'script_output/solution_grading'+assignment_number+'_'
output_solution_graded_preamble = 'script_output/solution_graded'+assignment_number+'_'
# Markers for student custom ID
marker_customID_A = 'XXcustomID_AXX'
......@@ -47,11 +46,11 @@ marker_fullname = 'XXstudentfullnameXX'
# Open and read the template assignment tex file
with open(assignment_path,'r', encoding="utf-8") as f:
assignment = f.read()
# Open and read the template solution tex file
with open(assig_solution_path,'r', encoding="utf-8") as f:
with open(assig_solution_grading_path,'r', encoding="utf-8") as f:
assig_solution = f.read()
# Store students data from csv file into variables
with open(canoniccl_path, newline='', encoding="utf-8") as f:
canoniccl_reader = csv.reader(f)
......@@ -92,11 +91,11 @@ for i in range (0,len(first_names)):
# Store the custom assignment data for all the students in a csv file
with open (output_csv_path,'w',newline='', encoding="utf-8") as f:
writer = csv.writer(f)
writer.writerow(['first name','last name','email','custom_ID_A','custom_ID_G'] +
markers)
writer.writerow(['first name','last name','email','custom_ID_A',
'custom_ID_G'] + markers)
for i in range(0,len(first_names)):
writer.writerow([first_names[i],last_names[i],emails[i], custom_ID_A[i],
custom_ID_G[i]]+custom_values[i])
writer.writerow([first_names[i],last_names[i],emails[i],
custom_ID_A[i], custom_ID_G[i]]+custom_values[i])
# Generate a tex file with custom parameters for each student
for i in range (0,len(first_names)): # For each student
......@@ -112,26 +111,46 @@ for i in range (0,len(first_names)): # For each student
full_name = str(first_names[i]) + ' ' + str(last_names[i])
temp_assig = temp_assig.replace(marker_fullname, full_name)
# Produce the custom tex file for each student
with open ((output_assignment_path+custom_ID_A[i]+'.tex'),'w', encoding="utf-8") as f:
with open ((output_assignment_preamble+custom_ID_A[i]+'.tex'),'w', encoding="utf-8") as f:
for line in temp_assig:
f.write(line)
# Generate modified tex files with solution to the assignment for each student
# For each peer, generate a tex file for the grading
for i in range (0,len(first_names)): # For each student
temp_sol = assig_solution
temp_sol_grading = assig_solution
for j in range (0, len(markers)): # Replace each marker by a custom value
temp_sol = temp_sol.replace(markers[j],str(custom_values[i][j]))
temp_sol_grading = temp_sol_grading.replace(markers[j],str(custom_values[i][j]))
# Mark solution with the student custom ID
temp_sol = temp_sol.replace(marker_customID_A, str(custom_ID_A[i]))
temp_sol = temp_sol.replace(marker_customID_G, str(custom_ID_G[i]))
# Mark assignment with the student first name
temp_sol = temp_sol.replace(marker_firstname, str(first_names[i]))
# Mark solution with the student name
full_name = str(first_names[i]) + ' ' + str(last_names[i])
temp_sol = temp_sol.replace(marker_fullname, full_name)
temp_sol_grading = temp_sol_grading.replace(marker_customID_A, str(custom_ID_A[i]))
temp_sol_grading = temp_sol_grading.replace(marker_customID_G, str(custom_ID_G[i]))
# Mark solution with the student first name
temp_sol_grading = temp_sol_grading.replace(marker_firstname, str(first_names[i]))
# Mark solution with the student first name and last name
full_name = str(first_names[i]) + ' ' + str(last_names[i])
temp_sol_grading = temp_sol_grading.replace(marker_fullname, full_name)
# Produce the custom tex file for each student
with open ((output_solution_path+custom_ID_G[i]+'.tex'),'w', encoding="utf-8") as f:
for line in temp_sol:
with open ((output_solution_grading_preamble+custom_ID_G[i]+'.tex'),'w', encoding="utf-8") as f:
for line in temp_sol_grading:
f.write(line)
# For each student, generate a tex file for the solution
for i in range (0,len(first_names)): # For each student
temp_sol_graded = assig_solution
for j in range (0, len(markers)): # Replace each marker by a custom value
temp_sol_graded = temp_sol_graded.replace(markers[j],str(custom_values[i][j]))
# Mark solution with the student custom ID
temp_sol_graded = temp_sol_graded.replace(marker_customID_A, str(custom_ID_A[i]))
temp_sol_graded = temp_sol_graded.replace(marker_customID_G, str(custom_ID_G[i]))
# Mark solution with the student first name
temp_sol_graded = temp_sol_graded.replace(marker_firstname, str(first_names[i]))
# Mark solution with the student first name and last name
full_name = str(first_names[i]) + ' ' + str(last_names[i])
temp_sol_graded = temp_sol_graded.replace(marker_fullname, full_name)
# Produce the custom tex file for each student
with open ((output_solution_graded_preamble+custom_ID_A[i]+'.tex'),'w', encoding="utf-8") as f:
for line in temp_sol_graded:
f.write(line)
# 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