add limiting period to grade export report

***test plan
  1. through the api pass parameters['include_deleted'] = true
    and parameters['limiting_period'] = some number of days
  2.  Make sure enrollments that have been deleted or concluded within
  specified # of days from above are returned in report
  3.  Make sure enrollments that are not concluded / deleted within
  specified number of days are not returned in the report

refs: PS-1698

Change-Id: Id24c58954dba2aed0a92cd5dea1946ef0764dc1a
Reviewed-on: https://gerrit.instructure.com/36612
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Brandon Broschinsky <brandonbr@instructure.com>
Product-Review: Adam Phillipps <adam@instructure.com>
QA-Review: Adam Phillipps <adam@instructure.com>
This commit is contained in:
dave 2014-06-18 14:58:19 -06:00 committed by Dave Jungst
parent 4c0671ee6b
commit 10268ebff0
2 changed files with 90 additions and 1 deletions

View File

@ -33,6 +33,11 @@ module Canvas::AccountReports
add_extra_text(I18n.t('account_reports.grades.deleted',
'Include Deleted Objects: true;'))
end
if @account_report.has_parameter? "limiting_period"
add_extra_text(I18n.t('account_reports.grades.limited',
'deleted objects limited by days specified;'))
end
end
# retrieve the list of courses for the account
@ -77,6 +82,14 @@ module Canvas::AccountReports
if @include_deleted
students = students.where("e.workflow_state IN ('active', 'completed', 'deleted')")
if @account_report.parameters.has_key? 'limiting_period'
limiting_period = @account_report.parameters['limiting_period'].to_i
students = students.where("e.workflow_state = 'active'
OR c.conclude_at >= ?
OR (e.workflow_state = 'deleted'
AND e.updated_at >= ?)",
limiting_period.days.ago, limiting_period.days.ago)
end
else
students = students.where(
"pseudonyms.workflow_state<>'deleted'

View File

@ -203,6 +203,82 @@ describe "Default Account Reports" do
nil, "Math 101", @course2.course_sections.first.id.to_s, nil, "Default Term",
@default_term.id.to_s, nil, nil, "99", "active"]
end
end
it "should run a grade export on concluded courses with an limiting period given" do
@course1.complete!
@enrollment1.conclude
@enrollment1.save!
parameters = {}
parameters["include_deleted"] = true
parameters["limiting_period"] = "2"
parsed = read_report('grade_export_csv', {order: 13, params: parameters})
parsed.length.should == 5
parsed[0].should == ["John St. Clair", @user1.id.to_s, "user_sis_id_01",
"English 101", @course1.id.to_s, "SIS_COURSE_ID_1",
"English 101", @course1.course_sections.first.id.to_s,
nil, "Fall", @term1.id.to_s, "fall12", nil, "88", "concluded"]
parsed[1].should == ["Michael Bolton", @user2.id.to_s, "user_sis_id_02",
"English 101", @course1.id.to_s, "SIS_COURSE_ID_1",
"English 101", @course1.course_sections.first.id.to_s,
nil, "Fall", @term1.id.to_s, 'fall12', nil, "90", "concluded"]
parsed[2].should == ["Michael Bolton", @user2.id.to_s, "user_sis_id_02",
"Math 101", @course2.id.to_s, nil, "Math 101",
@course2.course_sections.first.id.to_s, nil, "Default Term",
@default_term.id.to_s, nil, nil, "93", "active"]
parsed[3].should == ["Rick Astley", @user3.id.to_s, "user_sis_id_03",
"English 101", @course1.id.to_s, "SIS_COURSE_ID_1",
"English 101", @course1.course_sections.first.id.to_s,
nil, "Fall", @term1.id.to_s, "fall12", nil, "97", "concluded"]
parsed[4].should == ["Jason Donovan", @user4.id.to_s, "user_sis_id_04",
"Math 101", @course2.id.to_s, nil, "Math 101",
@course2.course_sections.first.id.to_s, nil, "Default Term",
@default_term.id.to_s, nil, nil, "99", "active"]
end
it "should not return results that don't fall within the limiting period" do
@course1.complete!
@course1.conclude_at = Date.today - 3.days
@course1.save!
parameters = {}
parameters["include_deleted"] = true
parameters["limiting_period"] = "2"
parsed = read_report('grade_export_csv', {order: 13, params: parameters})
parsed.length.should == 2
parsed[0].should == ["Michael Bolton", @user2.id.to_s, "user_sis_id_02",
"Math 101", @course2.id.to_s, nil, "Math 101",
@course2.course_sections.first.id.to_s, nil, "Default Term",
@default_term.id.to_s, nil, nil, "93", "active"]
parsed[1].should == ["Jason Donovan", @user4.id.to_s, "user_sis_id_04",
"Math 101", @course2.id.to_s, nil, "Math 101",
@course2.course_sections.first.id.to_s, nil, "Default Term",
@default_term.id.to_s, nil, nil, "99", "active"]
end
it "should return a deleted courses within an limiting period" do
@enrollment3.destroy
parameters = {}
parameters["include_deleted"] = true
parameters["limiting_period"] = "2"
parsed = read_report('grade_export_csv', {order: 13, params: parameters})
parsed.length.should == 4
parsed[0].should == ["John St. Clair", @user1.id.to_s, "user_sis_id_01", "English 101", @course1.id.to_s,
"SIS_COURSE_ID_1", "English 101", @course1.course_sections.first.id.to_s, nil, "Fall",
@term1.id.to_s, "fall12", nil, "88", "active"]
parsed[1].should == ["Michael Bolton", @user2.id.to_s, "user_sis_id_02", "Math 101", @course2.id.to_s,
nil, "Math 101", @course2.course_sections.first.id.to_s, nil, "Default Term",
@default_term.id.to_s, nil, nil, "93", "deleted"]
parsed[2].should == ["Rick Astley", @user3.id.to_s, "user_sis_id_03", "English 101", @course1.id.to_s,
"SIS_COURSE_ID_1", "English 101", @course1.course_sections.first.id.to_s, nil, "Fall",
@term1.id.to_s, "fall12", nil, "97", "active"]
parsed[3].should == ["Jason Donovan", @user4.id.to_s, "user_sis_id_04", "Math 101", @course2.id.to_s,
nil, "Math 101", @course2.course_sections.first.id.to_s, nil, "Default Term",
@default_term.id.to_s, nil, nil, "99", "active"]
end
end
end