Skip to content

Commit efc4c57

Browse files
committed
Formatting
1 parent 5573a21 commit efc4c57

File tree

8 files changed

+228
-172
lines changed

8 files changed

+228
-172
lines changed

lib/cadet/assessments/assessments.ex

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2290,7 +2290,8 @@ defmodule Cadet.Assessments do
22902290
base_query =
22912291
Answer
22922292
|> where(submission_id: ^id)
2293-
|> join(:inner, [a], q in assoc(a, :question)) # [a] are bindings (in SQL it is similar to FROM answers "AS a"), this line's alias is INNER JOIN ... "AS q"
2293+
# [a] are bindings (in SQL it is similar to FROM answers "AS a"), this line's alias is INNER JOIN ... "AS q"
2294+
|> join(:inner, [a], q in assoc(a, :question))
22942295
|> join(:inner, [_, q], ast in assoc(q, :assessment))
22952296
|> join(:inner, [..., ast], ac in assoc(ast, :config))
22962297
|> join(:left, [a, ...], g in assoc(a, :grader))
@@ -2794,11 +2795,11 @@ defmodule Cadet.Assessments do
27942795
end
27952796

27962797
def get_llm_assessment_prompt(question_id) do
2797-
from(q in Question,
2798-
where: q.id == ^question_id,
2799-
join: a in assoc(q, :assessment),
2800-
select: a.llm_assessment_prompt
2801-
)
2802-
|> Repo.one()
2798+
from(q in Question,
2799+
where: q.id == ^question_id,
2800+
join: a in assoc(q, :assessment),
2801+
select: a.llm_assessment_prompt
2802+
)
2803+
|> Repo.one()
28032804
end
28042805
end

lib/cadet/courses/course.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ defmodule Cadet.Courses.Course do
100100
if llm_api_key = get_change(changeset, :llm_api_key) do
101101
if is_binary(llm_api_key) and llm_api_key != "" do
102102
encrypted = encrypt_llm_api_key(llm_api_key)
103+
103104
case encrypted do
104105
nil ->
105106
add_error(
@@ -111,7 +112,6 @@ defmodule Cadet.Courses.Course do
111112
encrypted ->
112113
put_change(changeset, :llm_api_key, encrypted)
113114
end
114-
115115
else
116116
# If empty string or nil is provided, don't encrypt but don't add error
117117
changeset

lib/cadet/jobs/xml_parser.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ defmodule Cadet.Updater.XMLParser do
9898
reading: ~x"//READING/text()" |> transform_by(&process_charlist/1),
9999
summary_short: ~x"//WEBSUMMARY/text()" |> transform_by(&process_charlist/1),
100100
summary_long: ~x"./TEXT/text()" |> transform_by(&process_charlist/1),
101-
llm_assessment_prompt: ~x"./LLM_ASSESSMENT_PROMPT/text()" |> transform_by(&process_charlist/1),
101+
llm_assessment_prompt:
102+
~x"./LLM_ASSESSMENT_PROMPT/text()" |> transform_by(&process_charlist/1),
102103
password: ~x"//PASSWORD/text()"so |> transform_by(&process_charlist/1)
103104
)
104105
|> Map.put(:is_published, false)

lib/cadet_web/admin_views/admin_grading_view.ex

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ defmodule CadetWeb.AdminGradingView do
88
assessment:
99
render_one(assessment, CadetWeb.AdminGradingView, "assessment.json", as: :assessment),
1010
answers: render_many(answers, CadetWeb.AdminGradingView, "grading_info.json", as: :answer),
11-
enable_llm_grading: course.enable_llm_grading,
11+
enable_llm_grading: course.enable_llm_grading
1212
}
1313
end
1414

@@ -22,8 +22,7 @@ defmodule CadetWeb.AdminGradingView do
2222
number: assessment.number,
2323
story: assessment.story,
2424
reading: assessment.reading,
25-
llm_assessment_prompt: assessment.llm_assessment_prompt,
26-
25+
llm_assessment_prompt: assessment.llm_assessment_prompt
2726
}
2827
end
2928

@@ -157,7 +156,7 @@ defmodule CadetWeb.AdminGradingView do
157156
team: &extract_team_data(&1.submission.team),
158157
question: &build_grading_question/1,
159158
solution: &(&1.question.question["solution"] || ""),
160-
grade: &build_grade/1,
159+
grade: &build_grade/1
161160
})
162161
end
163162

@@ -166,8 +165,10 @@ defmodule CadetWeb.AdminGradingView do
166165
end
167166

168167
defp extract_ai_comments_per_answer(question_id, ai_comments) do
169-
matching_comment = ai_comments
170-
|> Enum.find(&(&1.question_id == question_id)) # Equivalent to fn comment -> comment.question_id == question_id end
168+
matching_comment =
169+
ai_comments
170+
# Equivalent to fn comment -> comment.question_id == question_id end
171+
|> Enum.find(&(&1.question_id == question_id))
171172

172173
case matching_comment do
173174
nil -> nil

lib/cadet_web/controllers/courses_controller.ex

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,14 @@ defmodule CadetWeb.CoursesController do
6060
llm_api_key(:body, :string, "OpenAI API key for this course", required: false)
6161
llm_model(:body, :string, "LLM model to be used for this course", required: false)
6262
llm_api_url(:body, :string, "LLM API URL to be used for this course", required: false)
63-
llm_course_level_prompt(:body, :string, "LLM course level prompt to be used for this course", required: false)
63+
64+
llm_course_level_prompt(
65+
:body,
66+
:string,
67+
"LLM course level prompt to be used for this course",
68+
required: false
69+
)
70+
6471
source_chapter(:body, :number, "Default source chapter", required: true)
6572

6673
source_variant(:body, Schema.ref(:SourceVariant), "Default source variant name",
@@ -106,7 +113,11 @@ defmodule CadetWeb.CoursesController do
106113
llm_api_key(:string, "OpenAI API key for this course", required: false)
107114
llm_model(:string, "LLM model to be used for this course", required: false)
108115
llm_api_url(:string, "LLM API URL to be used for this course", required: false)
109-
llm_course_level_prompt(:string, "LLM course level prompt to be used for this course", required: false)
116+
117+
llm_course_level_prompt(:string, "LLM course level prompt to be used for this course",
118+
required: false
119+
)
120+
110121
source_chapter(:integer, "Source Chapter number from 1 to 4", required: true)
111122
source_variant(Schema.ref(:SourceVariant), "Source Variant name", required: true)
112123
module_help_text(:string, "Module help text", required: true)
@@ -125,7 +136,8 @@ defmodule CadetWeb.CoursesController do
125136
llm_api_key: "sk-1234567890",
126137
llm_model: "gpt-4",
127138
llm_api_url: "https://api.openai.com/v1/chat/completions",
128-
llm_course_level_prompt: "You are a helpful teaching assistant for an introductory programming course",
139+
llm_course_level_prompt:
140+
"You are a helpful teaching assistant for an introductory programming course",
129141
source_chapter: 1,
130142
source_variant: "default",
131143
module_help_text: "Help text",

0 commit comments

Comments
 (0)