<commit_before>- material_count = material.offerings_count
- if material.parent
  - material_count = material_count + material.parent.offerings_count

- external = false
- if material.is_a? Investigation
  - link_url = browse_investigation_url(material)
- elsif material.is_a? Activity
  - link_url = browse_activity_url(material)
- elsif material.is_a? ExternalActivity
  - link_url = browse_external_activity_url(material)
  - edit_url = matedit_external_activity_url(material,:iFrame => false)
  - external = true

- has_activities = material.respond_to?(:activities) && !material.activities.nil?
- has_pretest = material.respond_to?(:has_pretest) && material.has_pretest

.material_list_item{ :id => "search_#{material.class.name.underscore}_#{material.id}",
                     :'data-material_name' => material.name,
                     :'data-material_id' => material.id }
  .main-part
    - if defined? hide_details
      = show_material_icon(material, link_url, hide_details)
    - elsif
      = show_material_icon(material, link_url, nil)
    %div
      %div{:style=>'overflow:hidden'}
        %table{:width=>"100%"}
          %tr
            %td
            %td
              %span.material_header
                %span.material_meta_data
                  - unless material.java_requirements.blank?
                    %span{:class => material.java_requirements}
                      = t(material.java_requirements)
                  - if material.is_official
                    %span.is_official Official
                  - else
                    %span.is_community Community
                %br
                - if link_url.nil?
                  = material.name
                - else
                  = link_to "#{material.name}",link_url
                - if current_visitor.has_role? ["admin","manager"]
                  %span.superTiny= link_to "(edit options)", edit_polymorphic_url(material)
              - if material.parent
                %span
                  from
                  = t(:investigation)
                  ="\"#{material.parent.name}\""
              -if material.user && (!material.user.name.nil?)
                %div
                  %span{:style=>"font-weight:bold"}
                    ="By #{material.user.name}"
            %td{:width=>"90px"}
              %div{:style=>'float:right'}
                = render :partial => '/browse/preview', :locals => {:material => material, :current_visitor => current_visitor}
            - if (material.is_a? ExternalActivity) && (current_visitor.has_role? 'admin')
              %td{:width=>"110px"}
                %div{:style=>'float:right'}
                  = link_to "Edit in iframe", matedit_external_activity_url(material,:iFrame => true), :class=>"button", :target => "_blank"
            - if (material.is_a? ExternalActivity) && (current_visitor.id == material.user_id or material.author_email == current_visitor.email or current_visitor.has_role? 'admin')
              %td{:width=>"60px"}
                %div{:style=>'float:right'}
                  = link_to "Edit", edit_url, :class=>"button", :target => "_blank"
            - if external && current_user
              - if material.is_locked != true or material.author_email == current_visitor.email or current_visitor.has_role? 'admin'
                %td{:width=>"70px"}
                  %div{:style=>'float:right'}
                    = link_to "Copy", copy_external_activity_url(material), :class=>"button", :target => "_blank"
            - unless material.teacher_guide_url.blank? && (current_user && (current_user.has_role? "admin"))
              %td{:width=>"130px"}
                %div{:style=>'float:right'}
                  - if current_visitor.portal_teacher
                    = assign_material_link(material, "javascript:void(0)", :onclick=>"get_Assign_To_Class_Popup(#{material.id},'#{material.class.to_s}')")
                  - else
                    = assign_material_link(material, url_for({ :controller => '/search', :action => 'unauthorized_user' }))
                %div{:style=>'float:right;text-align: right; margin-top: 3px;'}
                  = teacher_guide_link(material)


          %tr
            %td{:colspan=>3}
              -# TODO: FIXME: After demo, figure out how to get this working..
              -# if current_visitor.portal_teacher
                - teacher_clazz_ids = current_visitor.portal_teacher.teacher_clazzes.sort{|a,b| a.position <=> b.position}.map{|item| item.clazz_id}
                - offerings = material.offerings_by_clazz(teacher_clazz_ids).sort{|a,b| teacher_clazz_ids.index(a.clazz_id) <=> teacher_clazz_ids.index(b.clazz_id)}<commit_msg>Check for current_visitor is teacher or material has no guide link.<commit_after>- material_count = material.offerings_count
- if material.parent
  - material_count = material_count + material.parent.offerings_count

- external = false
- if material.is_a? Investigation
  - link_url = browse_investigation_url(material)
- elsif material.is_a? Activity
  - link_url = browse_activity_url(material)
- elsif material.is_a? ExternalActivity
  - link_url = browse_external_activity_url(material)
  - edit_url = matedit_external_activity_url(material,:iFrame => false)
  - external = true

- has_activities = material.respond_to?(:activities) && !material.activities.nil?
- has_pretest = material.respond_to?(:has_pretest) && material.has_pretest

.material_list_item{ :id => "search_#{material.class.name.underscore}_#{material.id}",
                     :'data-material_name' => material.name,
                     :'data-material_id' => material.id }
  .main-part
    - if defined? hide_details
      = show_material_icon(material, link_url, hide_details)
    - elsif
      = show_material_icon(material, link_url, nil)
    %div
      %div{:style=>'overflow:hidden'}
        %table{:width=>"100%"}
          %tr
            %td
            %td
              %span.material_header
                %span.material_meta_data
                  - unless material.java_requirements.blank?
                    %span{:class => material.java_requirements}
                      = t(material.java_requirements)
                  - if material.is_official
                    %span.is_official Official
                  - else
                    %span.is_community Community
                %br
                - if link_url.nil?
                  = material.name
                - else
                  = link_to "#{material.name}",link_url
                - if current_visitor.has_role? ["admin","manager"]
                  %span.superTiny= link_to "(edit options)", edit_polymorphic_url(material)
              - if material.parent
                %span
                  from
                  = t(:investigation)
                  ="\"#{material.parent.name}\""
              -if material.user && (!material.user.name.nil?)
                %div
                  %span{:style=>"font-weight:bold"}
                    ="By #{material.user.name}"
            %td{:width=>"90px"}
              %div{:style=>'float:right'}
                = render :partial => '/browse/preview', :locals => {:material => material, :current_visitor => current_visitor}
            - if (material.is_a? ExternalActivity) && (current_visitor.has_role? 'admin')
              %td{:width=>"110px"}
                %div{:style=>'float:right'}
                  = link_to "Edit in iframe", matedit_external_activity_url(material,:iFrame => true), :class=>"button", :target => "_blank"
            - if (material.is_a? ExternalActivity) && (current_visitor.id == material.user_id or material.author_email == current_visitor.email or current_visitor.has_role? 'admin')
              %td{:width=>"60px"}
                %div{:style=>'float:right'}
                  = link_to "Edit", edit_url, :class=>"button", :target => "_blank"
            - if external && current_user
              - if material.is_locked != true or material.author_email == current_visitor.email or current_visitor.has_role? 'admin'
                %td{:width=>"70px"}
                  %div{:style=>'float:right'}
                    = link_to "Copy", copy_external_activity_url(material), :class=>"button", :target => "_blank"
            - if material.teacher_guide_url || current_visitor.portal_teacher
              %td{:width=>"130px"}
                %div{:style=>'float:right'}
                  - if current_visitor.portal_teacher
                    = assign_material_link(material, "javascript:void(0)", :onclick=>"get_Assign_To_Class_Popup(#{material.id},'#{material.class.to_s}')")
                  - else
                    = assign_material_link(material, url_for({ :controller => '/search', :action => 'unauthorized_user' }))
                %div{:style=>'float:right;text-align: right; margin-top: 3px;'}
                  = teacher_guide_link(material)


          %tr
            %td{:colspan=>3}
              -# TODO: FIXME: After demo, figure out how to get this working..
              -# if current_visitor.portal_teacher
                - teacher_clazz_ids = current_visitor.portal_teacher.teacher_clazzes.sort{|a,b| a.position <=> b.position}.map{|item| item.clazz_id}
                - offerings = material.offerings_by_clazz(teacher_clazz_ids).sort{|a,b| teacher_clazz_ids.index(a.clazz_id) <=> teacher_clazz_ids.index(b.clazz_id)}
{'fraction_non_alphanumeric': 0.12866744905579858, 'fraction_numerical': 0.0038408193747999572, 'mean_word_length': 2.173324306025728, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 75, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2751038', 'n_tokens_mistral': 2851, 'n_tokens_neox': 2705, 'n_words': 437}