diff --git a/app/models/recipient_schedule.rb b/app/models/recipient_schedule.rb index a7c1584f..55b3b3d0 100644 --- a/app/models/recipient_schedule.rb +++ b/app/models/recipient_schedule.rb @@ -31,6 +31,18 @@ class RecipientSchedule < ApplicationRecord Question.where(id: next_question_id).first end + def upcoming_question_id_array + upcoming_question_ids.try(:split, /,/) || [] + end + + def attempted_question_id_array + attempted_question_ids.try(:split, /,/) || [] + end + + def queued_question_id_array + queued_question_ids.try(:split, /,/) || [] + end + def attempt_question_for_recipient_students(send_message: true, question: next_question) return if recipient.opted_out? return if question.nil? @@ -55,9 +67,9 @@ class RecipientSchedule < ApplicationRecord ) if send_message && attempt.send_message - upcoming = upcoming_question_ids.try(:split, /,/) || [] - queued = queued_question_ids.try(:split, /,/) || [] - attempted = attempted_question_ids.try(:split, /,/) || [] + upcoming = upcoming_question_id_array + queued = queued_question_id_array + attempted = attempted_question_id_array if question.present? question_id = [question.id.to_s] @@ -100,9 +112,9 @@ class RecipientSchedule < ApplicationRecord end if send_message && (unanswered_attempt || attempt).send_message - upcoming = upcoming_question_ids.try(:split, /,/) || [] - queued = queued_question_ids.try(:split, /,/) || [] - attempted = attempted_question_ids.try(:split, /,/) || [] + upcoming = upcoming_question_id_array + queued = queued_question_id_array + attempted = attempted_question_id_array if question.present? question_id = [question.id.to_s] diff --git a/db/seeds.rb b/db/seeds.rb index 0f5ee8ca..7ba325d0 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -21,6 +21,15 @@ recipients = [ school.recipients.create(name: 'Lynisse Patin', phone: '19176566892'), school.recipients.create(name: 'Khemenec Patin', phone: '(347) 534-6437'), ] + +recipients[0].students.create(name: 'Abigail') +recipients[0].students.create(name: 'Clara') + +recipients[3].students.creaet(name: 'Zara') +recipients[3].students.creaet(name: 'Cole') +recipients[4].students.creaet(name: 'Zara') +recipients[4].students.creaet(name: 'Cole') + recipient_list = school.recipient_lists.create(name: 'Pilot Parent Test', recipient_id_array: recipients.map(&:id)) user.user_schools.create(school: school) diff --git a/lib/tasks/data.rake b/lib/tasks/data.rake index 7905df9d..db01675e 100644 --- a/lib/tasks/data.rake +++ b/lib/tasks/data.rake @@ -102,7 +102,8 @@ namespace :data do option2: question['answers'][1], option3: question['answers'][2], option4: question['answers'][3], - option5: question['answers'][4] + option5: question['answers'][4], + for_recipient_students: question['child'].present? ) else variations.each do |variation| @@ -112,7 +113,8 @@ namespace :data do option2: question['answers'][1], option3: question['answers'][2], option4: question['answers'][3], - option5: question['answers'][4] + option5: question['answers'][4], + for_recipient_students: question['child'].present? ) end end