Skip to content

Instantly share code, notes, and snippets.

@alagu
Last active September 12, 2024 12:35
Show Gist options
  • Save alagu/53df205627ae59d62458f3ceb8a0106b to your computer and use it in GitHub Desktop.
Save alagu/53df205627ae59d62458f3ceb8a0106b to your computer and use it in GitHub Desktop.
Nupco customization
form = ReviewCycleTemplate.find(14166)
form = ReviewCycleTemplate.find(14169)
new_options = [{value: 79, legend:'Below Expectation'},
{value: 80, legend:'Below Expectation'},
{value: 81, legend:'Below Expectation'},
{value: 82, legend:'Below Expectation'},
{value: 83, legend:'Below Expectation'},
{value: 84, legend:'Below Expectation'},
{value: 85, legend:'Below Expectation'},
{value: 86, legend:'Below Expectation'},
{value: 87, legend:'Below Expectation'},
{value: 88, legend:'Below Expectation'},
{value: 89, legend:'Below Expectation'},
{value: 90, legend:'Meet Expectation'},
{value: 91, legend:'Meet Expectation'},
{value: 92, legend:'Meet Expectation'},
{value: 93, legend:'Meet Expectation'},
{value: 94, legend:'Meet Expectation'},
{value: 95, legend:'Meet Expectation'},
{value: 96, legend:'Meet Expectation'},
{value: 97, legend:'Meet Expectation'},
{value: 98, legend:'Meet Expectation'},
{value: 99, legend:'Meet Expectation'},
{value: 100, legend:'Meet Expectation'},
{value: 101, legend:'Exceed Expectation'},
{value: 102, legend:'Exceed Expectation'},
{value: 103, legend:'Exceed Expectation'},
{value: 104, legend:'Exceed Expectation'},
{value: 105, legend:'Exceed Expectation'},
{value: 106, legend:'Exceed Expectation'},
{value: 107, legend:'Exceed Expectation'},
{value: 108, legend:'Exceed Expectation'},
{value: 109, legend:'Exceed Expectation'},
{value: 110, legend:'Exceed Expectation'},
{value: 111, legend:'Outstanding Expectation'},
{value: 112, legend:'Outstanding Expectation'},
{value: 113, legend:'Outstanding Expectation'},
{value: 114, legend:'Outstanding Expectation'},
{value: 115, legend:'Outstanding Expectation'},
{value: 116, legend:'Outstanding Expectation'},
{value: 117, legend:'Outstanding Expectation'},
{value: 118, legend:'Outstanding Expectation'},
{value: 119, legend:'Outstanding Expectation'},
{value: 120, legend:'Outstanding Expectation'}]
questions = form.review_cycle_template_questions.where(block_type: :question).map(&:question)
questions.each { |q| q.options.destroy_all; new_options.each { |o| q.options.create(o) } }
legend_hash = new_options.map { |option| { option[:value].to_s => option[:legend] } }.reduce({}, :merge)
legend_formula = {"79": "Below Expectation", "90": "Meet Expectation", "101": "Exceed Expectation", "111": "Outstanding Expectation"}
goal_fields = {"text"=>true, "score"=>true,
"legend"=>legend_hash,
"legend_formula"=>legend_formula,
"nps_view_type"=>"dropdown",
"required" => false,
"score_visible" => true,
"show_legend_value" => true,
"show_overall_score" => true
}
goal_block = form.review_cycle_template_questions.where(block_type: :goals).first
goal_block.update(goal_fields: goal_fields)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment