package com.ssj.conch.constant;

import com.ssj.framework.core.util.PropertiesUtil;
import org.apache.commons.lang3.StringUtils;
import com.ssj.conch.util.enums.GradeEnum;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class CourseConstant implements Serializable{
    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;


	/**
     * 全学科列表
     */
    public final static List<String> subjectList = new ArrayList<>();


    /**
     * 全学科列表
     */
    public final static List<String> MAIN_SUBJECT_LIST = new ArrayList<>();

    /**
     * 排行榜显示top几
     */
    public final static int RANKING_COUNT = 50;

    /**
     * 同学圈排行榜基础分值
     */
    public final static Map<String, Integer> RANKING_BASE = new HashMap<>();

    /**
     * 学生学习状态及其对应分数
     */
    public final static List<Map<String, Object>> LABEL_SCORE = new ArrayList<>();


    /**
     * 作业状态名称
     */
    public final static List<String> LABEL_NAME_LIST = new ArrayList<>();

    /**
     * 各科作业的内容名称
     */
    public final static List<Map<String, Object>> SUBJECT_ITEM_TITLE = new ArrayList<>();

    /**
     * 题目类型
     */
    public final static String QUESTION_TYPES_STR = PropertiesUtil.getValue("QUESTION_TYPES");

    /**
     * 难易程度
     */
    public final static String DIFFICULTY_LEVELS_STR = PropertiesUtil.getValue("DIFFICULTY_LEVELS");

    /**
     * 真题例题类型
     */
    public final static String REAL_EXAM_TYPE_STR = PropertiesUtil.getValue("REAL_EXAM_TYPE");

    /**
     * 训练能力
     */
    public final static String TRAINING_SKILL_STR =  PropertiesUtil.getValue("TRAINING_SKILL");

    /**
     * 发布时间，用于作业反馈报告的查询
     */
    public final static String publishDate = "2018-10-31";



    static {
        initSubjectList();
        initRankingBase();
        initLabelScore();
        initLabelName();
        initSubjectItemTitle();
    }

    public static void initSubjectList (){
        subjectList.add("语文");
        subjectList.add("数学");
        subjectList.add("英语");
        subjectList.add("物理");
        subjectList.add("化学");

        MAIN_SUBJECT_LIST.add("语文");
        MAIN_SUBJECT_LIST.add("数学");
        MAIN_SUBJECT_LIST.add("英语");
    }

    public static void initRankingBase () {
        //点赞
        RANKING_BASE.put("1", 1);
        //被点赞
        RANKING_BASE.put("2", 2);
        //发消息
        RANKING_BASE.put("3", 4);
        //评论
        RANKING_BASE.put("4", 2);
        //被采纳
        RANKING_BASE.put("5", 4);
    }

    public static void initLabelScore (){
        Map<String, Object> item = new HashMap<>();
        item.put("name", "欠佳");
        item.put("score", 1);
        LABEL_SCORE.add(item);

        item = new HashMap<>();
        item.put("name", "一般");
        item.put("score", 2);
        LABEL_SCORE.add(item);

        item = new HashMap<>();
        item.put("name", "好");
        item.put("score", 3);
        LABEL_SCORE.add(item);
    }

    public static void initLabelName(){
        LABEL_NAME_LIST.add("作业速度");
        LABEL_NAME_LIST.add("自律性");
        LABEL_NAME_LIST.add("积极性");
        LABEL_NAME_LIST.add("专注度");
    }

    public static void initSubjectItemTitle () {
        Map<String, Object> subject  = new HashMap<>();
        String[] chineseItem = {"拼音抄写", "新字词抄写", "笔画认识", "笔顺认识", "造句", "听写", "默写", "课文朗读", "背诵", "阅读", "看图写作", "好词好句摘抄", "其他"};
        String[] mathItem = {"数字书写练习", "口算题", "计算题", "应用题", "画图题", "填空题", "判断题", "常识题", "图形认识", "拓展题", "其他"};
        String[] englishItem = {"字母书写练习", "语法", "单项选择", "单词填空题", "阅读判断", "问答题", "课文朗读", "单词听写", "拓展题", "其他"};

        subject.put("subject", "语文");
        subject.put("list", chineseItem);
        SUBJECT_ITEM_TITLE.add(subject);

        subject = new HashMap<>();
        subject.put("subject", "数学");
        subject.put("list", mathItem);
        SUBJECT_ITEM_TITLE.add(subject);

        subject = new HashMap<>();
        subject.put("subject", "英语");
        subject.put("list", englishItem);
        SUBJECT_ITEM_TITLE.add(subject);
    }

    /**
     * 根据年级获取科目列表, 低年级只能是语数英
     * @param grade
     * @return
     */
    public static List<String> getSubjectList (String grade) {
        if (StringUtils.isBlank(grade)) {
            return MAIN_SUBJECT_LIST;
        }
        int gradeNum = GradeEnum.getIndexByGrade(grade);
        if (gradeNum < 7){
            return MAIN_SUBJECT_LIST;
        }  else {
            return subjectList;
        }
    }

    public static List<String>  getAllSubjectList (){
        return subjectList;
    }
}
