get suggested answer belonging to the currents user for this question
# File app/models/question.rb, line 99 def get_suggested_answer(org_id) suggested_answer = suggested_answers.find_by_organisation_id(org_id) return suggested_answer end
guidance for question in the org admin
# File app/models/question.rb, line 69 def guidance_for_question(question, org_admin) # pulls together guidance from various sources for question guidances = {} theme_ids = question.theme_ids GuidanceGroup.where("organisation_id = ?", org_admin.id).each do |group| group.guidances.each do |g| g.themes.where("id IN (?)", theme_ids).each do |gg| guidances["#{group.name} guidance on #{gg.title}"] = g end end end # Guidance link to directly to a question question.guidances.each do |g_by_q| g_by_q.guidance_groups.each do |group| if group.organisation == org_admin guidances["#{group.name} guidance for this question"] = g_by_q end end end return guidances end
def question_type?
type_label = {} if self.is_text_field? type_label = 'Text field' elsif self.multiple_choice? type_label = 'Multiple choice' else type_label = 'Text area' end return type_label
end
# File app/models/question.rb, line 51 def question_themes? themes_label = {} i = 1 themes_quest = self.themes themes_quest.each do |tt| themes_label = tt.title if themes_quest.count > i then themes_label += ',' i +=1 end end return themes_label end
# File app/models/question.rb, line 29 def to_s "#{text}" end