module Admin::AnalyticsHelper
|
|
|
|
# Colours a bar by what the answer does to the player's score, so a stage
|
|
# reads at a glance: green = they made the good call, red = they didn't.
|
|
def answer_tone(node)
|
|
case node.template
|
|
when "good_answer" then "positive"
|
|
when "bad_answer" then "negative"
|
|
when "chance" then "neutral"
|
|
end
|
|
end
|
|
|
|
|
|
def band_tone(band)
|
|
{ best: "positive", balanced: "neutral", worst: "negative" }[band.to_sym]
|
|
end
|
|
|
|
|
|
def format_duration(seconds)
|
|
return "—" if seconds.blank? || seconds.to_i.zero?
|
|
|
|
seconds = seconds.to_i
|
|
minutes, seconds = seconds.divmod(60)
|
|
minutes.zero? ? "#{seconds}s" : "#{minutes}m #{seconds}s"
|
|
end
|
|
end
|