Skip to content
Merged
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
5 changes: 3 additions & 2 deletions lib/cadet/courses/assessment_config.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ defmodule Cadet.Courses.AssessmentConfig do
field(:type, :string)
field(:show_grading_summary, :boolean, default: true)
field(:is_manually_graded, :boolean, default: true)
# used by fronend to determine display styles
field(:has_token_counter, :boolean, default: false)
# used by frontend to determine display styles
field(:early_submission_xp, :integer, default: 0)
field(:hours_before_early_xp_decay, :integer, default: 0)

Expand All @@ -23,7 +24,7 @@ defmodule Cadet.Courses.AssessmentConfig do

@required_fields ~w(course_id)a
@optional_fields ~w(order type early_submission_xp
hours_before_early_xp_decay show_grading_summary is_manually_graded)a
hours_before_early_xp_decay show_grading_summary is_manually_graded has_token_counter)a

def changeset(assessment_config, params) do
assessment_config
Expand Down
1 change: 1 addition & 0 deletions lib/cadet_web/admin_views/admin_courses_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ defmodule CadetWeb.AdminCoursesView do
displayInDashboard: :show_grading_summary,
isManuallyGraded: :is_manually_graded,
earlySubmissionXp: :early_submission_xp,
hasTokenCounter: :has_token_counter,
hoursBeforeEarlyXpDecay: :hours_before_early_xp_decay
})
end
Expand Down
1 change: 1 addition & 0 deletions lib/cadet_web/views/user_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ defmodule CadetWeb.UserView do
type: :type,
displayInDashboard: :show_grading_summary,
isManuallyGraded: :is_manually_graded,
hasTokenCounter: :has_token_counter,
earlySubmissionXp: :early_submission_xp,
hoursBeforeEarlyXpDecay: :hours_before_early_xp_decay
})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
defmodule Cadet.Repo.Migrations.AddHasTokenCounterToggleToAssessmentConfig do
use Ecto.Migration

def up do
alter table(:assessment_configs) do
add(:has_token_counter, :boolean, null: false, default: false)
end
end

def down do
alter table(:assessment_configs) do
remove(:has_token_counter)
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ defmodule CadetWeb.AdminCoursesControllerTest do
is_manually_graded: false,
order: 2,
type: "Mission2",
course: course
course: course,
has_token_counter: true
})

resp =
Expand All @@ -172,23 +173,26 @@ defmodule CadetWeb.AdminCoursesControllerTest do
"displayInDashboard" => true,
"isManuallyGraded" => true,
"type" => "Mission1",
"assessmentConfigId" => config1.id
"assessmentConfigId" => config1.id,
"hasTokenCounter" => false
},
%{
"earlySubmissionXp" => 200,
"hoursBeforeEarlyXpDecay" => 48,
"displayInDashboard" => false,
"isManuallyGraded" => false,
"type" => "Mission2",
"assessmentConfigId" => config2.id
"assessmentConfigId" => config2.id,
"hasTokenCounter" => true
},
%{
"earlySubmissionXp" => 200,
"hoursBeforeEarlyXpDecay" => 48,
"displayInDashboard" => true,
"isManuallyGraded" => true,
"type" => "Mission3",
"assessmentConfigId" => config3.id
"assessmentConfigId" => config3.id,
"hasTokenCounter" => false
}
]

Expand Down
9 changes: 6 additions & 3 deletions test/cadet_web/controllers/user_controller_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -122,23 +122,26 @@ defmodule CadetWeb.UserControllerTest do
"isManuallyGraded" => true,
"assessmentConfigId" => config1.id,
"earlySubmissionXp" => 200,
"hoursBeforeEarlyXpDecay" => 48
"hoursBeforeEarlyXpDecay" => 48,
"hasTokenCounter" => false
},
%{
"type" => "test type 2",
"displayInDashboard" => true,
"isManuallyGraded" => true,
"assessmentConfigId" => config2.id,
"earlySubmissionXp" => 200,
"hoursBeforeEarlyXpDecay" => 48
"hoursBeforeEarlyXpDecay" => 48,
"hasTokenCounter" => false
},
%{
"type" => "test type 3",
"displayInDashboard" => true,
"isManuallyGraded" => true,
"assessmentConfigId" => config3.id,
"earlySubmissionXp" => 200,
"hoursBeforeEarlyXpDecay" => 48
"hoursBeforeEarlyXpDecay" => 48,
"hasTokenCounter" => false
}
]
}
Expand Down