Skip to content

Commit 0074e1a

Browse files
committed
Update dependencies
1 parent 3dd407a commit 0074e1a

27 files changed

+128
-78
lines changed

.github/workflows/cd.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ jobs:
2424
env:
2525
MIX_ENV: prod
2626
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27-
ELIXIR_VERSION: '1.12.3'
28-
OTP_VERSION: '24.0.6'
27+
ELIXIR_VERSION: '1.13.2'
28+
OTP_VERSION: '24.2'
2929
steps:
3030
- uses: rlespinasse/github-slug-action@v3.x
3131
- uses: actions/checkout@v2

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ jobs:
2323
env:
2424
MIX_ENV: test
2525
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26-
ELIXIR_VERSION: '1.12.3'
27-
OTP_VERSION: '24.0.6'
26+
ELIXIR_VERSION: '1.13.2'
27+
OTP_VERSION: '24.2'
2828
services:
2929
postgres:
3030
image: postgres:13.1

lib/cadet/accounts/course_registration.ex

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ defmodule Cadet.Accounts.CourseRegistration do
77
alias Cadet.Accounts.{Role, User}
88
alias Cadet.Courses.{Course, Group}
99

10+
@type t :: %__MODULE__{
11+
role: Role.t(),
12+
game_states: %{},
13+
agreed_to_research: boolean(),
14+
group: Group.t() | nil,
15+
user: User.t() | nil,
16+
course: Course.t() | nil
17+
}
18+
1019
schema "course_registrations" do
1120
field(:role, Role)
1221
field(:game_states, :map)

lib/cadet/accounts/notifications.ex

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ defmodule Cadet.Accounts.Notifications do
1515
@doc """
1616
Fetches all unread notifications belonging to a course_reg as an array
1717
"""
18-
@spec fetch(%CourseRegistration{}) :: {:ok, {:array, Notification}}
18+
@spec fetch(CourseRegistration.t()) :: {:ok, {:array, Notification}}
1919
def fetch(course_reg = %CourseRegistration{}) do
2020
notifications =
2121
Notification
@@ -101,7 +101,7 @@ defmodule Cadet.Accounts.Notifications do
101101
@doc """
102102
Changes read status of notification(s) from false to true.
103103
"""
104-
@spec acknowledge({:array, :integer}, %CourseRegistration{}) ::
104+
@spec acknowledge({:array, :integer}, CourseRegistration.t()) ::
105105
{:ok, Ecto.Schema.t()}
106106
| {:error, any}
107107
| {:error, Ecto.Multi.name(), any, %{Ecto.Multi.name() => any}}
@@ -123,7 +123,7 @@ defmodule Cadet.Accounts.Notifications do
123123
|> Repo.transaction()
124124
end
125125

126-
@spec acknowledge(:integer, %CourseRegistration{}) :: {:ok, Ecto.Schema.t()} | {:error, any()}
126+
@spec acknowledge(:integer, CourseRegistration.t()) :: {:ok, Ecto.Schema.t()} | {:error, any()}
127127
def acknowledge(notification_id, course_reg = %CourseRegistration{}) do
128128
notification = Repo.get_by(Notification, id: notification_id, course_reg_id: course_reg.id)
129129

@@ -141,7 +141,7 @@ defmodule Cadet.Accounts.Notifications do
141141
@doc """
142142
Function that handles notifications when a submission is unsubmitted.
143143
"""
144-
@spec handle_unsubmit_notifications(integer(), %CourseRegistration{}) ::
144+
@spec handle_unsubmit_notifications(integer(), CourseRegistration.t()) ::
145145
{:ok, Ecto.Schema.t()} | {:error, Ecto.Changeset.t()}
146146
def handle_unsubmit_notifications(assessment_id, student = %CourseRegistration{})
147147
when is_ecto_id(assessment_id) do
@@ -220,7 +220,7 @@ defmodule Cadet.Accounts.Notifications do
220220
When a student has finalized a submission, writes a notification to the corresponding
221221
grader (Avenger) in charge of the student.
222222
"""
223-
@spec write_notification_when_student_submits(%Submission{}) ::
223+
@spec write_notification_when_student_submits(Submission.t()) ::
224224
{:ok, Ecto.Schema.t()} | {:error, Ecto.Changeset.t()}
225225
def write_notification_when_student_submits(submission = %Submission{}) do
226226
avenger_id = get_avenger_id_of(submission.student_id)

lib/cadet/accounts/query.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ defmodule Cadet.Accounts.Query do
2020
|> preload(:latest_viewed_course)
2121
end
2222

23-
@spec students_of(%CourseRegistration{}) :: Ecto.Query.t()
23+
@spec students_of(CourseRegistration.t()) :: Ecto.Query.t()
2424
def students_of(course_reg = %CourseRegistration{course_id: course_id}) do
2525
# Note that staff role is not check here as we assume that
2626
# group leader is assign to a staff validated by group changeset

lib/cadet/accounts/user.ex

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ defmodule Cadet.Accounts.User do
88
alias Cadet.Accounts.CourseRegistration
99
alias Cadet.Courses.Course
1010

11+
@type t :: %__MODULE__{
12+
name: String.t(),
13+
username: String.t(),
14+
provider: String.t(),
15+
latest_viewed_course: Course.t()
16+
}
17+
1118
schema "users" do
1219
field(:name, :string)
1320
field(:username, :string)

lib/cadet/assessments/answer.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ defmodule Cadet.Assessments.Answer do
1111
alias Cadet.Assessments.AnswerTypes.{MCQAnswer, ProgrammingAnswer, VotingAnswer}
1212
alias Cadet.Assessments.{Question, QuestionType, Submission}
1313

14+
@type t :: %__MODULE__{}
15+
1416
schema "answers" do
1517
# used to compare answers with others
1618
field(:relative_score, :float, default: 0.0)

lib/cadet/assessments/assessment.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ defmodule Cadet.Assessments.Assessment do
1010
alias Cadet.Assessments.{AssessmentAccess, Question, SubmissionStatus, Upload}
1111
alias Cadet.Courses.{Course, AssessmentConfig}
1212

13+
@type t :: %__MODULE__{}
14+
1315
schema "assessments" do
1416
field(:access, AssessmentAccess, virtual: true, default: :public)
1517
field(:max_xp, :integer, virtual: true)

lib/cadet/assessments/assessments.ex

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ defmodule Cadet.Assessments do
6161
Repo.delete_all(submissions)
6262
end
6363

64-
@spec user_max_xp(%CourseRegistration{}) :: integer()
64+
@spec user_max_xp(CourseRegistration.t()) :: integer()
6565
def user_max_xp(%CourseRegistration{id: cr_id}) do
6666
Submission
6767
|> where(status: ^:submitted)
@@ -127,7 +127,7 @@ defmodule Cadet.Assessments do
127127
story
128128
end
129129

130-
@spec get_user_story_by_type(%CourseRegistration{}, :unattempted | :attempted) ::
130+
@spec get_user_story_by_type(CourseRegistration.t(), :unattempted | :attempted) ::
131131
String.t() | nil
132132
def get_user_story_by_type(%CourseRegistration{id: cr_id}, type)
133133
when is_atom(type) do
@@ -812,8 +812,8 @@ defmodule Cadet.Assessments do
812812
end
813813
end
814814

815-
@spec update_submission_status_and_xp_bonus(%Submission{}) ::
816-
{:ok, %Submission{}} | {:error, Ecto.Changeset.t()}
815+
@spec update_submission_status_and_xp_bonus(Submission.t()) ::
816+
{:ok, Submission.t()} | {:error, Ecto.Changeset.t()}
817817
defp update_submission_status_and_xp_bonus(submission = %Submission{}) do
818818
assessment = submission.assessment
819819
assessment_conifg = Repo.get_by(AssessmentConfig, id: assessment.config_id)
@@ -1118,7 +1118,7 @@ defmodule Cadet.Assessments do
11181118
The return value is {:ok, submissions} if no errors, else it is {:error,
11191119
{:unauthorized, "Forbidden."}}
11201120
"""
1121-
@spec all_submissions_by_grader_for_index(%CourseRegistration{}) ::
1121+
@spec all_submissions_by_grader_for_index(CourseRegistration.t()) ::
11221122
{:ok, String.t()}
11231123
def all_submissions_by_grader_for_index(
11241124
grader = %CourseRegistration{course_id: course_id},
@@ -1221,7 +1221,7 @@ defmodule Cadet.Assessments do
12211221
end
12221222

12231223
@spec get_answers_in_submission(integer() | String.t()) ::
1224-
{:ok, [%Answer{}]} | {:error, {:bad_request | :unauthorized, String.t()}}
1224+
{:ok, [Answer.t()]} | {:error, {:bad_request | :unauthorized, String.t()}}
12251225
def get_answers_in_submission(id) when is_ecto_id(id) do
12261226
answer_query =
12271227
Answer
@@ -1286,7 +1286,7 @@ defmodule Cadet.Assessments do
12861286
@spec update_grading_info(
12871287
%{submission_id: integer() | String.t(), question_id: integer() | String.t()},
12881288
%{},
1289-
%CourseRegistration{}
1289+
CourseRegistration.t()
12901290
) ::
12911291
{:ok, nil}
12921292
| {:error, {:unauthorized | :bad_request | :internal_server_error, String.t()}}
@@ -1347,7 +1347,7 @@ defmodule Cadet.Assessments do
13471347
{:error, {:unauthorized, "User is not permitted to grade."}}
13481348
end
13491349

1350-
@spec force_regrade_submission(integer() | String.t(), %CourseRegistration{}) ::
1350+
@spec force_regrade_submission(integer() | String.t(), CourseRegistration.t()) ::
13511351
{:ok, nil} | {:error, {:forbidden | :not_found, String.t()}}
13521352
def force_regrade_submission(
13531353
submission_id,
@@ -1374,7 +1374,7 @@ defmodule Cadet.Assessments do
13741374
@spec force_regrade_answer(
13751375
integer() | String.t(),
13761376
integer() | String.t(),
1377-
%CourseRegistration{}
1377+
CourseRegistration.t()
13781378
) ::
13791379
{:ok, nil} | {:error, {:forbidden | :not_found, String.t()}}
13801380
def force_regrade_answer(
@@ -1423,7 +1423,7 @@ defmodule Cadet.Assessments do
14231423
end
14241424

14251425
# Checks if an assessment is open and published.
1426-
@spec is_open?(%Assessment{}) :: boolean()
1426+
@spec is_open?(Assessment.t()) :: boolean()
14271427
def is_open?(%Assessment{open_at: open_at, close_at: close_at, is_published: is_published}) do
14281428
Timex.between?(Timex.now(), open_at, close_at, inclusive: :start) and is_published
14291429
end

lib/cadet/assessments/question.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ defmodule Cadet.Assessments.Question do
88
alias Cadet.Assessments.{Assessment, Library, QuestionType}
99
alias Cadet.Assessments.QuestionTypes.{MCQQuestion, ProgrammingQuestion, VotingQuestion}
1010

11+
@type t :: %__MODULE__{}
12+
1113
schema "questions" do
1214
field(:display_order, :integer)
1315
field(:question, :map)

lib/cadet/assessments/submission.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ defmodule Cadet.Assessments.Submission do
55
alias Cadet.Accounts.CourseRegistration
66
alias Cadet.Assessments.{Answer, Assessment, SubmissionStatus}
77

8+
@type t :: %__MODULE__{}
9+
810
schema "submissions" do
911
field(:xp, :integer, virtual: true)
1012
field(:xp_adjustment, :integer, virtual: true)

lib/cadet/courses/course.ex

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@ defmodule Cadet.Courses.Course do
66

77
alias Cadet.Courses.AssessmentConfig
88

9+
@type t :: %__MODULE__{
10+
course_name: String.t(),
11+
course_short_name: String.t(),
12+
viewable: boolean(),
13+
enable_game: boolean(),
14+
enable_achievements: boolean(),
15+
enable_sourcecast: boolean(),
16+
source_chapter: integer(),
17+
source_variant: String.t(),
18+
module_help_text: String.t(),
19+
assets_prefix: String.t() | nil
20+
}
21+
922
schema "courses" do
1023
field(:course_name, :string)
1124
field(:course_short_name, :string)

lib/cadet/courses/courses.ex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ defmodule Cadet.Courses do
4343
Returns the course configuration for the specified course.
4444
"""
4545
@spec get_course_config(integer) ::
46-
{:ok, %Course{}} | {:error, {:bad_request, String.t()}}
46+
{:ok, Course.t()} | {:error, {:bad_request, String.t()}}
4747
def get_course_config(course_id) when is_ecto_id(course_id) do
4848
case retrieve_course(course_id) do
4949
nil ->
@@ -65,7 +65,7 @@ defmodule Cadet.Courses do
6565
Updates the general course configuration for the specified course
6666
"""
6767
@spec update_course_config(integer, %{}) ::
68-
{:ok, %Course{}} | {:error, Ecto.Changeset.t()} | {:error, {:bad_request, String.t()}}
68+
{:ok, Course.t()} | {:error, Ecto.Changeset.t()} | {:error, {:bad_request, String.t()}}
6969
def update_course_config(course_id, params) when is_ecto_id(course_id) do
7070
case retrieve_course(course_id) do
7171
nil ->
@@ -299,7 +299,7 @@ defmodule Cadet.Courses do
299299
Get a group based on the group name and course id or create one if it doesn't exist
300300
"""
301301
@spec get_or_create_group(String.t(), integer()) ::
302-
{:ok, %Group{}} | {:error, Ecto.Changeset.t()}
302+
{:ok, Group.t()} | {:error, Ecto.Changeset.t()}
303303
def get_or_create_group(name, course_id) when is_binary(name) and is_ecto_id(course_id) do
304304
Group
305305
|> where(name: ^name)
@@ -406,7 +406,7 @@ defmodule Cadet.Courses do
406406
# |> Repo.preload(:uploader)
407407
# end
408408

409-
@spec assets_prefix(%Course{}) :: binary()
409+
@spec assets_prefix(Course.t()) :: binary()
410410
def assets_prefix(course) do
411411
course.assets_prefix || "#{Assets.assets_prefix()}#{course.id}/"
412412
end

lib/cadet/courses/group.ex

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ defmodule Cadet.Courses.Group do
99
alias Cadet.Accounts.CourseRegistration
1010
alias Cadet.Courses.Course
1111

12+
@type t :: %__MODULE__{
13+
name: String.t(),
14+
leader: CourseRegistration.t() | nil,
15+
course: Course.t() | nil
16+
}
17+
1218
schema "groups" do
1319
field(:name, :string)
1420
belongs_to(:leader, CourseRegistration)

lib/cadet/devices/device.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ defmodule Cadet.Devices.Device do
55

66
use Cadet, :model
77

8+
@type t :: %__MODULE__{}
9+
810
schema "devices" do
911
field(:secret, :string)
1012
field(:type, :string)

lib/cadet/devices/device_registration.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ defmodule Cadet.Devices.DeviceRegistration do
88
alias Cadet.Accounts.User
99
alias Cadet.Devices.Device
1010

11+
@type t :: %__MODULE__{}
12+
1113
schema "device_registrations" do
1214
field(:title, :string)
1315

lib/cadet/devices/devices.ex

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ defmodule Cadet.Devices do
1111
alias Cadet.Devices.{Device, DeviceRegistration}
1212
alias ExAws.STS
1313

14-
@spec get_user_registrations(integer | String.t() | %User{}) :: [%DeviceRegistration{}]
14+
@spec get_user_registrations(integer | String.t() | User.t()) :: [DeviceRegistration.t()]
1515
def get_user_registrations(%User{id: user_id}) do
1616
get_user_registrations(user_id)
1717
end
@@ -23,8 +23,8 @@ defmodule Cadet.Devices do
2323
|> Repo.all()
2424
end
2525

26-
@spec get_user_registration(integer | String.t() | %User{}, integer | String.t()) ::
27-
%DeviceRegistration{} | nil
26+
@spec get_user_registration(integer | String.t() | User.t(), integer | String.t()) ::
27+
DeviceRegistration.t() | nil
2828
def get_user_registration(%User{id: user_id}, id) do
2929
get_user_registration(user_id, id)
3030
end
@@ -37,20 +37,20 @@ defmodule Cadet.Devices do
3737
|> Repo.get(id)
3838
end
3939

40-
@spec delete_registration(%DeviceRegistration{}) :: {:ok, %DeviceRegistration{}}
40+
@spec delete_registration(DeviceRegistration.t()) :: {:ok, DeviceRegistration.t()}
4141
def delete_registration(registration = %DeviceRegistration{}) do
4242
Repo.delete(registration)
4343
end
4444

45-
@spec rename_registration(%DeviceRegistration{}, String.t()) ::
46-
{:ok, %DeviceRegistration{}} | {:error, Ecto.Changeset.t()}
45+
@spec rename_registration(DeviceRegistration.t(), String.t()) ::
46+
{:ok, DeviceRegistration.t()} | {:error, Ecto.Changeset.t()}
4747
def rename_registration(registration = %DeviceRegistration{}, title) do
4848
registration
4949
|> DeviceRegistration.changeset(%{title: title})
5050
|> Repo.update()
5151
end
5252

53-
@spec get_device(binary | integer) :: %Device{} | nil
53+
@spec get_device(binary | integer) :: Device.t() | nil
5454
def get_device(device_id) when is_integer(device_id) do
5555
Repo.get(Device, device_id)
5656
end
@@ -61,8 +61,8 @@ defmodule Cadet.Devices do
6161
|> Repo.one()
6262
end
6363

64-
@spec register(binary, binary, binary, integer | %User{}) ::
65-
{:ok, %DeviceRegistration{}} | {:error, Ecto.Changeset.t() | :conflicting_device}
64+
@spec register(binary, binary, binary, integer | User.t()) ::
65+
{:ok, DeviceRegistration.t()} | {:error, Ecto.Changeset.t() | :conflicting_device}
6666
def register(title, type, secret, %User{id: user_id}) do
6767
register(title, type, secret, user_id)
6868
end
@@ -78,7 +78,7 @@ defmodule Cadet.Devices do
7878
end
7979
end
8080

81-
@spec get_device_key_cert(binary | integer | %Device{}) ::
81+
@spec get_device_key_cert(binary | integer | Device.t()) ::
8282
{:ok, {String.t(), String.t()}}
8383
| {:error,
8484
:no_such_device
@@ -108,7 +108,7 @@ defmodule Cadet.Devices do
108108
end
109109

110110
@spec maybe_insert_device(binary, binary) ::
111-
{:ok, %Device{}} | {:error, Ecto.Changeset.t() | :conflicting_device}
111+
{:ok, Device.t()} | {:error, Ecto.Changeset.t() | :conflicting_device}
112112
defp maybe_insert_device(type, secret) do
113113
case get_device(secret) do
114114
device = %Device{} ->
@@ -167,8 +167,8 @@ defmodule Cadet.Devices do
167167
end
168168

169169
@spec get_device_ws_endpoint(
170-
binary | integer | %Device{},
171-
%User{},
170+
binary | integer | Device.t(),
171+
User.t(),
172172
[{:datetime, :calendar.datetime()}]
173173
) ::
174174
{:ok, %{}}

0 commit comments

Comments
 (0)