mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 21:48:16 -08:00
chore: add script to delete student records incorrectly created by teacher responses
This commit is contained in:
parent
f1eaad62c8
commit
0f5c0b280d
1 changed files with 7 additions and 0 deletions
|
|
@ -140,6 +140,13 @@ namespace :one_off do
|
|||
academic_year.delete
|
||||
end
|
||||
end
|
||||
desc "delete all student records incorrectly created by teacher responses"
|
||||
task delete_errant_student_records: :environment do
|
||||
wrong_response_ids = SurveyItemResponse.where(survey_item: SurveyItem.teacher_survey_items).pluck(:response_id).uniq
|
||||
StudentRace.where(student: Student.where(response_id: wrong_response_ids)).delete_all
|
||||
Student.where(response_id: wrong_response_ids).delete_all
|
||||
SurveyItemResponse.where(response_id: wrong_response_ids).update_all(student_id: nil)
|
||||
end
|
||||
|
||||
desc "print out percentage of nil values for range"
|
||||
task nil_grades: :environment do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue