/* * JHSCETakeRecord * <Extension> * <Effort>0</Effort> * <Text/> * <Score>56</Score> * <AssignmentScore>56</AssignmentScore> * </Extension> */ /* * JHAEIncludeRecord * <Extension> * <UseScore>是</UseScore> * <UseEffort>否</UseEffort> * <UseText>否</UseText> * <UseAssignmentScore>是</UseAssignmentScore> * </Extension> */ public TakeScore(JHSCETakeRecord sceTake, AEIncludeData include) { SCETakeData scedata = new SCETakeData(sceTake); AEIncludeData aedata = include; //為了效率... Text = scedata.Text; Effort = null; Value = null; Weight = include.Weight; if (Program.Mode == ModuleMode.KaoHsiung) { if (aedata.UseScore) { Value = scedata.Score; } if (aedata.UseEffort) { Effort = scedata.Effort; } } else if (Program.Mode == ModuleMode.HsinChu) { decimal sum = 0, weight = 0; if (aedata.UseScore && scedata.Score.HasValue) { sum += scedata.Score.Value; weight++; } if (aedata.UseAssignmentScore && scedata.AssignmentScore.HasValue) { sum += scedata.AssignmentScore.Value; weight++; } if (weight > 0) { Value = (sum / weight); } } else { throw new ArgumentException(string.Format("沒有此種縣市的處理方式({0})。", Program.Mode.ToString())); } }
/* * JHSCETakeRecord * <Extension> * <Effort>0</Effort> * <Text/> * <Score>56</Score> * <AssignmentScore>56</AssignmentScore> * </Extension> */ /* * JHAEIncludeRecord * <Extension> * <UseScore>是</UseScore> * <UseEffort>否</UseEffort> * <UseText>否</UseText> * <UseAssignmentScore>是</UseAssignmentScore> * </Extension> */ public TakeScore(JHSCETakeRecord sceTake, AEIncludeData include) { SCETakeData scedata = new SCETakeData(sceTake); AEIncludeData aedata = include; //為了效率... Text = scedata.Text; Effort = null; Value = null; Weight = include.Weight; if (Program.Mode == ModuleMode.KaoHsiung) { if (aedata.UseScore) { Value = scedata.Score; } if (aedata.UseEffort) { Effort = scedata.Effort; } } else if (Program.Mode == ModuleMode.HsinChu) { // 預設取得比例 decimal scoreWeight = 0, assignmentWeight = 0, totalWeight = 0; decimal?totalScore = null; // 使用系統內預設比例 if (Util.ScorePercentageHSDict.ContainsKey(aedata.RefAssessmentSetupID)) { scoreWeight = Util.ScorePercentageHSDict[aedata.RefAssessmentSetupID]; assignmentWeight = 100 - scoreWeight; } if (aedata.UseScore && !aedata.UseAssignmentScore) { scoreWeight = 100; assignmentWeight = 0; } if (!aedata.UseScore && aedata.UseAssignmentScore) { scoreWeight = 0; assignmentWeight = 100; } if (!aedata.UseScore && !aedata.UseAssignmentScore) { scoreWeight = 0; assignmentWeight = 0; } if (scedata.Score.HasValue && Program.ScoreValueMap.ContainsKey(scedata.Score.Value)) { if (!Program.ScoreValueMap[scedata.Score.Value].AllowCalculation) { scoreWeight = 0; assignmentWeight = 100; } } if (scedata.AssignmentScore.HasValue && Program.ScoreValueMap.ContainsKey(scedata.AssignmentScore.Value)) { if (!Program.ScoreValueMap[scedata.AssignmentScore.Value].AllowCalculation) { scoreWeight = 100; assignmentWeight = 0; } } if (scoreWeight > 0 && scedata.Score.HasValue) { if (Program.ScoreValueMap.ContainsKey(scedata.Score.Value)) { if (Program.ScoreValueMap[scedata.Score.Value].AllowCalculation) { totalScore = (totalScore == null ? 0 : totalScore) + Program.ScoreValueMap[scedata.Score.Value].Score.Value * scoreWeight; totalWeight += scoreWeight; } } else { totalScore = (totalScore == null ? 0 : totalScore) + scedata.Score.Value * scoreWeight; totalWeight += scoreWeight; } } if (assignmentWeight > 0 && scedata.AssignmentScore.HasValue) { if (Program.ScoreValueMap.ContainsKey(scedata.AssignmentScore.Value)) { if (Program.ScoreValueMap[scedata.AssignmentScore.Value].AllowCalculation) { totalScore = (totalScore == null ? 0 : totalScore) + Program.ScoreValueMap[scedata.AssignmentScore.Value].Score.Value * assignmentWeight; totalWeight += assignmentWeight; } } else { totalScore = (totalScore == null ? 0 : totalScore) + scedata.AssignmentScore.Value * assignmentWeight; totalWeight += assignmentWeight; } } //if (aedata.UseScore && scedata.Score.HasValue) //{ // totalScore += scedata.Score.Value * scoreWeight; // totalWeight += scoreWeight; //} //if (aedata.UseAssignmentScore && scedata.AssignmentScore.HasValue) //{ // totalScore += scedata.AssignmentScore.Value * assignmentWeight; // totalWeight += assignmentWeight; //} if (totalWeight != 0) { Value = totalScore / totalWeight; } else { Value = null; } //// 原本作法 //decimal sum = 0, weight = 0; //if (aedata.UseScore && scedata.Score.HasValue) //{ // sum += scedata.Score.Value; // weight++; //} //if (aedata.UseAssignmentScore && scedata.AssignmentScore.HasValue) //{ // sum += scedata.AssignmentScore.Value; // weight++; //} //if (weight > 0) // Value = (sum / weight); } else { throw new ArgumentException(string.Format("沒有此種縣市的處理方式({0})。", Program.Mode.ToString())); } }