using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TEAMModelOS.SDK.Models.Cosmos.Common
{
    public class Scoring : CosmosEntity
    {
        public Scoring()
        {
            pk = "Scoring";
        }
        public string stuId { get; set; }
        public string examId { get; set; }
        public string subjectId { get; set; }
        public List<Item> items { get; set; } = new List<Item>();
        public string blob { get; set; }
        public List<string> tIds { get; set; } = new List<string>();
        //阅卷次数
        public int  count { get; set; }
        public List<double> scores { get; set; } = new List<double>();
        public int model { get; set; }
        public string mode { get; set; }
        //public long endTime { get; set; }
        //阅卷类型1 正常卷 2 异常卷 3 仲裁卷
        /*public int type { get; set; } = 1;
        public string err { get; set; }*/
        public List<Qs> qs { get; set; } = new List<Qs>();

    }
    public class Qs {
        //阅卷类型1 正常卷 2 异常卷 3 仲裁卷
        public string err { get; set; }
        public string improve { get; set; }
        public string tId { get; set; }
        public int index { get; set; }
    }

    public class Item
    {
        public List<Info> scores { get; set; } = new List<Info>();
        //原题的配分
        public double ssc { get; set; }
        //public string tmdId { get; set; }
        public bool flag
        {
            get
            {
                if (scores.Count >= 2)
                {
                    List<string> sc = scores.Select(s => s.tmdId).Where(c => string.IsNullOrEmpty(c)).ToList();
                    if (sc.Count > 0) {
                        return true;
                    }
                    //double diff = Math.Abs(scores.Where(c => c.identity.Equals("")).Select(s => s.sc).ToList().Aggregate((i, j) => (i - j) * 6));
                    double diff = Math.Abs(scores.Select(s => s.sc).ToList().Aggregate((i, j) => (i - j) * 6));
                    if (diff > ssc)
                    {
                        return false;
                    }
                    else {
                        return true;
                    }
                    
                }
                else
                {
                    return true;
                }

            }
        }
        public int isArb { get {
                if (flag)
                {
                    return 0;
                }
                else {
                    return 1;
                }
            } }

    }
    public class Info { 
        public double sc { get; set; }
        public string tmdId { get; set; }
        //记录老师批注信息
        public string mark { get; set; }
        //记录老师身份信息
        public string identity { get; set; }
        public int index { get;set; }
    }

}
