$(function () {
  function getGradeName(gradeid) {
    var gradename = "";
    if (gradeid == 1) {
      gradename = "一年级";
    } else if (gradeid == 2) {
      gradename = "二年级";
    } else if (gradeid == 3) {
      gradename = "三年级";
    } else if (gradeid == 4) {
      gradename = "四年级";
    } else if (gradeid == 5) {
      gradename = "五年级";
    } else if (gradeid == 6) {
      gradename = "六年级";
    } else if (gradeid == 7) {
      gradename = "七年级";
    } else if (gradeid == 8) {
      gradename = "八年级";
    } else if (gradeid == 9) {
      gradename = "九年级";
    } else if (gradeid == 10) {
      gradename = "高一";
    } else if (gradeid == 11) {
      gradename = "高二";
    } else if (gradeid == 12) {
      gradename = "高三";
    }
    return gradename;
  };
  // 考试类型 10期末20期中30月考40周考
  function getExamTypeName(examtype) {
    var examname = "";
    if (examtype == 10) {
      examname = "期末";
    } else if (examtype == 20) {
      examname = "期中";
    } else if (examtype == 30) {
      examname = "月考";
    } else if (examtype == 40) {
      examname = "周考";
    }
    return examname;
  };
  // outerHeight(true) 高度为 height+margin+padding+border
  var parameter = JSON.parse($(".preface_html_root").data("page-params"));
  var gradename = getGradeName(parameter.ksgk.gradeid);
  var examname = getExamTypeName(parameter.ksgk.examtype);
  $(".preface .gradename").text(gradename);
  $(".preface .examtype").text(examname);
  $(".preface .classnum").text(parameter.ksgk.classnum);
  $(".preface .subjectnum").text(parameter.ksgk.subjectnum);
  $(".preface .allscore").text(parameter.ksgk.allscore);
  $(".preface .stunum").text(parameter.ksgk.stunum);
  $(".preface .qkunum").text(parameter.ksgk.missnum);
  $(".preface .sjnum").text(parameter.ksgk.stunum);
  $(".preface .maxscore").text(parameter.ksgk.maxscore);
  $(".preface .avgscore").text(parameter.ksgk.avgscore);
  var arr = $.grep(parameter.djfx, function (value) {
    return value.ranktype == 1 && value.subjectid == "zf";
  })[0].ranks;
  var arrdj = $.grep(arr, function (value) {
    return value.classid == 0;
  });
  var html = "";
  $.each(arrdj, function (idx, item) {
    html += '<div class="preface_content_line">本次考试' +
      item.rankname +
      '类上线分值' +
      item.rankrange +
      '，上线率' +
      item.sturate + '%，上线人数 ' +
      item.stunum +
      '人;</div>'
  });
  $(".preface .preface_djfx").html(html);
});