Skip to content

Commit 73a4dd1

Browse files
Merge pull request #2 from SA-Teams-Assessment/branch-fix-git-diff
Branch fix git diff
2 parents 82fbece + 995c56e commit 73a4dd1

File tree

11 files changed

+4433
-4434
lines changed

11 files changed

+4433
-4434
lines changed

.credo.exs

Lines changed: 140 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -1,140 +1,140 @@
1-
# This file contains the configuration for Credo and you are probably reading
2-
# this after creating it with `mix credo.gen.config`.
3-
#
4-
# If you find anything wrong or unclear in this file, please report an
5-
# issue on GitHub: https://github.com/rrrene/credo/issues
6-
#
7-
%{
8-
#
9-
# You can have as many configs as you like in the `configs:` field.
10-
configs: [
11-
%{
12-
#
13-
# Run any exec using `mix credo -C <name>`. If no exec name is given
14-
# "default" is used.
15-
#
16-
name: "default",
17-
#
18-
# These are the files included in the analysis:
19-
files: %{
20-
#
21-
# You can give explicit globs or simply directories.
22-
# In the latter case `**/*.{ex,exs}` will be used.
23-
included: ["lib/", "src/", "web/", "apps/", "test/"],
24-
excluded: [~r"/_build/", ~r"/deps/"]
25-
},
26-
#
27-
# If you create your own checks, you must specify the source files for
28-
# them here, so they can be loaded by Credo before running the analysis.
29-
#
30-
requires: [],
31-
#
32-
# If you want to enforce a style guide and need a more traditional linting
33-
# experience, you can change `strict` to `true` below:
34-
#
35-
strict: true,
36-
#
37-
# If you want to use uncolored output by default, you can change `color`
38-
# to `false` below:
39-
#
40-
color: true,
41-
#
42-
# You can customize the parameters of any check by adding a second element
43-
# to the tuple.
44-
#
45-
# To disable a check put `false` as second element:
46-
#
47-
# {Credo.Check.Design.DuplicatedCode, false}
48-
#
49-
checks: [
50-
{Credo.Check.Consistency.ExceptionNames},
51-
{Credo.Check.Consistency.LineEndings},
52-
{Credo.Check.Consistency.ParameterPatternMatching},
53-
{Credo.Check.Consistency.SpaceAroundOperators},
54-
{Credo.Check.Consistency.SpaceInParentheses},
55-
{Credo.Check.Consistency.TabsOrSpaces},
56-
57-
# For some checks, like AliasUsage, you can only customize the priority
58-
# Priority values are: `low, normal, high, higher`
59-
#
60-
{Credo.Check.Design.AliasUsage,
61-
if_called_more_often_than: 2, excluded_namespaces: ["Faker"]},
62-
63-
# For others you can set parameters
64-
65-
# If you don't want the `setup` and `test` macro calls in ExUnit tests
66-
# or the `schema` macro in Ecto schemas to trigger DuplicatedCode, just
67-
# set the `excluded_macros` parameter to `[:schema, :setup, :test]`.
68-
#
69-
{Credo.Check.Design.DuplicatedCode, excluded_macros: [], exit_status: 0},
70-
71-
# You can also customize the exit_status of each check.
72-
# If you don't want TODO comments to cause `mix credo` to fail, just
73-
# set this value to 0 (zero).
74-
#
75-
{Credo.Check.Design.TagTODO, exit_status: 0},
76-
{Credo.Check.Design.TagFIXME},
77-
{Credo.Check.Readability.AliasOrder, false},
78-
{Credo.Check.Readability.FunctionNames},
79-
{Credo.Check.Readability.LargeNumbers},
80-
{Credo.Check.Readability.MaxLineLength, max_length: 101},
81-
{Credo.Check.Readability.ModuleAttributeNames},
82-
{Credo.Check.Readability.ModuleDoc},
83-
{Credo.Check.Readability.ModuleNames},
84-
{Credo.Check.Readability.ParenthesesOnZeroArityDefs},
85-
{Credo.Check.Readability.ParenthesesInCondition},
86-
{Credo.Check.Readability.PredicateFunctionNames},
87-
{Credo.Check.Readability.PreferImplicitTry},
88-
{Credo.Check.Readability.RedundantBlankLines},
89-
{Credo.Check.Readability.StringSigils},
90-
{Credo.Check.Readability.TrailingBlankLine},
91-
{Credo.Check.Readability.TrailingWhiteSpace},
92-
{Credo.Check.Readability.VariableNames},
93-
{Credo.Check.Readability.Semicolons},
94-
{Credo.Check.Readability.SpaceAfterCommas},
95-
{Credo.Check.Refactor.DoubleBooleanNegation},
96-
{Credo.Check.Refactor.CondStatements},
97-
{Credo.Check.Refactor.CyclomaticComplexity},
98-
{Credo.Check.Refactor.FunctionArity},
99-
{Credo.Check.Refactor.LongQuoteBlocks},
100-
{Credo.Check.Refactor.MatchInCondition},
101-
{Credo.Check.Refactor.NegatedConditionsInUnless},
102-
{Credo.Check.Refactor.NegatedConditionsWithElse},
103-
{Credo.Check.Refactor.Nesting},
104-
{Credo.Check.Refactor.PipeChainStart},
105-
{Credo.Check.Refactor.UnlessWithElse},
106-
{Credo.Check.Warning.BoolOperationOnSameValues},
107-
{Credo.Check.Warning.IExPry},
108-
{Credo.Check.Warning.IoInspect},
109-
{Credo.Check.Warning.LazyLogging, false},
110-
{Credo.Check.Warning.OperationOnSameValues},
111-
{Credo.Check.Warning.OperationWithConstantResult},
112-
{Credo.Check.Warning.UnusedEnumOperation},
113-
{Credo.Check.Warning.UnusedFileOperation},
114-
{Credo.Check.Warning.UnusedKeywordOperation},
115-
{Credo.Check.Warning.UnusedListOperation},
116-
{Credo.Check.Warning.UnusedPathOperation},
117-
{Credo.Check.Warning.UnusedRegexOperation},
118-
{Credo.Check.Warning.UnusedStringOperation},
119-
{Credo.Check.Warning.UnusedTupleOperation},
120-
{Credo.Check.Warning.RaiseInsideRescue},
121-
122-
# Controversial and experimental checks (opt-in, just remove `, false`)
123-
#
124-
{Credo.Check.Refactor.ABCSize, false},
125-
{Credo.Check.Refactor.AppendSingleItem, false},
126-
{Credo.Check.Refactor.VariableRebinding, false},
127-
{Credo.Check.Warning.MapGetUnsafePass},
128-
{Credo.Check.Consistency.MultiAliasImportRequireUse},
129-
130-
# Deprecated checks (these will be deleted after a grace period)
131-
#
132-
{Credo.Check.Readability.Specs, false},
133-
{Credo.Check.Refactor.MapInto, false}
134-
135-
# Custom checks can be created using `mix credo.gen.check`.
136-
#
137-
]
138-
}
139-
]
140-
}
1+
# This file contains the configuration for Credo and you are probably reading
2+
# this after creating it with `mix credo.gen.config`.
3+
#
4+
# If you find anything wrong or unclear in this file, please report an
5+
# issue on GitHub: https://github.com/rrrene/credo/issues
6+
#
7+
%{
8+
#
9+
# You can have as many configs as you like in the `configs:` field.
10+
configs: [
11+
%{
12+
#
13+
# Run any exec using `mix credo -C <name>`. If no exec name is given
14+
# "default" is used.
15+
#
16+
name: "default",
17+
#
18+
# These are the files included in the analysis:
19+
files: %{
20+
#
21+
# You can give explicit globs or simply directories.
22+
# In the latter case `**/*.{ex,exs}` will be used.
23+
included: ["lib/", "src/", "web/", "apps/", "test/"],
24+
excluded: [~r"/_build/", ~r"/deps/"]
25+
},
26+
#
27+
# If you create your own checks, you must specify the source files for
28+
# them here, so they can be loaded by Credo before running the analysis.
29+
#
30+
requires: [],
31+
#
32+
# If you want to enforce a style guide and need a more traditional linting
33+
# experience, you can change `strict` to `true` below:
34+
#
35+
strict: true,
36+
#
37+
# If you want to use uncolored output by default, you can change `color`
38+
# to `false` below:
39+
#
40+
color: true,
41+
#
42+
# You can customize the parameters of any check by adding a second element
43+
# to the tuple.
44+
#
45+
# To disable a check put `false` as second element:
46+
#
47+
# {Credo.Check.Design.DuplicatedCode, false}
48+
#
49+
checks: [
50+
{Credo.Check.Consistency.ExceptionNames},
51+
{Credo.Check.Consistency.LineEndings},
52+
{Credo.Check.Consistency.ParameterPatternMatching},
53+
{Credo.Check.Consistency.SpaceAroundOperators},
54+
{Credo.Check.Consistency.SpaceInParentheses},
55+
{Credo.Check.Consistency.TabsOrSpaces},
56+
57+
# For some checks, like AliasUsage, you can only customize the priority
58+
# Priority values are: `low, normal, high, higher`
59+
#
60+
{Credo.Check.Design.AliasUsage,
61+
if_called_more_often_than: 2, excluded_namespaces: ["Faker"]},
62+
63+
# For others you can set parameters
64+
65+
# If you don't want the `setup` and `test` macro calls in ExUnit tests
66+
# or the `schema` macro in Ecto schemas to trigger DuplicatedCode, just
67+
# set the `excluded_macros` parameter to `[:schema, :setup, :test]`.
68+
#
69+
{Credo.Check.Design.DuplicatedCode, excluded_macros: [], exit_status: 0},
70+
71+
# You can also customize the exit_status of each check.
72+
# If you don't want TODO comments to cause `mix credo` to fail, just
73+
# set this value to 0 (zero).
74+
#
75+
{Credo.Check.Design.TagTODO, exit_status: 0},
76+
{Credo.Check.Design.TagFIXME},
77+
{Credo.Check.Readability.AliasOrder, false},
78+
{Credo.Check.Readability.FunctionNames},
79+
{Credo.Check.Readability.LargeNumbers},
80+
{Credo.Check.Readability.MaxLineLength, max_length: 101},
81+
{Credo.Check.Readability.ModuleAttributeNames},
82+
{Credo.Check.Readability.ModuleDoc},
83+
{Credo.Check.Readability.ModuleNames},
84+
{Credo.Check.Readability.ParenthesesOnZeroArityDefs},
85+
{Credo.Check.Readability.ParenthesesInCondition},
86+
{Credo.Check.Readability.PredicateFunctionNames},
87+
{Credo.Check.Readability.PreferImplicitTry},
88+
{Credo.Check.Readability.RedundantBlankLines},
89+
{Credo.Check.Readability.StringSigils},
90+
{Credo.Check.Readability.TrailingBlankLine},
91+
{Credo.Check.Readability.TrailingWhiteSpace},
92+
{Credo.Check.Readability.VariableNames},
93+
{Credo.Check.Readability.Semicolons},
94+
{Credo.Check.Readability.SpaceAfterCommas},
95+
{Credo.Check.Refactor.DoubleBooleanNegation},
96+
{Credo.Check.Refactor.CondStatements},
97+
{Credo.Check.Refactor.CyclomaticComplexity},
98+
{Credo.Check.Refactor.FunctionArity},
99+
{Credo.Check.Refactor.LongQuoteBlocks},
100+
{Credo.Check.Refactor.MatchInCondition},
101+
{Credo.Check.Refactor.NegatedConditionsInUnless},
102+
{Credo.Check.Refactor.NegatedConditionsWithElse},
103+
{Credo.Check.Refactor.Nesting},
104+
{Credo.Check.Refactor.PipeChainStart},
105+
{Credo.Check.Refactor.UnlessWithElse},
106+
{Credo.Check.Warning.BoolOperationOnSameValues},
107+
{Credo.Check.Warning.IExPry},
108+
{Credo.Check.Warning.IoInspect},
109+
{Credo.Check.Warning.LazyLogging, false},
110+
{Credo.Check.Warning.OperationOnSameValues},
111+
{Credo.Check.Warning.OperationWithConstantResult},
112+
{Credo.Check.Warning.UnusedEnumOperation},
113+
{Credo.Check.Warning.UnusedFileOperation},
114+
{Credo.Check.Warning.UnusedKeywordOperation},
115+
{Credo.Check.Warning.UnusedListOperation},
116+
{Credo.Check.Warning.UnusedPathOperation},
117+
{Credo.Check.Warning.UnusedRegexOperation},
118+
{Credo.Check.Warning.UnusedStringOperation},
119+
{Credo.Check.Warning.UnusedTupleOperation},
120+
{Credo.Check.Warning.RaiseInsideRescue},
121+
122+
# Controversial and experimental checks (opt-in, just remove `, false`)
123+
#
124+
{Credo.Check.Refactor.ABCSize, false},
125+
{Credo.Check.Refactor.AppendSingleItem, false},
126+
{Credo.Check.Refactor.VariableRebinding, false},
127+
{Credo.Check.Warning.MapGetUnsafePass},
128+
{Credo.Check.Consistency.MultiAliasImportRequireUse},
129+
130+
# Deprecated checks (these will be deleted after a grace period)
131+
#
132+
{Credo.Check.Readability.Specs, false},
133+
{Credo.Check.Refactor.MapInto, false}
134+
135+
# Custom checks can be created using `mix credo.gen.check`.
136+
#
137+
]
138+
}
139+
]
140+
}

lib/cadet/accounts/notification.ex

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
1-
defmodule Cadet.Accounts.Notification do
2-
@moduledoc """
3-
The Notification entity represents a notification.
4-
It stores information pertaining to the type of notification and who in which course it belongs to.
5-
Each notification can have an assessment id or submission id, with optional question id.
6-
This will be used to pinpoint where the notification will be showed on the frontend.
7-
"""
8-
use Cadet, :model
9-
10-
alias Cadet.Accounts.{NotificationType, Role, CourseRegistration}
11-
alias Cadet.Assessments.{Assessment, Submission}
12-
13-
schema "notifications" do
14-
field(:type, NotificationType)
15-
field(:read, :boolean, default: false)
16-
field(:role, Role, virtual: true)
17-
18-
belongs_to(:course_reg, CourseRegistration)
19-
belongs_to(:assessment, Assessment)
20-
belongs_to(:submission, Submission)
21-
22-
timestamps()
23-
end
24-
25-
@required_fields ~w(type read course_reg_id assessment_id)a
26-
@optional_fields ~w(submission_id)a
27-
28-
def changeset(answer, params) do
29-
answer
30-
|> cast(params, @required_fields ++ @optional_fields)
31-
|> validate_required(@required_fields)
32-
|> foreign_key_constraint(:course_reg_id)
33-
|> foreign_key_constraint(:assessment_id)
34-
|> foreign_key_constraint(:submission_id)
35-
end
36-
end
1+
defmodule Cadet.Accounts.Notification do
2+
@moduledoc """
3+
The Notification entity represents a notification.
4+
It stores information pertaining to the type of notification and who in which course it belongs to.
5+
Each notification can have an assessment id or submission id, with optional question id.
6+
This will be used to pinpoint where the notification will be showed on the frontend.
7+
"""
8+
use Cadet, :model
9+
10+
alias Cadet.Accounts.{NotificationType, Role, CourseRegistration}
11+
alias Cadet.Assessments.{Assessment, Submission}
12+
13+
schema "notifications" do
14+
field(:type, NotificationType)
15+
field(:read, :boolean, default: false)
16+
field(:role, Role, virtual: true)
17+
18+
belongs_to(:course_reg, CourseRegistration)
19+
belongs_to(:assessment, Assessment)
20+
belongs_to(:submission, Submission)
21+
22+
timestamps()
23+
end
24+
25+
@required_fields ~w(type read course_reg_id assessment_id)a
26+
@optional_fields ~w(submission_id)a
27+
28+
def changeset(answer, params) do
29+
answer
30+
|> cast(params, @required_fields ++ @optional_fields)
31+
|> validate_required(@required_fields)
32+
|> foreign_key_constraint(:course_reg_id)
33+
|> foreign_key_constraint(:assessment_id)
34+
|> foreign_key_constraint(:submission_id)
35+
end
36+
end

0 commit comments

Comments
 (0)