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 delete(context, old_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}
      new_tags.delete(old_value)
      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|
      str = response.response
      response.response = str.split(',').collect { |val| (val.strip.downcase == old_value.downcase) ? nil : (val.strip == ',' || val.strip == '') ? nil : val.strip}.compact.join(',')
      response.save
    end
  end
def delete ( context , old_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 } new_tags . delete ( old_value ) 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 | str = response . response response . response = str . split ( ',' ) . collect { | val | ( val . strip . downcase == old_value . downcase ) ? nil : ( val . strip == ',' || val . strip == '' ) ? nil : val . strip } . compact . 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>