jshoe/coursequestionbank

View on GitHub
app/views/problems/_problem_data.html.haml

Summary

Maintainability
Test Coverage

- if column == :checkbox
  = check_box_tag "checked_problems[#{problem.id}]", 1, false, id: "checked_problems_#{problem.id}",
    class: "checkbox check_box_#{group_id}", form: "update_multiple_tags_#{group_id}"


- if column == :problem
  %div.problem_view= problem.html5.html_safe

  %div.additional
    %div.prob-right
      - if can? :set_privacy, problem
        = form_tag problem_path(:id => problem.id), :method => :put, :class => 'prob_privacy' do
          = hidden_field_tag :privacy, (problem.is_public ? 'private' : 'public'), :id => nil
          = submit_tag (problem.is_public ? 'Public' : 'Private'), :class => 'btn btn-default privacy-button'

      = form_tag problem_path(:id => problem.id), :method => :put, :class => 'prob_obsolete' do
        = hidden_field_tag :obsolete, problem.obsolete ? '0' : '1', :id => nil
        - if can? :set_privacy, problem
          = submit_tag (problem.obsolete ? 'Obsolete' : 'Mark obsolete'), :class => 'btn btn-default obsolete-button'
        - elsif problem.obsolete
          = submit_tag 'Obsolete', :class => 'btn btn-default obsolete-button', :disabled => true

    %div Created #{problem.created_date} by #{problem.instructor.name}

    %div UID: #{problem.uid}
    
    - if can? :set_previous, problem
      %div
        Previous version:
        = form_tag problem_path(:id => problem.id), :method => :put, :class => 'previous-form' do
          = text_field_tag :previous, nil, :id => nil, :class => 'form-control', :placeholder => 'Enter problem UID', 
              :value => (problem.previous_version.uid if problem.previous_version)

    %div.bloom-buttons
      Bloom Category:
      - Problem.all_bloom_categories.each do |category|
        = form_tag problem_path(:id => problem.id), :method => :put do
          - selected = problem.bloom_category == category
          - if selected
            = hidden_field_tag :category, 'none', :id => nil
          - else
            = hidden_field_tag :category, category, :id => nil
          = submit_tag category, :class => "bloom-button btn #{selected ? 'btn-info' : 'btn-default'}"

    = render :partial => 'problems/collection_buttons', :locals => {:problem => problem}

    %div
      Supersede:
      %textarea{:id => "source_#{problem.id}", :value => "current_ruql", :style => "display: none"}= #{problem.ruql_source}
      %button{"data-clipboard-target" => "source_#{problem.id}", "data-clipboard-text" => "",
              :title => "", :id => "copy_source_button_#{problem.id}", :class => "d_clip_button btn btn-default",
              :value => "copy_source_button_#{problem.id}", :style => ('display: none' if not Rails.env.test?)}
        Clip Source Code

      = link_to "Supersede", supersede_path(:id => problem.id), :id => "supersede_button_#{problem.id}", :class => 'supersede_button btn btn-default'

      - if !problem.previous_version.nil?
        = link_to "See Version History", problem_history_path(:id => problem.id), :id => "history_button_#{problem.id}", :class => 'history_button btn btn-default'

    %div.supersede_form.hidden-additional{:style => 'display: none'}
      = render :partial => 'problems/new_form', :locals => {:previous => problem}

    %div.history_list.hidden-additional{:style => 'display: none'}
      = render :partial => 'problems/history_list', :locals => {:problem => problem}


- if column == :tags
  %div{:id => "all_tags_#{problem.id}", :class => 'tag_list'}
    = render :partial => 'problems/tags', locals: { problem: problem }

  = form_tag add_tags_path(id: problem.id), class: 'add_tags_form' do
    = text_field_tag :tag_names, nil, id: "add_tags_#{problem.id}", class: 'form-control', placeholder: 'Add tags'