add grade_passback_setting to course
fixes CORE-3156 test plan - specs should pass Change-Id: I3e90d4c8ad9aa022c6fa2257c85d9b656e005010 Reviewed-on: https://gerrit.instructure.com/200364 Tested-by: Jenkins Reviewed-by: James Williams <jamesw@instructure.com> QA-Review: James Williams <jamesw@instructure.com> Product-Review: Rob Orton <rob@instructure.com>
This commit is contained in:
parent
c89387e8b9
commit
700333ca7a
|
@ -0,0 +1,24 @@
|
|||
#
|
||||
# Copyright (C) 2019 - present Instructure, Inc.
|
||||
#
|
||||
# This file is part of Canvas.
|
||||
#
|
||||
# Canvas is free software: you can redistribute it and/or modify it under
|
||||
# the terms of the GNU Affero General Public License as published by the Free
|
||||
# Software Foundation, version 3 of the License.
|
||||
#
|
||||
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License along
|
||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
class AddGradePassbackSettingToCourse < ActiveRecord::Migration[5.1]
|
||||
tag :predeploy
|
||||
|
||||
def change
|
||||
add_column :courses, :grade_passback_setting, :string, limit: 255
|
||||
end
|
||||
end
|
|
@ -62,7 +62,7 @@ module SIS
|
|||
@success_count = 0
|
||||
end
|
||||
|
||||
def add_course(course_id, term_id, account_id, fallback_account_id, status, start_date, end_date, abstract_course_id, short_name, long_name, integration_id, course_format, blueprint_course_id)
|
||||
def add_course(course_id, term_id, account_id, fallback_account_id, status, start_date, end_date, abstract_course_id, short_name, long_name, integration_id, course_format, blueprint_course_id, grade_passback_setting)
|
||||
state_changes = []
|
||||
@logger.debug("Processing Course #{[course_id, term_id, account_id, fallback_account_id, status, start_date, end_date, abstract_course_id, short_name, long_name].inspect}")
|
||||
|
||||
|
@ -71,6 +71,7 @@ module SIS
|
|||
raise ImportError, "No long_name given for course #{course_id}" if long_name.blank? && abstract_course_id.blank?
|
||||
raise ImportError, "Improper status \"#{status}\" for course #{course_id}" unless status =~ /\A(active|deleted|completed|unpublished)/i
|
||||
raise ImportError, "Invalid course_format \"#{course_format}\" for course #{course_id}" unless course_format.blank? || course_format =~ /\A(online|on_campus|blended|not_set)/i
|
||||
raise ImportError, "Invalid grade_passback_setting \"#{grade_passback_setting}\" for course #{course_id}" unless grade_passback_setting.blank? || grade_passback_setting =~ /\A(nightly_sync|not_set)/i
|
||||
return if @batch.skip_deletes? && status =~ /deleted/i
|
||||
|
||||
course = @root_account.all_courses.where(sis_source_id: course_id).take
|
||||
|
@ -177,6 +178,13 @@ module SIS
|
|||
end
|
||||
end
|
||||
|
||||
if grade_passback_setting
|
||||
grade_passback_setting = nil if grade_passback_setting == 'not_set'
|
||||
if grade_passback_setting != course.grade_passback_setting
|
||||
course.grade_passback_setting = grade_passback_setting
|
||||
end
|
||||
end
|
||||
|
||||
if course.changed?
|
||||
course.templated_courses.each do |templated_course|
|
||||
templated_course.root_account = @root_account
|
||||
|
|
|
@ -43,9 +43,11 @@ module SIS
|
|||
messages << SisBatch.build_error(csv, "Bad date format for course #{row['course_id']}", sis_batch: @batch, row: row['lineno'], row_info: row)
|
||||
end
|
||||
course_format = row.key?('course_format') && (row['course_format'] || 'not_set')
|
||||
grade_passback_setting = row.key?('grade_passback_setting') && (row['grade_passback_setting'] || 'not_set')
|
||||
begin
|
||||
importer.add_course(row['course_id'], row['term_id'], row['account_id'], row['fallback_account_id'], row['status'], start_date, end_date,
|
||||
row['abstract_course_id'], row['short_name'], row['long_name'], row['integration_id'], course_format, row['blueprint_course_id'])
|
||||
row['abstract_course_id'], row['short_name'], row['long_name'], row['integration_id'], course_format, row['blueprint_course_id'],
|
||||
grade_passback_setting)
|
||||
rescue ImportError => e
|
||||
messages << SisBatch.build_error(csv, e.to_s, sis_batch: @batch, row: row['lineno'], row_info: row)
|
||||
end
|
||||
|
|
|
@ -761,5 +761,32 @@ describe SIS::CSV::CourseImporter do
|
|||
expect(mm).to_not eq other_mm
|
||||
expect(mm).to be_completed
|
||||
end
|
||||
|
||||
it 'sets and updates grade_passback_setting' do
|
||||
process_csv_data_cleanly(
|
||||
"course_id,short_name,long_name,account_id,term_id,status,grade_passback_setting",
|
||||
"test_1,TC 101,Test Course 101,,,active,nightly_sync",
|
||||
"test_2,TC 102,Test Course 102,,,active,nightly_sync",
|
||||
"test_3,TC 103,Test Course 103,,,active,nightly_sync"
|
||||
)
|
||||
expect(Course.find_by_sis_source_id('test_1').grade_passback_setting).to eq 'nightly_sync'
|
||||
expect(Course.find_by_sis_source_id('test_2').grade_passback_setting).to eq 'nightly_sync'
|
||||
|
||||
process_csv_data_cleanly(
|
||||
"course_id,short_name,long_name,account_id,term_id,status,grade_passback_setting",
|
||||
"test_1,TC 101,Test Course 101,,,active,",
|
||||
"test_2,TC 102,Test Course 102,,,active,\"\"",
|
||||
"test_3,TC 103,Test Course 103,,,active,nightly_sync"
|
||||
)
|
||||
expect(Course.find_by_sis_source_id('test_1').grade_passback_setting).to be_nil
|
||||
expect(Course.find_by_sis_source_id('test_2').grade_passback_setting).to be_nil
|
||||
expect(Course.find_by_sis_source_id('test_3').grade_passback_setting).to eq 'nightly_sync'
|
||||
|
||||
process_csv_data_cleanly(
|
||||
"course_id,short_name,long_name,account_id,term_id,status",
|
||||
"test_3,TC 103,Test Course 103,,,active"
|
||||
)
|
||||
expect(Course.find_by_sis_source_id('test_3').grade_passback_setting).to eq 'nightly_sync'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue