• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

source-academy / backend / e0330f2cf38b2d8af12bffd20f4cac2158d607fc-PR-1236

31 Mar 2025 09:12AM UTC coverage: 19.982% (-73.6%) from 93.607%
e0330f2cf38b2d8af12bffd20f4cac2158d607fc-PR-1236

Pull #1236

github

RichDom2185
Redate migrations to maintain total ordering
Pull Request #1236: Added Exam mode

12 of 57 new or added lines in 8 files covered. (21.05%)

2430 existing lines in 97 files now uncovered.

671 of 3358 relevant lines covered (19.98%)

3.03 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/lib/cadet/accounts/team.ex
1
defmodule Cadet.Accounts.Team do
2
  @moduledoc """
3
  This module defines the Ecto schema and changeset for teams in the Cadet.Accounts context.
4
  Teams represent groups of students collaborating on an assessment within a course.
5
  """
6

7
  use Cadet, :model
8

9
  alias Cadet.Accounts.TeamMember
10
  alias Cadet.Assessments.{Assessment, Submission}
11

12
  @doc """
13
  Ecto schema definition for teams.
14
  This schema represents a group of students collaborating on a specific assessment within a course.
15
  Fields:
16
    - `assessment`: A reference to the assessment associated with the team.
17
    - `submission`: A reference to the team's submission for the assessment.
18
    - `team_members`: A list of team members associated with the team.
19
  """
UNCOV
20
  schema "teams" do
×
21
    belongs_to(:assessment, Assessment)
22
    has_one(:submission, Submission, on_delete: :delete_all)
23
    has_many(:team_members, TeamMember, on_delete: :delete_all)
24

25
    timestamps()
26
  end
27

28
  @required_fields ~w(assessment_id)a
29

30
  @doc """
31
  Builds an Ecto changeset for a team.
32
  This function is used to create or update a team record based on the provided attributes.
33
  Args:
34
    - `team`: The existing team struct.
35
    - `attrs`: The attributes to be cast and validated for the changeset.
36
  Returns:
37
    A changeset struct with cast and validated attributes.
38
  """
39
  def changeset(team, attrs) do
40
    team
41
    |> cast(attrs, @required_fields)
42
    |> validate_required(@required_fields)
UNCOV
43
    |> foreign_key_constraint(:assessment_id)
×
44
  end
45
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc