Skip to content

Commit 03f657c

Browse files
authored
add source versions (#912)
* add source versions * fix format
1 parent cb91f7e commit 03f657c

File tree

4 files changed

+28
-6
lines changed

4 files changed

+28
-6
lines changed

lib/cadet/assessments/library.ex

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,14 @@ defmodule Cadet.Assessments.Library do
5555
@valid_chapter_variants [
5656
{1, "wasm"},
5757
{1, "lazy"},
58+
{1, "native"},
5859
{2, "lazy"},
60+
{2, "native"},
5961
{3, "concurrent"},
6062
{3, "non-det"},
61-
{4, "gpu"}
63+
{3, "native"},
64+
{4, "gpu"},
65+
{4, "native"}
6266
]
6367

6468
defp validate_chapter_variant(changeset) do

lib/cadet/courses/course.ex

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,21 @@ defmodule Cadet.Courses.Course do
5959
{true, true} ->
6060
case get_field(changeset, :source_chapter) do
6161
1 ->
62-
validate_inclusion(changeset, :source_variant, ["default", "lazy", "wasm"])
62+
validate_inclusion(changeset, :source_variant, ["default", "lazy", "wasm", "native"])
6363

6464
2 ->
65-
validate_inclusion(changeset, :source_variant, ["default", "lazy"])
65+
validate_inclusion(changeset, :source_variant, ["default", "lazy", "native"])
6666

6767
3 ->
68-
validate_inclusion(changeset, :source_variant, ["default", "concurrent", "non-det"])
68+
validate_inclusion(changeset, :source_variant, [
69+
"default",
70+
"concurrent",
71+
"non-det",
72+
"native"
73+
])
6974

7075
4 ->
71-
validate_inclusion(changeset, :source_variant, ["default", "gpu"])
76+
validate_inclusion(changeset, :source_variant, ["default", "gpu", "native"])
7277

7378
_ ->
7479
add_error(changeset, :source_chapter, "is invalid")

test/cadet/assessments/library_test.exs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,17 @@ defmodule Cadet.Assessments.LibraryTest do
4040
{1, "default"},
4141
{1, "wasm"},
4242
{1, "lazy"},
43+
{1, "native"},
4344
{2, "default"},
4445
{2, "lazy"},
46+
{2, "native"},
4547
{3, "default"},
4648
{3, "concurrent"},
4749
{3, "non-det"},
50+
{3, "native"},
4851
{4, "default"},
49-
{4, "gpu"}
52+
{4, "gpu"},
53+
{4, "native"}
5054
]
5155

5256
for {c, v} <- variants do

test/cadet/courses/course_test.exs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,15 @@ defmodule Cadet.Courses.CourseTest do
123123
:valid
124124
)
125125

126+
assert_changeset(
127+
%{
128+
source_chapter: 3,
129+
source_variant: "native",
130+
course_name: "Data Structures and Algorithms"
131+
},
132+
:valid
133+
)
134+
126135
assert_changeset(
127136
%{
128137
source_chapter: 4,

0 commit comments

Comments
 (0)