- if current_user && showState
  .clear
  - script = Script.find_by_name(id)
  - if current_user.completed_scripts.include?(script)
    = link_to script_certificate_image_url(current_user, script), class: 'whitelink' do
      .bottombar.smalltext.printcertificate
        = t('home.print_certificate')
  - elsif current_user.working_on_scripts.include?(script)
    %a.whitelink{href: build_script_level_url(current_user.next_unpassed_progression_level(script))}
      .bottombar.smalltext.continue
        = t('continue')
  - else
    = link_to url, class: 'whitelink' do
      .bottombar.smalltext.trynow
        = t('home.trynow')

- if current_user && showState
  .clear

  - script = Script.find_by_name(id)
  - user_script = current_user.user_scripts.where(script_id: script.id).first
  - next_unpassed_progression_level = current_user.next_unpassed_progression_level(script)

  - if user_script.try(:completed_at)
    = link_to script_certificate_image_url(current_user, script), class: 'whitelink' do
      .bottombar.smalltext.printcertificate
        = t('home.print_certificate')
  - elsif next_unpassed_progression_level
    %a.whitelink{href: build_script_level_url(next_unpassed_progression_level)}
      .bottombar.smalltext.continue
        = t('continue')
  - else
    = link_to url, class: 'whitelink' do
      .bottombar.smalltext.trynow
        = t('home.trynow')

Fix studio.code.org for some users with incorrect course completion. Since deploying changes to studio.code.org yesterday, we've seen 46 cases in which a user hits an error on the page. The error happens when a user has completed all levels in a course, but for some reason user_script.completed_at is still nil and the script is not listed in user_script.completed_scripts. This changes goes back closer to what we had before, which should be more robust in these cases.
Fix studio.code.org for some users with incorrect course completion.
Since deploying changes to studio.code.org yesterday, we've seen 46 cases in which a user hits an error on the page.  The error happens when a user has completed all levels in a course, but for some reason user_script.completed_at is still nil and the script is not listed in user_script.completed_scripts.  This changes goes back closer to what we had before, which should be more robust in these cases.
