Skip to content

Commit 94e12de

Browse files
authored
Merge pull request #1856 from openstax/video-task-steps
include content in video task steps
2 parents d2714eb + 49ca4a4 commit 94e12de

File tree

5 files changed

+25
-5
lines changed

5 files changed

+25
-5
lines changed

app/controllers/api/v1/task_steps_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def update
4040
user_options: {include_content: true} # needed so representer will consume free_response
4141
)
4242
@tasked.save
43+
raise(ActiveRecord::Rollback) if render_api_errors(@tasked.errors)
4344

4445
result = MarkTaskStepCompleted.call(task_step: @task_step, lock_task: true)
4546
raise(ActiveRecord::Rollback) if render_api_errors(result.errors)

app/representers/api/v1/tasks/tasked_interactive_representer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class TaskedInteractiveRepresenter < TaskStepRepresenter
3636
readable: true,
3737
schema_info: {
3838
required: false,
39-
description: "The content preview for reading tasked"
39+
description: "The complete content for interactive tasked"
4040
},
4141
if: INCLUDE_CONTENT
4242
end

app/representers/api/v1/tasks/tasked_video_representer.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,16 @@ class TaskedVideoRepresenter < TaskStepRepresenter
2727
required: false,
2828
description: "The content preview for video tasked"
2929
}
30+
31+
property :content,
32+
as: :html,
33+
type: String,
34+
writeable: false,
35+
readable: true,
36+
schema_info: {
37+
required: false,
38+
description: "The complete content for video tasked"
39+
},
40+
if: INCLUDE_CONTENT
3041
end
3142
end

spec/representers/api/v1/tasks/tasked_exercise_representer_spec.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
allow(step).to receive(:feedback_available?).and_return(false)
1010
allow(step).to receive(:labels).and_return([])
1111
allow(step).to receive(:related_content).and_return('RelatedContent')
12-
allow(step).to receive(:spy).and_return(garbage_estimate: { valid: false })
1312
allow(step).to receive(:spy).and_return(response_validation: { valid: false })
1413
end
1514
end
@@ -85,9 +84,8 @@
8584
expect(complete_representation).to include("labels")
8685
end
8786

88-
it "has 'spy'" do
89-
expect(complete_representation).to include("spy" => { garbage_estimate: { valid: false }})
90-
expect(representation).to include("spy" => {"response_validation"=>{"valid"=>false}})
87+
it "have 'spy'" do
88+
expect(complete_representation).to include("spy" => { response_validation: { valid: false }})
9189
end
9290
end
9391

spec/representers/api/v1/tasks/tasked_video_representer_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,14 @@
1414
}.stringify_keys)
1515
end
1616

17+
it "has additional content fields" do
18+
task_step = FactoryBot.create(:tasks_tasked_reading).task_step
19+
json = Api::V1::Tasks::TaskedVideoRepresenter.new(task_step.tasked).to_json(
20+
user_options: { include_content: true }
21+
)
22+
expect(JSON.parse(json)).to include({
23+
html: task_step.tasked.content,
24+
}.stringify_keys)
25+
end
26+
1727
end

0 commit comments

Comments
 (0)