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
4 changes: 3 additions & 1 deletion lib/cadet/courses/assessment_config.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ defmodule Cadet.Courses.AssessmentConfig do
field(:early_submission_xp, :integer, default: 0)
field(:hours_before_early_xp_decay, :integer, default: 0)
field(:is_grading_auto_published, :boolean, default: false)
# marks an assessment type as a minigame (with different submission and testcase behaviour)
field(:is_minigame, :boolean, default: false)

belongs_to(:course, Course)

Expand All @@ -26,7 +28,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 has_voting_features has_token_counter is_grading_auto_published)a
hours_before_early_xp_decay show_grading_summary is_manually_graded has_voting_features has_token_counter is_grading_auto_published is_minigame)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 @@ -10,6 +10,7 @@ defmodule CadetWeb.AdminCoursesView do
assessmentConfigId: :id,
type: :type,
displayInDashboard: :show_grading_summary,
isMinigame: :is_minigame,
isManuallyGraded: :is_manually_graded,
earlySubmissionXp: :early_submission_xp,
hasVotingFeatures: :has_voting_features,
Expand Down
1 change: 1 addition & 0 deletions lib/cadet_web/views/assessments_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ defmodule CadetWeb.AssessmentsView do
longSummary: :summary_long,
hasTokenCounter: :has_token_counter,
missionPDF: &Cadet.Assessments.Upload.url({&1.mission_pdf, &1}),
isMinigame: & &1.config.is_minigame,
questions:
&Enum.map(&1.questions, fn question ->
map =
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 @@ -124,6 +124,7 @@ defmodule CadetWeb.UserView do
assessmentConfigId: :id,
type: :type,
displayInDashboard: :show_grading_summary,
isMinigame: :is_minigame,
isManuallyGraded: :is_manually_graded,
hasVotingFeatures: :has_voting_features,
hasTokenCounter: :has_token_counter,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
defmodule Cadet.Repo.Migrations.AddIsMinigameToAssessmentConfig do
use Ecto.Migration

def change do
alter table(:assessment_configs) do
add(:is_minigame, :boolean, default: false)
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ defmodule CadetWeb.AdminCoursesControllerTest do
"earlySubmissionXp" => 200,
"hoursBeforeEarlyXpDecay" => 48,
"displayInDashboard" => true,
"isMinigame" => false,
"isManuallyGraded" => true,
"type" => "Mission1",
"assessmentConfigId" => config1.id,
Expand All @@ -200,6 +201,7 @@ defmodule CadetWeb.AdminCoursesControllerTest do
"earlySubmissionXp" => 200,
"hoursBeforeEarlyXpDecay" => 48,
"displayInDashboard" => false,
"isMinigame" => false,
"isManuallyGraded" => false,
"type" => "Mission2",
"assessmentConfigId" => config2.id,
Expand All @@ -211,6 +213,7 @@ defmodule CadetWeb.AdminCoursesControllerTest do
"earlySubmissionXp" => 200,
"hoursBeforeEarlyXpDecay" => 48,
"displayInDashboard" => true,
"isMinigame" => false,
"isManuallyGraded" => true,
"type" => "Mission3",
"assessmentConfigId" => config3.id,
Expand Down
3 changes: 2 additions & 1 deletion test/cadet_web/controllers/assessments_controller_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,8 @@ defmodule CadetWeb.AssessmentsControllerTest do
"reading" => assessment.reading,
"longSummary" => assessment.summary_long,
"hasTokenCounter" => assessment.has_token_counter,
"missionPDF" => Cadet.Assessments.Upload.url({assessment.mission_pdf, assessment})
"missionPDF" => Cadet.Assessments.Upload.url({assessment.mission_pdf, assessment}),
"isMinigame" => false
}

resp_assessments =
Expand Down
3 changes: 3 additions & 0 deletions test/cadet_web/controllers/user_controller_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ defmodule CadetWeb.UserControllerTest do
%{
"type" => "test type 1",
"displayInDashboard" => true,
"isMinigame" => false,
"isManuallyGraded" => true,
"assessmentConfigId" => config1.id,
"earlySubmissionXp" => 200,
Expand All @@ -131,6 +132,7 @@ defmodule CadetWeb.UserControllerTest do
%{
"type" => "test type 2",
"displayInDashboard" => true,
"isMinigame" => false,
"isManuallyGraded" => true,
"assessmentConfigId" => config2.id,
"earlySubmissionXp" => 200,
Expand All @@ -142,6 +144,7 @@ defmodule CadetWeb.UserControllerTest do
%{
"type" => "test type 3",
"displayInDashboard" => true,
"isMinigame" => false,
"isManuallyGraded" => true,
"assessmentConfigId" => config3.id,
"earlySubmissionXp" => 200,
Expand Down
Loading