Пример #1
0
        /// <summary>
        /// 取得共評表相關資料
        /// </summary>
        /// <returns></returns>
        private PeerJointSheet CalculateJointSheets()
        {
            var peerJointSheet = new PeerJointSheet()
            {
                SheetOne = new List <PeerJointSheetOne>(),
                SheetTwo = new List <PeerJointSheetTwo>(),
            };

            //讀取共評表一
            using (var reader = new StreamReader(pathOfJointSheetOne))
                using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
                {
                    var records = csv.GetRecords <PeerJointSheetOne>();
                    peerJointSheet.SheetOne = records.ToList();
                }

            //讀取共評表二
            using (var reader = new StreamReader(pathOfJointSheetTwo))
                using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
                {
                    var records = csv.GetRecords <PeerJointSheetTwo>();
                    peerJointSheet.SheetTwo = records.ToList();
                }

            return(peerJointSheet);
        }
Пример #2
0
        /// <summary>
        /// 取得成績、組別及組員資料
        /// </summary>
        /// <param name="groupInformation"></param>
        /// <param name="jointSheetData"></param>
        /// <returns></returns>
        private List <GroupWithGrade> GetGroupWithGradeInformation(List <GroupInformation> groupInformation, PeerJointSheet jointSheetData)
        {
            var groupInfoWithGrade = JsonConvert.DeserializeObject <List <GroupWithGrade> >(JsonConvert.SerializeObject(groupInformation));

            foreach (var group in groupInfoWithGrade)
            {
                //共評表一裡是否有該組別
                Type type         = typeof(PeerJointSheetOne);
                var  hasThisGroup = type.GetProperties().Any(x => x.Name == group.GroupName);
                if (hasThisGroup)
                {
                    group.Records = new Dictionary <string, string>();
                    foreach (var record in jointSheetData.SheetOne)
                    {
                        var propertyInfo = type.GetProperty(group.GroupName);
                        var score        = propertyInfo.GetValue(record).ToString();

                        //教師評分
                        if (record.StudentID.IndexOf("S") > 0)
                        {
                            group.TeachScore = score;
                        }
                        else
                        {
                            if (score != null && score.Length > 0)
                            {
                                group.Records.Add(record.StudentName, score);
                            }
                            //else
                            //{
                            //}
                        }
                    }

                    //if (group.TeachScore == null)
                    //{
                    //}
                }

                //共評表二裡是否有該組別
                type         = typeof(PeerJointSheetTwo);
                hasThisGroup = type.GetProperties().Any(x => x.Name == group.GroupName);
                if (hasThisGroup)
                {
                    group.Records = new Dictionary <string, string>();
                    foreach (var record in jointSheetData.SheetTwo)
                    {
                        var propertyInfo = type.GetProperty(group.GroupName);
                        var score        = propertyInfo.GetValue(record).ToString();

                        //教師評分
                        if (record.StudentID.IndexOf("S") > 0)
                        {
                            group.TeachScore = score;
                        }
                        else
                        {
                            if (score != null && score.Length > 0)
                            {
                                group.Records.Add(record.StudentName, score);
                            }
                            //else
                            //{
                            //}
                        }
                    }

                    //if (group.TeachScore == null)
                    //{
                    //}
                }
            }

            return(groupInfoWithGrade);
        }