Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add supports_researchers flag to external reports [PT-187221928] #1242

Merged
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
2 changes: 1 addition & 1 deletion rails/app/assets/javascripts/react-components.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion rails/app/controllers/admin/external_reports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def destroy
def external_report_strong_params(params)
params && params.permit(:allowed_for_students, :client, :client_id, :default_report_for_source_type,
:individual_activity_reportable, :individual_student_reportable, :launch_text,
:move_students_api_token, :move_students_api_url, :name, :report_type, :url, :use_query_jwt)
:move_students_api_token, :move_students_api_url, :name, :report_type, :url,
:use_query_jwt, :supports_researchers)
end
end
3 changes: 2 additions & 1 deletion rails/app/models/api/v1/offering.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ def report_attributes(report, offering, protocol, host_with_port)
id: report.id,
name: report.name,
url: portal_external_report_url(id: offering.id, report_id: report.id, protocol: protocol, host: host_with_port),
launch_text: report.launch_text
launch_text: report.launch_text,
supports_researchers: report.supports_researchers
}
end

Expand Down
7 changes: 7 additions & 0 deletions rails/app/views/admin/external_reports/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@
%p
Submit a JWT containing the query to the report. If unchecked, the result of the query will be sent instead.
(Learner researcher reports only.)
%li
%label
= f.check_box :supports_researchers
Support anonymized researcher views
%br
%p
Show report in researcher assignments table. If unchecked, the report will not be available to researchers.
%li
%label
Move Students API URL
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddResearcherOptionToExternalReports < ActiveRecord::Migration[6.1]
def change
add_column :external_reports, :supports_researchers, :boolean, :default => false
end
end
3 changes: 2 additions & 1 deletion rails/db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2023_07_20_110611) do
ActiveRecord::Schema.define(version: 2024_03_13_184118) do

create_table "access_grants", id: :integer, charset: "utf8", force: :cascade do |t|
t.string "code"
Expand Down Expand Up @@ -295,6 +295,7 @@
t.text "move_students_api_url"
t.string "move_students_api_token"
t.boolean "use_query_jwt", default: false
t.boolean "supports_researchers", default: false
t.index ["client_id"], name: "index_external_reports_on_client_id"
end

Expand Down
1 change: 1 addition & 0 deletions rails/factories/external_reports.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@
f.individual_student_reportable {true}
f.individual_activity_reportable {true}
f.use_query_jwt {false}
f.supports_researchers {false}
end
end
21 changes: 15 additions & 6 deletions rails/spec/controllers/api/v1/offerings_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,22 +124,31 @@
end
end

describe "when offering has an external report" do
let (:external_report) { FactoryBot.create(:external_report) }
describe "when offering has external reports" do
let(:external_report_1) { FactoryBot.create(:external_report, name: 'External Report 1', supports_researchers: true) }
let(:external_report_2) { FactoryBot.create(:external_report, name: 'External Report 2', supports_researchers: false) }

before (:each) do
sign_in teacher.user
runnable.external_reports = [ external_report ]
runnable.external_reports = [ external_report_1, external_report_2 ]
runnable.save
end

it "returns information about external report" do
get :show, params: { id: offering.id }
expect(response.status).to eq 200
json = JSON.parse(response.body)
expect(json["external_reports"][0]).not_to eq nil
expect(json["external_reports"][0]["url"]).to eq portal_external_report_url(id: offering.id, report_id: external_report.id, host: 'test.host')
expect(json["external_reports"][0]["launch_text"]).to eq external_report.launch_text
expect(json["external_reports"].length).to eq 2

expect(json["external_reports"][0]["name"]).to eq "External Report 1"
expect(json["external_reports"][0]["url"]).to eq portal_external_report_url(id: offering.id, report_id: external_report_1.id, host: 'test.host')
expect(json["external_reports"][0]["launch_text"]).to eq external_report_1.launch_text
expect(json["external_reports"][0]["supports_researchers"]).to eq true

expect(json["external_reports"][1]["name"]).to eq "External Report 2"
expect(json["external_reports"][1]["url"]).to eq portal_external_report_url(id: offering.id, report_id: external_report_2.id, host: 'test.host')
expect(json["external_reports"][1]["launch_text"]).to eq external_report_2.launch_text
expect(json["external_reports"][1]["supports_researchers"]).to eq false
end
end

Expand Down
3 changes: 2 additions & 1 deletion react-components/src/library/components/assigments/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ const externalReportMapping = data => {
return {
name: data.name,
launchText: data.launch_text,
url: data.url
url: data.url,
supportsResearchers: data.supports_researchers
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const externalReportMapping = data => {
}
return {
url: data.url,
launchText: data.launch_text
launchText: data.launch_text,
supportsResearchers: data.supports_researchers
}
}

Expand Down
Loading