# encoding: utf-8
include UsersHelper
module HomeworkCommonHelper
  #迟交扣分下拉框
  def late_penalty_option
    type = []
    type << l(:lable_unset)
    for i in (1..5)
      option = []
      option << i
      option << i
      type << option
    end
    type
  end

  #教辅评分比例下拉框
  def ta_proportion_option
    type = []
    i = 0
    while  i <= 100
      option = []
      option << i.to_s + "%"
      option << i.to_f / 100
      type << option
      i += 10
    end
    type
  end

  def programing_languages_options
    type = []
    option = []
    option << "C"
    option << 1
    type << option
    option_1 = []
    option_1 << "C++"
    option_1 << 2
    type << option_1
    type
  end

  #缺评扣分
  def absence_penalty_option
    type = []
    i = 1
    type << l(:lable_unset)
    while  i <= 5
      option = []
      option << i
      option << i
      type << option
      i += 1
    end
    type
  end

  #根据传入作业确定跳转到开启匿评还是关闭匿评功能
  def alert_anonyoms_path homework,homework_detail_manual,user_activity_id,is_in_course,course_activity
    link = ""
    if homework_detail_manual.comment_status == 1
      link = start_anonymous_comment_homework_common_url homework.id,:user_activity_id=>user_activity_id,:is_in_course=>is_in_course,:course_activity=>course_activity
    elsif homework_detail_manual.comment_status == 2
      link = stop_anonymous_comment_homework_common_url homework.id,:user_activity_id=>user_activity_id,:is_in_course=>is_in_course,:course_activity=>course_activity
    end
    link
  end

  #将状态转换为错误信息
  def status_to_err_msg status
    case status.to_i
      when -1
        '编译出错'
      when -2
        '输入和输出不匹配'
      when -3
        '输入和输出不匹配'
      when 1
        '运行出错'
      when 2
        '超时'
      when 3
        '内存超出'
      when 4
        '输出超出'
      when 5
        '禁用函数'
      when 6
        '其他错误'
      when 0
        '成功'
      else
        '未知错误'
    end
  end
end