Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions lib/cadet/assessments/grading/grading.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
defmodule Cadet.Assessments.Grading do
@moduledoc """
The Grading represents the Grading of a Submission by a Student.
"""
use Ecto.Schema
alias Cadet.Assessments.GradingInfo

import Ecto.Changeset

schema "gradings" do
embeds_many(:grading_infos, GradingInfo)

timestamps()
end

@required_fields ~w(weight marks grading_infos)a
@optional_fields ~w(comment)

def changeset(answer, params \\ %{}) do
answer
|> cast(params, @required_fields ++ @optional_fields)
|> cast_embed(:grading_infos, with: &GradingInfo.changeset/2, required: true)
|> validate_required(@required_fields)
end
end
25 changes: 25 additions & 0 deletions lib/cadet/assessments/grading/grading_info.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
defmodule Cadet.Assessments.GradingInfo do
@moduledoc """
The GradingInfo represents the Grading of a particular
ProgrammingQuestion.
"""
use Ecto.Schema

import Ecto.Changeset

embedded_schema do
field(:marks, :integer)
field(:comment, :string)
# TODO add once assessments is merged
# belongs_to(:question, Assessments.Question)
end

# TODO add :question once assessments is merged
@required_fields ~w(marks comment)a

def changeset(grading_info, params \\ %{}) do
grading_info
|> cast(params, @required_fields)
|> validate_required(@required_fields)
end
end
33 changes: 17 additions & 16 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -41,30 +41,31 @@ defmodule Cadet.Mixfile do
# Type `mix help deps` for examples and options.
defp deps do
[
{:phoenix, "~> 1.3.0"},
{:phoenix_pubsub, "~> 1.0"},
{:phoenix_ecto, "~> 3.2"},
{:postgrex, ">= 0.0.0"},
{:phoenix_html, "~> 2.10"},
{:gettext, "~> 0.11"},
{:arc, "~> 0.8.0"},
{:arc_ecto, "~> 0.7.0"},
{:comeonin, "~> 4.0"},
{:cowboy, "~> 1.0"},
{:dotenv, "~> 2.0.0"},
{:ecto_enum, "~> 1.0"},
{:ex_json_schema, "~> 0.5"},
{:ex_machina, "~> 2.1"},
{:pbkdf2_elixir, "~> 0.12"},
{:comeonin, "~> 4.0"},
{:gettext, "~> 0.11"},
{:guardian, "~> 1.0"},
{:guardian_db, "~> 1.0"},
{:phoenix_live_reload, "~> 1.0", only: :dev},
{:credo, "~> 0.8", only: [:dev, :test], runtime: false},
{:excoveralls, "~> 0.8", only: :test},
{:dialyxir, "~> 0.5", only: [:dev, :test], runtime: false},
{:arc, "~> 0.8.0"},
{:arc_ecto, "~> 0.7.0"},
{:httpoison, "~> 1.0", override: true},
{:pbkdf2_elixir, "~> 0.12"},
{:phoenix, "~> 1.3.0"},
{:phoenix_ecto, "~> 3.2"},
{:phoenix_html, "~> 2.10"},
{:phoenix_pubsub, "~> 1.0"},
{:phoenix_swagger, "~> 0.8"},
{:postgrex, ">= 0.0.0"},
{:timex, "~> 3.0"},
{:timex_ecto, "~> 3.0"},
{:phoenix_swagger, "~> 0.8"},
{:ex_json_schema, "~> 0.5"},
{:credo, "~> 0.8", only: [:dev, :test], runtime: false},
{:dialyxir, "~> 0.5", only: [:dev, :test], runtime: false},
{:excoveralls, "~> 0.8", only: :test},
{:phoenix_live_reload, "~> 1.0", only: :dev},
{:pre_commit, "~> 0.3.4", only: [:dev, :test]}
]
end
Expand Down
9 changes: 5 additions & 4 deletions mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"arc_ecto": {:hex, :arc_ecto, "0.7.0", "428ed7ea4ed0be8996d8fc6e9f651d3e26fe9c9063f26cbf6731c865369845d3", [:mix], [{:arc, "~> 0.8.0", [hex: :arc, repo: "hexpm", optional: false]}, {:ecto, "~> 2.0", [hex: :ecto, repo: "hexpm", optional: false]}], "hexpm"},
"base64url": {:hex, :base64url, "0.0.1", "36a90125f5948e3afd7be97662a1504b934dd5dac78451ca6e9abf85a10286be", [:rebar], [], "hexpm"},
"bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm"},
"certifi": {:hex, :certifi, "2.0.0", "a0c0e475107135f76b8c1d5bc7efb33cd3815cb3cf3dea7aefdd174dabead064", [:rebar3], [], "hexpm"},
"certifi": {:hex, :certifi, "2.3.1", "d0f424232390bf47d82da8478022301c561cf6445b5b5fb6a84d49a9e76d2639", [:rebar3], [{:parse_trans, "3.2.0", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm"},
"combine": {:hex, :combine, "0.10.0", "eff8224eeb56498a2af13011d142c5e7997a80c8f5b97c499f84c841032e429f", [:mix], [], "hexpm"},
"comeonin": {:hex, :comeonin, "4.0.3", "4e257dcb748ed1ca2651b7ba24fdbd1bd24efd12482accf8079141e3fda23a10", [:mix], [{:argon2_elixir, "~> 1.2", [hex: :argon2_elixir, repo: "hexpm", optional: true]}, {:bcrypt_elixir, "~> 0.12.1 or ~> 1.0", [hex: :bcrypt_elixir, repo: "hexpm", optional: true]}, {:pbkdf2_elixir, "~> 0.12", [hex: :pbkdf2_elixir, repo: "hexpm", optional: true]}], "hexpm"},
"connection": {:hex, :connection, "1.0.4", "a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976", [:mix], [], "hexpm"},
Expand All @@ -24,14 +24,15 @@
"gettext": {:hex, :gettext, "0.13.1", "5e0daf4e7636d771c4c71ad5f3f53ba09a9ae5c250e1ab9c42ba9edccc476263", [], [], "hexpm"},
"guardian": {:hex, :guardian, "1.0.1", "db0fbaf571c3b874785818b7272eaf5f1ed97a2f9b1f8bc5dc8b0fb8f8f7bb06", [], [{:jose, "~> 1.8", [hex: :jose, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.0 or ~> 1.2 or ~> 1.3", [hex: :phoenix, repo: "hexpm", optional: true]}, {:plug, "~> 1.3.3 or ~> 1.4", [hex: :plug, repo: "hexpm", optional: true]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: false]}, {:uuid, ">= 1.1.1", [hex: :uuid, repo: "hexpm", optional: false]}], "hexpm"},
"guardian_db": {:hex, :guardian_db, "1.1.0", "45ab94206cce38f7443dc27de6dc52966ccbdeff65ca1b1f11a6d8f3daceb556", [:mix], [{:ecto, "~> 2.2", [hex: :ecto, repo: "hexpm", optional: false]}, {:guardian, "~> 1.0", [hex: :guardian, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.13", [hex: :postgrex, repo: "hexpm", optional: true]}], "hexpm"},
"hackney": {:hex, :hackney, "1.10.1", "c38d0ca52ea80254936a32c45bb7eb414e7a96a521b4ce76d00a69753b157f21", [], [{:certifi, "2.0.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "5.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"},
"httpoison": {:hex, :httpoison, "0.13.0", "bfaf44d9f133a6599886720f3937a7699466d23bb0cd7a88b6ba011f53c6f562", [], [{:hackney, "~> 1.8", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"},
"idna": {:hex, :idna, "5.1.0", "d72b4effeb324ad5da3cab1767cb16b17939004e789d8c0ad5b70f3cea20c89a", [], [{:unicode_util_compat, "0.3.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"},
"hackney": {:hex, :hackney, "1.12.1", "8bf2d0e11e722e533903fe126e14d6e7e94d9b7983ced595b75f532e04b7fdc7", [:rebar3], [{:certifi, "2.3.1", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "5.1.1", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"},
"httpoison": {:hex, :httpoison, "1.1.1", "96ed7ab79f78a31081bb523eefec205fd2900a02cda6dbc2300e7a1226219566", [:mix], [{:hackney, "~> 1.8", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"},
"idna": {:hex, :idna, "5.1.1", "cbc3b2fa1645113267cc59c760bafa64b2ea0334635ef06dbac8801e42f7279c", [:rebar3], [{:unicode_util_compat, "0.3.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"},
"jose": {:hex, :jose, "1.8.4", "7946d1e5c03a76ac9ef42a6e6a20001d35987afd68c2107bcd8f01a84e75aa73", [], [{:base64url, "~> 0.0.1", [hex: :base64url, repo: "hexpm", optional: false]}], "hexpm"},
"jsx": {:hex, :jsx, "2.8.3", "a05252d381885240744d955fbe3cf810504eb2567164824e19303ea59eef62cf", [], [], "hexpm"},
"metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [], [], "hexpm"},
"mime": {:hex, :mime, "1.1.0", "01c1d6f4083d8aa5c7b8c246ade95139620ef8effb009edde934e0ec3b28090a", [], [], "hexpm"},
"mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [], [], "hexpm"},
"parse_trans": {:hex, :parse_trans, "3.2.0", "2adfa4daf80c14dc36f522cf190eb5c4ee3e28008fc6394397c16f62a26258c2", [:rebar3], [], "hexpm"},
"pbkdf2_elixir": {:hex, :pbkdf2_elixir, "0.12.3", "6706a148809a29c306062862c803406e88f048277f6e85b68faf73291e820b84", [], [], "hexpm"},
"phoenix": {:hex, :phoenix, "1.3.0", "1c01124caa1b4a7af46f2050ff11b267baa3edb441b45dbf243e979cd4c5891b", [], [{:cowboy, "~> 1.0", [hex: :cowboy, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 1.0", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:plug, "~> 1.3.3 or ~> 1.4", [hex: :plug, repo: "hexpm", optional: false]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"},
"phoenix_ecto": {:hex, :phoenix_ecto, "3.3.0", "702f6e164512853d29f9d20763493f2b3bcfcb44f118af2bc37bb95d0801b480", [], [{:ecto, "~> 2.1", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.9", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"},
Expand Down
11 changes: 11 additions & 0 deletions priv/repo/migrations/20180613114758_create_gradings.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
defmodule Cadet.Repo.Migrations.CreateGradings do
use Ecto.Migration

def change do
create table(:gradings) do
add(:grading_infos, :map)

timestamps()
end
end
end
1 change: 0 additions & 1 deletion test/cadet/assessments/submission_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ defmodule Cadet.Assessments.SubmissionTest do
override_xp: 100
}
end

end