app/controllers/survey_respondents/tags_admin_controller.rb
# The start page, we start with a hash of the tag contexts and their associated tags
The start page, we start with a hash of the tag contexts and their associated tags
The start page we start with a hash of the tag contexts and their associated tags
def edit(context, old_value, new_value)
    respondents = SurveyRespondent.tagged_with(old_value, :on => context)
    respondents.each do |respondent|
      tags = respondent.tag_counts_on(context)
      new_tags = tags.collect {|tag| (tag.name == old_value) ? new_value : tag.name }
      respondent.set_tag_list_on(context, new_tags.join(",") )
      respondent.save
      if (respondent.person)
        respondent.person.set_tag_list_on(context, new_tags.join(",") )
        respondent.person.save
      end
    end
    responses = SurveyResponse.where(["response like ? and survey_question_id in (SELECT id FROM survey_questions where tags_label = ?)", '%'+ old_value +'%', context])
    responses.each do |response|
      tags = response.survey_respondent_detail.survey_respondent.tag_counts_on(context)
      new_tags = tags.collect {|tag| tag.name }
      response.response = new_tags.join(",")
      response.save
    end
  end
def edit ( context , old_value , new_value ) respondents = SurveyRespondent . tagged_with ( old_value , :on => context ) respondents . each do | respondent | tags = respondent . tag_counts_on ( context ) new_tags = tags . collect { | tag | ( tag . name == old_value ) ? new_value : tag . name } respondent . set_tag_list_on ( context , new_tags . join ( "," ) ) respondent . save if ( respondent . person ) respondent . person . set_tag_list_on ( context , new_tags . join ( "," ) ) respondent . person . save end end responses = SurveyResponse . where ( [ "response like ? and survey_question_id in (SELECT id FROM survey_questions where tags_label = ?)" , '%' + old_value + '%' , context ] ) responses . each do | response | tags = response . survey_respondent_detail . survey_respondent . tag_counts_on ( context ) new_tags = tags . collect { | tag | tag . name } response . response = new_tags . join ( "," ) response . save end end
The start page, we start with a hash of the tag contexts and their associated tags
The start page we start with a hash of the tag contexts and their associated tags
# questionId = @tagContexts[context]
context
<not_specific>
old_value
<not_specific>
new_value
<not_specific>