<commit_before>React = require 'react'
BS = require 'react-bootstrap'
classnames = require 'classnames'

TutorLink = require '../link'
SortingHeader    = require './sorting-header'
Time   = require '../time'

ReviewLink = (props) ->
  return null if props.isConceptCoach or props.heading.type is 'external' or not props.heading.plan_id?
  <span className="review-link #{props.cellWidth}">
    <TutorLink
      to='reviewTask'
      query={tab: props.periodIndex}
      params={id: props.heading.plan_id, courseId: props.courseId}
    >
      Review
    </TutorLink>
  </span>

AverageLabel = (props) ->
  if props.average_score
    <span className="average #{props.cellWidth}">
      {(props.average_score * 100).toFixed(0)}%
    </span>
  else
    if props.heading.type is 'homework'
      <span className="average">---</span>
    else if props.heading.type is 'external'
      p = props.heading.completion_rate
      percent = switch
        when (p < 1 and p > 0.99) then 99 # Don't round to 100% when it's not 100%!
        when (p > 0 and p < 0.01) then 1  # Don't round to 0% when it's not 0%!
        when (p > 1) then 100             # Don't let it go over 100%!
        else Math.round(p * 100)

      <span className="click-rate">
        {percent}% have clicked link
      </span>
    else
      null

getCellWidth = ({isConceptCoach, heading}) ->
  if isConceptCoach
    'wide'
  else
    switch heading.type
      when 'reading' then 'wide'
      when 'external' then 'wide'
      else ''

AssignmentSortingHeader = (props) ->
  {heading, dataType, columnIndex, sort, onSort} = props
  if heading.type is 'reading' or heading.type is 'external'
    <div className='scores-cell'>
      <SortingHeader<commit_msg>Add displayName so components match tests<commit_after>React = require 'react'
BS = require 'react-bootstrap'
classnames = require 'classnames'

TutorLink = require '../link'
SortingHeader    = require './sorting-header'
Time   = require '../time'

ReviewLink = (props) ->
  return null if props.isConceptCoach or props.heading.type is 'external' or not props.heading.plan_id?
  <span className="review-link #{props.cellWidth}">
    <TutorLink
      to='reviewTask'
      query={tab: props.periodIndex}
      params={id: props.heading.plan_id, courseId: props.courseId}
    >
      Review
    </TutorLink>
  </span>
ReviewLink.displayName = 'ReviewLink'

AverageLabel = (props) ->
  if props.average_score
    <span className="average #{props.cellWidth}">
      {(props.average_score * 100).toFixed(0)}%
    </span>
  else
    if props.heading.type is 'homework'
      <span className="average">---</span>
    else if props.heading.type is 'external'
      p = props.heading.completion_rate
      percent = switch
        when (p < 1 and p > 0.99) then 99 # Don't round to 100% when it's not 100%!
        when (p > 0 and p < 0.01) then 1  # Don't round to 0% when it's not 0%!
        when (p > 1) then 100             # Don't let it go over 100%!
        else Math.round(p * 100)

      <span className="click-rate">
        {percent}% have clicked link
      </span>
    else
      null
AverageLabel.displayName = 'AverageLabel'

getCellWidth = ({isConceptCoach, heading}) ->
  if isConceptCoach
    'wide'
  else
    switch heading.type
      when 'reading' then 'wide'
      when 'external' then 'wide'
      else ''

AssignmentSortingHeader = (props) ->
  {heading, dataType, columnIndex, sort, onSort} = props
  if heading.type is 'reading' or heading.type is 'external'
    <div className='scores-cell'>
      <SortingHeader
{'fraction_non_alphanumeric': 0.1265466816647919, 'fraction_numerical': 0.01856017997750281, 'mean_word_length': 2.824731182795699, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 39, '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': '524202', 'n_tokens_mistral': 1213, 'n_tokens_neox': 1114, 'n_words': 334}