From 8aad9db5c830b1f224f2131d5fe7bf150d7c77d3 Mon Sep 17 00:00:00 2001 From: padmaJS Date: Wed, 27 Nov 2024 21:46:34 +0545 Subject: [PATCH] update csv headers --- lib/handin/assignment_submissions.ex | 6 +++--- lib/handin_web/controllers/submission_controller.ex | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/handin/assignment_submissions.ex b/lib/handin/assignment_submissions.ex index 5d3a342..1d7342d 100644 --- a/lib/handin/assignment_submissions.ex +++ b/lib/handin/assignment_submissions.ex @@ -46,7 +46,7 @@ defmodule Handin.AssignmentSubmissions do Map.merge(test_result_marks, %{ "full_name" => DisplayHelper.get_full_name(user), - "email" => user.email, + "id" => user.id, "attempt_marks" => attempt_marks, "total" => total_points }) @@ -68,7 +68,7 @@ defmodule Handin.AssignmentSubmissions do end defp calculate_test_result_marks(nil, assignment_tests) do - Enum.reduce(assignment_tests, %{}, &Map.put(&2, &1.command, 0)) + Enum.reduce(assignment_tests, %{}, &Map.put(&2, &1.name, 0)) end defp calculate_test_result_marks(build, _assignment_tests) do @@ -76,7 +76,7 @@ defmodule Handin.AssignmentSubmissions do test_marks = if test_result.state == :pass, do: test_result.assignment_test.points_on_pass, else: 0 - Map.put(acc, test_result.assignment_test.command, test_marks) + Map.put(acc, test_result.assignment_test.name, test_marks) end) end diff --git a/lib/handin_web/controllers/submission_controller.ex b/lib/handin_web/controllers/submission_controller.ex index 6cdd1fc..c3051e2 100644 --- a/lib/handin_web/controllers/submission_controller.ex +++ b/lib/handin_web/controllers/submission_controller.ex @@ -8,7 +8,9 @@ defmodule HandinWeb.SubmissionController do conn = prepare_conn_for_csv_download(conn, assignment.name) Repo.transaction(fn -> - student_grades = AssignmentSubmissions.get_student_grades_for_assignment(assignment_id) + student_grades = + AssignmentSubmissions.get_student_grades_for_assignment(assignment_id) + headers = generate_headers(student_grades) send_csv_data(conn, headers, student_grades) @@ -28,9 +30,9 @@ defmodule HandinWeb.SubmissionController do test_headers = List.first(student_grades) |> Map.keys() - |> Enum.filter(&(&1 not in ["full_name", "email", "attempt_marks", "total"])) + |> Enum.filter(&(&1 not in ["full_name", "id", "attempt_marks", "total"])) - ["full_name", "email", "attempt_marks"] ++ test_headers ++ ["total"] + ["full_name", "id", "attempt_marks"] ++ test_headers ++ ["total"] end defp send_csv_data(conn, headers, student_grades) do