diff --git a/lib/cadet/assessments/assessments.ex b/lib/cadet/assessments/assessments.ex index 4ce8dec85..55d0dff4d 100644 --- a/lib/cadet/assessments/assessments.ex +++ b/lib/cadet/assessments/assessments.ex @@ -1888,25 +1888,14 @@ defmodule Cadet.Assessments do The return value is `{:ok, %{"count": count, "data": submissions}}` - # Parameters - - `pageSize`: Integer. The number of submissions to return. Default is 10. - - `offset`: Integer. The number of submissions to skip. Default is 0. - - `title`: String. Assessment title. - - `status`: String. Submission status. - - `isFullyGraded`: Boolean. Whether the submission is fully graded. - - `isGradingPublished`: Boolean. Whether the grading is published. - - `group`: Boolean. Only the groups under the grader should be returned. - - `groupName`: String. Group name. - - `name`: String. User name. - - `username`: String. User username. - - `type`: String. Assessment Config type. - - `isManuallyGraded`: Boolean. Whether the assessment is manually graded. + # Params + Refer to admin_grading_controller.ex/index for the list of query parameters. # Implementation Uses helper functions to build the filter query. Helper functions are separated by tables in the database. """ - @spec submissions_by_grader_for_index(CourseRegistration.t()) :: + @spec submissions_by_grader_for_index(CourseRegistration.t(), map()) :: {:ok, %{ :count => integer, @@ -1920,14 +1909,7 @@ defmodule Cadet.Assessments do }} def submissions_by_grader_for_index( grader = %CourseRegistration{course_id: course_id}, - params \\ %{ - "group" => "false", - "isFullyGraded" => "false", - "pageSize" => "10", - "offset" => "0", - "sortBy" => "", - "sortDirection" => "" - } + params ) do submission_answers_query = from(ans in Answer, @@ -1978,8 +1960,8 @@ defmodule Cadet.Assessments do where: s.assessment_id in subquery(build_assessment_config_filter(params)), where: ^build_submission_filter(params), where: ^build_course_registration_filter(params, grader), - limit: ^elem(Integer.parse(Map.get(params, "pageSize", "10")), 0), - offset: ^elem(Integer.parse(Map.get(params, "offset", "0")), 0), + limit: ^params[:limit], + offset: ^params[:offset], select: %{ id: s.id, status: s.status, @@ -1997,8 +1979,7 @@ defmodule Cadet.Assessments do } ) - query = - sort_submission(query, Map.get(params, "sortBy", ""), Map.get(params, "sortDirection", "")) + query = sort_submission(query, params[:sort_by], params[:sort_direction]) query = from([s, ans, asst, cr, user, group] in query, order_by: [desc: s.inserted_at, asc: s.id]) @@ -2027,117 +2008,82 @@ defmodule Cadet.Assessments do end # Given a query from submissions_by_grader_for_index, - # sorts it by the relevant field and direction - # sort_by is a string of either "", "assessmentName", "assessmentType", "studentName", - # "studentUsername", "groupName", "progressStatus", "xp" - # sort_direction is a string of either "", "sort-asc", "sort-desc" - defp sort_submission(query, sort_by, sort_direction) do - cond do - sort_direction == "sort-asc" -> - sort_submission_asc(query, sort_by) - - sort_direction == "sort-desc" -> - sort_submission_desc(query, sort_by) - - true -> - query - end - end - - defp sort_submission_asc(query, sort_by) do - cond do - sort_by == "assessmentName" -> + # sorts it by the relevant field and direction. + defp sort_submission(query, sort_by, sort_direction) + when sort_direction in [:asc, :desc] do + case sort_by do + :assessment_name -> from([s, ans, asst, cr, user, group, config] in query, - order_by: fragment("upper(?)", asst.title) + order_by: [{^sort_direction, fragment("upper(?)", asst.title)}] ) - sort_by == "assessmentType" -> - from([s, ans, asst, cr, user, group, config] in query, order_by: asst.config_id) + :assessment_type -> + from([s, ans, asst, cr, user, group, config] in query, + order_by: [{^sort_direction, asst.config_id}] + ) - sort_by == "studentName" -> + :student_name -> from([s, ans, asst, cr, user, group, config] in query, - order_by: fragment("upper(?)", user.name) + order_by: [{^sort_direction, fragment("upper(?)", user.name)}] ) - sort_by == "studentUsername" -> + :student_username -> from([s, ans, asst, cr, user, group, config] in query, - order_by: fragment("upper(?)", user.username) + order_by: [{^sort_direction, fragment("upper(?)", user.username)}] ) - sort_by == "groupName" -> + :group_name -> from([s, ans, asst, cr, user, group, config] in query, - order_by: fragment("upper(?)", group.name) + order_by: [{^sort_direction, fragment("upper(?)", group.name)}] ) - sort_by == "progressStatus" -> + :progress_status -> from([s, ans, asst, cr, user, group, config] in query, order_by: [ - asc: config.is_manually_graded, - asc: s.status, - asc: ans.graded_count - asst.question_count, - asc: s.is_grading_published + {^sort_direction, config.is_manually_graded}, + {^sort_direction, s.status}, + {^sort_direction, ans.graded_count - asst.question_count}, + {^sort_direction, s.is_grading_published} ] ) - sort_by == "xp" -> + :xp -> from([s, ans, asst, cr, user, group, config] in query, - order_by: ans.xp + ans.xp_adjustment + order_by: [{^sort_direction, ans.xp + ans.xp_adjustment}] ) - true -> + _ -> query end end - defp sort_submission_desc(query, sort_by) do - cond do - sort_by == "assessmentName" -> - from([s, ans, asst, cr, user, group, config] in query, - order_by: [desc: fragment("upper(?)", asst.title)] - ) + defp sort_submission(query, _sort_by, _sort_direction), do: query - sort_by == "assessmentType" -> - from([s, ans, asst, cr, user, group, config] in query, order_by: [desc: asst.config_id]) - - sort_by == "studentName" -> - from([s, ans, asst, cr, user, group, config] in query, - order_by: [desc: fragment("upper(?)", user.name)] - ) - - sort_by == "studentUsername" -> - from([s, ans, asst, cr, user, group, config] in query, - order_by: [desc: fragment("upper(?)", user.username)] - ) - - sort_by == "groupName" -> - from([s, ans, asst, cr, user, group, config] in query, - order_by: [desc: fragment("upper(?)", group.name)] - ) - - sort_by == "progressStatus" -> - from([s, ans, asst, cr, user, group, config] in query, - order_by: [ - desc: config.is_manually_graded, - desc: s.status, - desc: ans.graded_count - asst.question_count, - desc: s.is_grading_published - ] - ) - - sort_by == "xp" -> - from([s, ans, asst, cr, user, group, config] in query, - order_by: [desc: ans.xp + ans.xp_adjustment] - ) + def parse_sort_direction(params) do + case params[:sort_direction] do + "sort-asc" -> Map.put(params, :sort_direction, :asc) + "sort-desc" -> Map.put(params, :sort_direction, :desc) + _ -> Map.put(params, :sort_direction, nil) + end + end - true -> - query + def parse_sort_by(params) do + case params[:sort_by] do + "assessmentName" -> Map.put(params, :sort_by, :assessment_name) + "assessmentType" -> Map.put(params, :sort_by, :assessment_type) + "studentName" -> Map.put(params, :sort_by, :student_name) + "studentUsername" -> Map.put(params, :sort_by, :student_username) + "groupName" -> Map.put(params, :sort_by, :group_name) + "progressStatus" -> Map.put(params, :sort_by, :progress_status) + "xp" -> Map.put(params, :sort_by, :xp) + _ -> Map.put(params, :sort_by, nil) end end defp build_assessment_filter(params, course_id) do assessments_filters = Enum.reduce(params, dynamic(true), fn - {"title", value}, dynamic -> + {:title, value}, dynamic -> dynamic([assessment], ^dynamic and ilike(assessment.title, ^"%#{value}%")) {_, _}, dynamic -> @@ -2153,16 +2099,16 @@ defmodule Cadet.Assessments do defp build_submission_filter(params) do Enum.reduce(params, dynamic(true), fn - {"status", value}, dynamic -> + {:status, value}, dynamic -> dynamic([submission], ^dynamic and submission.status == ^value) - {"isFullyGraded", value}, dynamic -> + {:is_fully_graded, value}, dynamic -> dynamic( [ans: ans, asst: asst], ^dynamic and asst.question_count == ans.graded_count == ^value ) - {"isGradingPublished", value}, dynamic -> + {:is_grading_published, value}, dynamic -> dynamic([submission], ^dynamic and submission.is_grading_published == ^value) {_, _}, dynamic -> @@ -2172,7 +2118,7 @@ defmodule Cadet.Assessments do defp build_course_registration_filter(params, grader) do Enum.reduce(params, dynamic(true), fn - {"group", "true"}, dynamic -> + {:group, true}, dynamic -> dynamic( [submission], (^dynamic and @@ -2186,7 +2132,7 @@ defmodule Cadet.Assessments do )) or submission.student_id == ^grader.id ) - {"groupName", value}, dynamic -> + {:group_name, value}, dynamic -> dynamic( [submission], ^dynamic and @@ -2207,7 +2153,7 @@ defmodule Cadet.Assessments do defp build_user_filter(params) do Enum.reduce(params, dynamic(true), fn - {"name", value}, dynamic -> + {:name, value}, dynamic -> dynamic( [submission], ^dynamic and @@ -2221,7 +2167,7 @@ defmodule Cadet.Assessments do ) ) - {"username", value}, dynamic -> + {:username, value}, dynamic -> dynamic( [submission], ^dynamic and @@ -2243,10 +2189,10 @@ defmodule Cadet.Assessments do defp build_assessment_config_filter(params) do assessment_config_filters = Enum.reduce(params, dynamic(true), fn - {"type", value}, dynamic -> + {:type, value}, dynamic -> dynamic([assessment_config: config], ^dynamic and config.type == ^value) - {"isManuallyGraded", value}, dynamic -> + {:is_manually_graded, value}, dynamic -> dynamic([assessment_config: config], ^dynamic and config.is_manually_graded == ^value) {_, _}, dynamic -> diff --git a/lib/cadet/helpers/shared_helper.ex b/lib/cadet/helpers/shared_helper.ex index 0c20d7fcf..6528a2daa 100644 --- a/lib/cadet/helpers/shared_helper.ex +++ b/lib/cadet/helpers/shared_helper.ex @@ -96,4 +96,26 @@ defmodule Cadet.SharedHelper do Sentry.capture_exception(error, stacktrace: stacktrace) end + + @doc """ + Converts a map with string booleans to booleans. + """ + @spec process_map_booleans(map(), list(atom())) :: map() + def process_map_booleans(map, flags) do + flags + |> Enum.reduce(map, fn flag, acc -> + put_in(acc[flag], acc[flag] == "true") + end) + end + + @doc """ + Converts a map with string integers to integers. + """ + @spec process_map_integers(map(), list(atom())) :: map() + def process_map_integers(map, flags) do + flags + |> Enum.reduce(map, fn flag, acc -> + put_in(acc[flag], String.to_integer(acc[flag])) + end) + end end diff --git a/lib/cadet/jobs/xml_parser.ex b/lib/cadet/jobs/xml_parser.ex index 09640b565..b49128506 100644 --- a/lib/cadet/jobs/xml_parser.ex +++ b/lib/cadet/jobs/xml_parser.ex @@ -8,7 +8,7 @@ defmodule Cadet.Updater.XMLParser do import Ecto.Query import SweetXml - alias Cadet.{Repo, Courses.AssessmentConfig, Assessments} + alias Cadet.{Repo, Courses.AssessmentConfig, Assessments, SharedHelper} require Logger @@ -149,7 +149,8 @@ defmodule Cadet.Updater.XMLParser do |> Enum.map(fn param -> with {:no_missing_attr?, true} <- {:no_missing_attr?, not is_nil(param[:type]) and not is_nil(param[:max_xp])}, - question when is_map(question) <- process_question_booleans(param), + question when is_map(question) <- + SharedHelper.process_map_booleans(param, [:show_solution, :blocking]), question when is_map(question) <- process_question_by_question_type(param), question when is_map(question) <- process_question_library(question, default_library, default_grading_library), @@ -179,16 +180,6 @@ defmodule Cadet.Updater.XMLParser do Logger.error("Changeset: #{inspect(changeset, pretty: true)}") end - @spec process_question_booleans(map()) :: map() - defp process_question_booleans(question) do - flags = [:show_solution, :blocking] - - flags - |> Enum.reduce(question, fn flag, acc -> - put_in(acc[flag], acc[flag] == "true") - end) - end - @spec process_question_by_question_type(map()) :: map() | {:error, String.t()} defp process_question_by_question_type(question) do question[:entity] diff --git a/lib/cadet_web/admin_controllers/admin_grading_controller.ex b/lib/cadet_web/admin_controllers/admin_grading_controller.ex index d95431362..5f349edb0 100644 --- a/lib/cadet_web/admin_controllers/admin_grading_controller.ex +++ b/lib/cadet_web/admin_controllers/admin_grading_controller.ex @@ -4,10 +4,47 @@ defmodule CadetWeb.AdminGradingController do alias Cadet.Assessments + @doc """ + # Query Parameters + - `pageSize`: Integer. The number of submissions to return. Default 10. + - `offset`: Integer. The number of submissions to skip. Default 0. + - `title`: String. Assessment title. + - `status`: String. Submission status. + - `isFullyGraded`: Boolean. Whether the submission is fully graded. + - `isGradingPublished`: Boolean. Whether the grading is published. + - `group`: Boolean. Only the groups under the grader should be returned. + - `groupName`: String. Group name. + - `name`: String. User name. + - `username`: String. User username. + - `type`: String. Assessment Config type. + - `isManuallyGraded`: Boolean. Whether the assessment is manually graded. + """ def index(conn, %{"group" => group} = params) when group in ["true", "false"] do course_reg = conn.assigns[:course_reg] + boolean_params = [:is_fully_graded, :group, :is_manually_graded] + int_params = [:page_size, :offset] + + # Convert string keys to atoms and parse values + params = + params + |> to_snake_case_atom_keys() + |> Map.put_new(:page_size, "10") + |> Map.put_new(:offset, "0") + + filtered_boolean_params = + params + |> Map.take(boolean_params) + |> Map.keys() + + params = + params + |> process_map_booleans(filtered_boolean_params) + |> process_map_integers(int_params) + |> Assessments.parse_sort_direction() + |> Assessments.parse_sort_by() + case Assessments.submissions_by_grader_for_index(course_reg, params) do {:ok, view_model} -> conn diff --git a/test/cadet/assessments/assessments_test.exs b/test/cadet/assessments/assessments_test.exs index 750861657..6c36cd1d1 100644 --- a/test/cadet/assessments/assessments_test.exs +++ b/test/cadet/assessments/assessments_test.exs @@ -2220,8 +2220,8 @@ defmodule Cadet.AssessmentsTest do {_, res} = Assessments.submissions_by_grader_for_index(avenger, %{ - "title" => title, - "pageSize" => total_submissions + :title => title, + :page_size => total_submissions }) assessments_from_res = res[:data][:assessments] @@ -2243,8 +2243,8 @@ defmodule Cadet.AssessmentsTest do {_, res} = Assessments.submissions_by_grader_for_index(avenger, %{ - "status" => "attempting", - "pageSize" => total_submissions + :status => "attempting", + :page_size => total_submissions }) submissions_from_res = res[:data][:submissions] @@ -2268,8 +2268,8 @@ defmodule Cadet.AssessmentsTest do {_, res} = Assessments.submissions_by_grader_for_index(avenger, %{ - "status" => "attempted", - "pageSize" => total_submissions + :status => "attempted", + :page_size => total_submissions }) submissions_from_res = res[:data][:submissions] @@ -2293,8 +2293,8 @@ defmodule Cadet.AssessmentsTest do {_, res} = Assessments.submissions_by_grader_for_index(avenger, %{ - "status" => "submitted", - "pageSize" => total_submissions + :status => "submitted", + :page_size => total_submissions }) submissions_from_res = res[:data][:submissions] @@ -2318,8 +2318,8 @@ defmodule Cadet.AssessmentsTest do {_, res} = Assessments.submissions_by_grader_for_index(avenger, %{ - "isFullyGraded" => "true", - "pageSize" => total_submissions + :is_fully_graded => true, + :page_size => total_submissions }) submissions_from_res = res[:data][:submissions] @@ -2343,8 +2343,8 @@ defmodule Cadet.AssessmentsTest do {_, res} = Assessments.submissions_by_grader_for_index(avenger, %{ - "isFullyGraded" => "false", - "pageSize" => total_submissions + :is_fully_graded => false, + :page_size => total_submissions }) submissions_from_res = res[:data][:submissions] @@ -2370,8 +2370,8 @@ defmodule Cadet.AssessmentsTest do {_, res} = Assessments.submissions_by_grader_for_index(avenger, %{ - "isGradingPublished" => "true", - "pageSize" => total_submissions + :is_grading_published => true, + :page_size => total_submissions }) submissions_from_res = res[:data][:submissions] @@ -2397,8 +2397,8 @@ defmodule Cadet.AssessmentsTest do {_, res} = Assessments.submissions_by_grader_for_index(avenger, %{ - "isGradingPublished" => "false", - "pageSize" => total_submissions + :is_grading_published => false, + :page_size => total_submissions }) submissions_from_res = res[:data][:submissions] @@ -2424,8 +2424,8 @@ defmodule Cadet.AssessmentsTest do {_, res} = Assessments.submissions_by_grader_for_index(avenger, %{ - "group" => "true", - "pageSize" => total_submissions + :group => true, + :page_size => total_submissions }) submissions_from_res = res[:data][:submissions] @@ -2452,8 +2452,8 @@ defmodule Cadet.AssessmentsTest do {_, res} = Assessments.submissions_by_grader_for_index(avenger2, %{ - "group" => "true", - "pageSize" => total_submissions + :group => true, + :page_size => total_submissions }) submissions_from_res = res[:data][:submissions] @@ -2483,8 +2483,8 @@ defmodule Cadet.AssessmentsTest do {_, res} = Assessments.submissions_by_grader_for_index(avenger2, %{ - "groupName" => group_name, - "pageSize" => total_submissions + :group_name => group_name, + :page_size => total_submissions }) submissions_from_res = res[:data][:submissions] @@ -2514,8 +2514,8 @@ defmodule Cadet.AssessmentsTest do {_, res} = Assessments.submissions_by_grader_for_index(avenger, %{ - "groupName" => group_name, - "pageSize" => total_submissions + :group_name => group_name, + :page_size => total_submissions }) submissions_from_res = res[:data][:submissions] @@ -2539,8 +2539,8 @@ defmodule Cadet.AssessmentsTest do {_, res} = Assessments.submissions_by_grader_for_index(avenger, %{ - "name" => student_name, - "pageSize" => total_submissions + :name => student_name, + :page_size => total_submissions }) submissions_from_res = res[:data][:submissions] @@ -2563,8 +2563,8 @@ defmodule Cadet.AssessmentsTest do {_, res} = Assessments.submissions_by_grader_for_index(avenger, %{ - "name" => student_name, - "pageSize" => total_submissions + :name => student_name, + :page_size => total_submissions }) submissions_from_res = res[:data][:submissions] @@ -2587,8 +2587,8 @@ defmodule Cadet.AssessmentsTest do {_, res} = Assessments.submissions_by_grader_for_index(avenger, %{ - "name" => student_name, - "pageSize" => total_submissions + :name => student_name, + :page_size => total_submissions }) submissions_from_res = res[:data][:submissions] @@ -2611,8 +2611,8 @@ defmodule Cadet.AssessmentsTest do {_, res} = Assessments.submissions_by_grader_for_index(avenger, %{ - "username" => student_username, - "pageSize" => total_submissions + :username => student_username, + :page_size => total_submissions }) submissions_from_res = res[:data][:submissions] @@ -2635,8 +2635,8 @@ defmodule Cadet.AssessmentsTest do {_, res} = Assessments.submissions_by_grader_for_index(avenger, %{ - "username" => student_username, - "pageSize" => total_submissions + :username => student_username, + :page_size => total_submissions }) submissions_from_res = res[:data][:submissions] @@ -2659,8 +2659,8 @@ defmodule Cadet.AssessmentsTest do {_, res} = Assessments.submissions_by_grader_for_index(avenger, %{ - "username" => student_username, - "pageSize" => total_submissions + :username => student_username, + :page_size => total_submissions }) submissions_from_res = res[:data][:submissions] @@ -2683,8 +2683,8 @@ defmodule Cadet.AssessmentsTest do {_, res} = Assessments.submissions_by_grader_for_index(avenger, %{ - "type" => assessment_type, - "pageSize" => total_submissions + :type => assessment_type, + :page_size => total_submissions }) assessments_from_res = res[:data][:assessments] @@ -2712,8 +2712,8 @@ defmodule Cadet.AssessmentsTest do {_, res} = Assessments.submissions_by_grader_for_index(avenger, %{ - "type" => assessment_type, - "pageSize" => total_submissions + :type => assessment_type, + :page_size => total_submissions }) assessments_from_res = res[:data][:assessments] @@ -2741,8 +2741,8 @@ defmodule Cadet.AssessmentsTest do {_, res} = Assessments.submissions_by_grader_for_index(avenger, %{ - "type" => assessment_type, - "pageSize" => total_submissions + :type => assessment_type, + :page_size => total_submissions }) assessments_from_res = res[:data][:assessments] @@ -2770,8 +2770,8 @@ defmodule Cadet.AssessmentsTest do {_, res} = Assessments.submissions_by_grader_for_index(avenger, %{ - "isManuallyGraded" => "true", - "pageSize" => total_submissions + :is_manually_graded => true, + :page_size => total_submissions }) submissions_from_res = res[:data][:submissions] @@ -2799,8 +2799,8 @@ defmodule Cadet.AssessmentsTest do {_, res} = Assessments.submissions_by_grader_for_index(avenger, %{ - "isManuallyGraded" => "false", - "pageSize" => total_submissions + :is_manually_graded => false, + :page_size => total_submissions }) submissions_from_res = res[:data][:submissions] @@ -2823,9 +2823,9 @@ defmodule Cadet.AssessmentsTest do } do {_, res} = Assessments.submissions_by_grader_for_index(avenger, %{ - "pageSize" => total_submissions, - "sortBy" => "assessmentName", - "sortDirection" => "sort-asc" + :page_size => total_submissions, + :sort_by => :assessment_name, + :sort_direction => :asc }) submissions_from_res = res[:data][:submissions] @@ -2857,9 +2857,9 @@ defmodule Cadet.AssessmentsTest do } do {_, res} = Assessments.submissions_by_grader_for_index(avenger, %{ - "pageSize" => total_submissions, - "sortBy" => "assessmentName", - "sortDirection" => "sort-desc" + :page_size => total_submissions, + :sort_by => :assessment_name, + :sort_direction => :desc }) submissions_from_res = res[:data][:submissions] @@ -2891,9 +2891,9 @@ defmodule Cadet.AssessmentsTest do } do {_, res} = Assessments.submissions_by_grader_for_index(avenger, %{ - "pageSize" => total_submissions, - "sortBy" => "assessmentType", - "sortDirection" => "sort-asc" + :page_size => total_submissions, + :sort_by => :assessment_type, + :sort_direction => :asc }) submissions_from_res = res[:data][:submissions] @@ -2925,9 +2925,9 @@ defmodule Cadet.AssessmentsTest do } do {_, res} = Assessments.submissions_by_grader_for_index(avenger, %{ - "pageSize" => total_submissions, - "sortBy" => "assessmentType", - "sortDirection" => "sort-desc" + :page_size => total_submissions, + :sort_by => :assessment_type, + :sort_direction => :desc }) submissions_from_res = res[:data][:submissions] @@ -2959,9 +2959,9 @@ defmodule Cadet.AssessmentsTest do } do {_, res} = Assessments.submissions_by_grader_for_index(avenger, %{ - "pageSize" => total_submissions, - "sortBy" => "xp", - "sortDirection" => "sort-asc" + :page_size => total_submissions, + :sort_by => :xp, + :sort_direction => :asc }) submissions_from_res = res[:data][:submissions] @@ -2982,9 +2982,9 @@ defmodule Cadet.AssessmentsTest do } do {_, res} = Assessments.submissions_by_grader_for_index(avenger, %{ - "pageSize" => total_submissions, - "sortBy" => "xp", - "sortDirection" => "sort-desc" + :page_size => total_submissions, + :sort_by => :xp, + :sort_direction => :desc }) submissions_from_res = res[:data][:submissions] diff --git a/test/cadet/helpers/shared_helper_test.exs b/test/cadet/helpers/shared_helper_test.exs index 43ef3451f..1d77de7a0 100644 --- a/test/cadet/helpers/shared_helper_test.exs +++ b/test/cadet/helpers/shared_helper_test.exs @@ -42,4 +42,24 @@ defmodule Cadet.SharedHelperTest do } end end + + test "process_map_booleans works correctly" do + map = %{:hello_world => "true", :bye_world => "false"} + flags = [:hello_world, :bye_world] + + assert process_map_booleans(map, flags) == %{ + :hello_world => true, + :bye_world => false + } + end + + test "process_map_integers works correctly" do + map = %{:hello_world => "1", :bye_world => "2"} + flags = [:hello_world, :bye_world] + + assert process_map_integers(map, flags) == %{ + :hello_world => 1, + :bye_world => 2 + } + end end