Skip to content

Commit 5c7b5cf

Browse files
authored
Add on_finish field to assessments (#1239)
* Add on_finish to assessments * Rewrite on_finish as separate migration * Update tests to expect onFinish field in assessments * Fix migration and expected assessment * onFinishSubmitAndReturnToGame is now boolean and in assessment_configs * Remove extra comma in assessment_configs optional_fields * Update onFinish tag in tests * Rename on_finish_submit_and_return_to_game to is_minigame * Update tests and register isMinigame inputs from frontend admin panel * Add comment describing :is_minigame * Remove .tool-versions
1 parent 6586c6e commit 5c7b5cf

File tree

8 files changed

+23
-2
lines changed

8 files changed

+23
-2
lines changed

lib/cadet/courses/assessment_config.ex

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ defmodule Cadet.Courses.AssessmentConfig do
1818
field(:early_submission_xp, :integer, default: 0)
1919
field(:hours_before_early_xp_decay, :integer, default: 0)
2020
field(:is_grading_auto_published, :boolean, default: false)
21+
# marks an assessment type as a minigame (with different submission and testcase behaviour)
22+
field(:is_minigame, :boolean, default: false)
2123

2224
belongs_to(:course, Course)
2325

@@ -26,7 +28,7 @@ defmodule Cadet.Courses.AssessmentConfig do
2628

2729
@required_fields ~w(course_id)a
2830
@optional_fields ~w(order type early_submission_xp
29-
hours_before_early_xp_decay show_grading_summary is_manually_graded has_voting_features has_token_counter is_grading_auto_published)a
31+
hours_before_early_xp_decay show_grading_summary is_manually_graded has_voting_features has_token_counter is_grading_auto_published is_minigame)a
3032

3133
def changeset(assessment_config, params) do
3234
assessment_config

lib/cadet_web/admin_views/admin_courses_view.ex

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ defmodule CadetWeb.AdminCoursesView do
1010
assessmentConfigId: :id,
1111
type: :type,
1212
displayInDashboard: :show_grading_summary,
13+
isMinigame: :is_minigame,
1314
isManuallyGraded: :is_manually_graded,
1415
earlySubmissionXp: :early_submission_xp,
1516
hasVotingFeatures: :has_voting_features,

lib/cadet_web/views/assessments_view.ex

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ defmodule CadetWeb.AssessmentsView do
5353
longSummary: :summary_long,
5454
hasTokenCounter: :has_token_counter,
5555
missionPDF: &Cadet.Assessments.Upload.url({&1.mission_pdf, &1}),
56+
isMinigame: & &1.config.is_minigame,
5657
questions:
5758
&Enum.map(&1.questions, fn question ->
5859
map =

lib/cadet_web/views/user_view.ex

+1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ defmodule CadetWeb.UserView do
124124
assessmentConfigId: :id,
125125
type: :type,
126126
displayInDashboard: :show_grading_summary,
127+
isMinigame: :is_minigame,
127128
isManuallyGraded: :is_manually_graded,
128129
hasVotingFeatures: :has_voting_features,
129130
hasTokenCounter: :has_token_counter,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
defmodule Cadet.Repo.Migrations.AddIsMinigameToAssessmentConfig do
2+
use Ecto.Migration
3+
4+
def change do
5+
alter table(:assessment_configs) do
6+
add(:is_minigame, :boolean, default: false)
7+
end
8+
end
9+
end

test/cadet_web/admin_controllers/admin_courses_controller_test.exs

+3
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ defmodule CadetWeb.AdminCoursesControllerTest do
189189
"earlySubmissionXp" => 200,
190190
"hoursBeforeEarlyXpDecay" => 48,
191191
"displayInDashboard" => true,
192+
"isMinigame" => false,
192193
"isManuallyGraded" => true,
193194
"type" => "Mission1",
194195
"assessmentConfigId" => config1.id,
@@ -200,6 +201,7 @@ defmodule CadetWeb.AdminCoursesControllerTest do
200201
"earlySubmissionXp" => 200,
201202
"hoursBeforeEarlyXpDecay" => 48,
202203
"displayInDashboard" => false,
204+
"isMinigame" => false,
203205
"isManuallyGraded" => false,
204206
"type" => "Mission2",
205207
"assessmentConfigId" => config2.id,
@@ -211,6 +213,7 @@ defmodule CadetWeb.AdminCoursesControllerTest do
211213
"earlySubmissionXp" => 200,
212214
"hoursBeforeEarlyXpDecay" => 48,
213215
"displayInDashboard" => true,
216+
"isMinigame" => false,
214217
"isManuallyGraded" => true,
215218
"type" => "Mission3",
216219
"assessmentConfigId" => config3.id,

test/cadet_web/controllers/assessments_controller_test.exs

+2-1
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,8 @@ defmodule CadetWeb.AssessmentsControllerTest do
327327
"reading" => assessment.reading,
328328
"longSummary" => assessment.summary_long,
329329
"hasTokenCounter" => assessment.has_token_counter,
330-
"missionPDF" => Cadet.Assessments.Upload.url({assessment.mission_pdf, assessment})
330+
"missionPDF" => Cadet.Assessments.Upload.url({assessment.mission_pdf, assessment}),
331+
"isMinigame" => false
331332
}
332333

333334
resp_assessments =

test/cadet_web/controllers/user_controller_test.exs

+3
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ defmodule CadetWeb.UserControllerTest do
120120
%{
121121
"type" => "test type 1",
122122
"displayInDashboard" => true,
123+
"isMinigame" => false,
123124
"isManuallyGraded" => true,
124125
"assessmentConfigId" => config1.id,
125126
"earlySubmissionXp" => 200,
@@ -131,6 +132,7 @@ defmodule CadetWeb.UserControllerTest do
131132
%{
132133
"type" => "test type 2",
133134
"displayInDashboard" => true,
135+
"isMinigame" => false,
134136
"isManuallyGraded" => true,
135137
"assessmentConfigId" => config2.id,
136138
"earlySubmissionXp" => 200,
@@ -142,6 +144,7 @@ defmodule CadetWeb.UserControllerTest do
142144
%{
143145
"type" => "test type 3",
144146
"displayInDashboard" => true,
147+
"isMinigame" => false,
145148
"isManuallyGraded" => true,
146149
"assessmentConfigId" => config3.id,
147150
"earlySubmissionXp" => 200,

0 commit comments

Comments
 (0)