123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641 |
- using Microsoft.Azure.Cosmos;
- using Azure.Messaging.ServiceBus;
- using Microsoft.Extensions.Configuration;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Text.Json;
- using System.Threading.Tasks;
- using TEAMModelOS.SDK.DI;
- using TEAMModelOS.SDK.Extension;
- using TEAMModelOS.SDK.Models.Cosmos;
- using static TEAMModelOS.SDK.Models.ClassAnalysis;
- namespace TEAMModelOS.SDK.Models.Service
- {
- public static class ArtService
- {
- public static List<ArtQuota> GetParentByChildId(List<ArtQuota> quotas, string childId) {
- List<ArtQuota> list_quotas = new List<ArtQuota>();
- list_quotas = TreeToList(quotas, list_quotas, null);
- List<ArtQuota> parents = new List<ArtQuota>();
- parents = GetParents(list_quotas, parents, $"{childId}");
- if (parents.IsNotEmpty()) {
- int len = parents.Count;
- parents.ForEach(x => {
- x.level= len-x.level+1;
- });
- }
- return parents;
- }
- private static List<ArtQuota> GetParents(List<ArtQuota> list, List<ArtQuota> parents, string cid, int level = 1)
- {
- var child = list.Find(x => x.id.Equals(cid));
- if (child != null)
- {
- child.level = level;
- parents.Add(child);
- if (!child.pid.Equals(child.id))
- {
- level++;
- return GetParents(list, parents, child.pid, level);
- }
- else
- {
- return parents;
- }
- }
- else { return parents; }
- }
- private static List<ArtQuota> TreeToList(List<ArtQuota> trees, List<ArtQuota> nodes, string pid)
- {
- List<ArtQuota> list = new List<ArtQuota>();
- trees.ForEach(x => {
- var node = new ArtQuota
- {
- pid = string.IsNullOrWhiteSpace(pid) ? x.id : pid,
- id = x.id,
- name = x.name,
- percent = x.percent,
- type = x.type,
- };
- list.Add(node);
- });
- nodes.AddRange(list);
- foreach (ArtQuota tree in trees)
- {
- if (tree.children.IsNotEmpty())
- {
- TreeToList(tree.children, nodes, tree.id);
- }
- }
- return nodes;
- }
- public async static Task GenArtPDF (List<string> studentIds, string _artId, string _schoolId, string head_lang,AzureServiceBusFactory _serviceBus, IConfiguration _configuration)
- {
- var messageBlobPDF = new ServiceBusMessage(new { studentIds, artId= _artId, schoolCode = $"{_schoolId}", headLang= head_lang, bizType = "ArtStudentPdf" }.ToJsonString());
- var GenPdfQueue = _configuration.GetValue<string>("Azure:ServiceBus:GenPdfQueue");
- await _serviceBus.GetServiceBusClient().SendMessageAsync(GenPdfQueue, messageBlobPDF);
- }
- public async static Task<(List<ArtStudentPdf> studentPdfs, List<StudentArtResult> artResults)> GenStuArtPDF(List<string> studentIds, string _artId, ArtEvaluation art, string _schoolId,string head_lang ,AzureCosmosFactory _azureCosmos,
- CoreAPIHttpService _coreAPIHttpService, DingDing _dingDing) {
- var client = _azureCosmos.GetCosmosClient();
- string query = $" select value c from c where c.school = '{_schoolId}' ";
- if (studentIds.Any())
- {
- query = $" select value c from c where c.school = '{_schoolId}' and c.studentId in ({string.Join(",", studentIds.Select(z => $"'{z}'"))})";
- }
- List<StudentArtResult> artResults = new List<StudentArtResult>();
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Student).GetItemQueryIteratorSql<StudentArtResult>
- (queryText: query, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"ArtResult-{_artId}") }))
- {
- artResults.Add(item);
- }
- School school = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).ReadItemAsync<School>($"{_schoolId}", new PartitionKey("Base"));
- string path = Path.Combine("", $"Lang/{head_lang}.json");
- string comment1 = "";
- string comment2 = "";
- string comment3 = "";
- string comment4 = "";
- string comment5 = "";
- string comment_subject_music = "";
- string comment_subject_painting = "";
- var jsonDoc = readFileJson(path);
- if (jsonDoc != null)
- {
- if (jsonDoc.RootElement.TryGetProperty("art-template-comment1", out JsonElement _c1))
- {
- comment1 = $"{_c1}";
- }
- if (jsonDoc.RootElement.TryGetProperty("art-template-comment2", out JsonElement _c2))
- {
- comment2 = $"{_c2}";
- }
- if (jsonDoc.RootElement.TryGetProperty("art-template-comment3", out JsonElement _c3))
- {
- comment3 = $"{_c3}";
- }
- if (jsonDoc.RootElement.TryGetProperty("art-template-comment4", out JsonElement _c4))
- {
- comment4 = $"{_c4}";
- }
- if (jsonDoc.RootElement.TryGetProperty("art-template-comment5", out JsonElement _c5))
- {
- comment5 = $"{_c5}";
- }
- if (jsonDoc.RootElement.TryGetProperty("art-template-subject_music", out JsonElement _subject_music))
- {
- comment_subject_music = $"{_subject_music}";
- }
- if (jsonDoc.RootElement.TryGetProperty("art-template-subject_painting", out JsonElement _subject_painting))
- {
- comment_subject_painting = $"{_subject_painting}";
- }
- }
-
- ArtSetting artSetting = await client.GetContainer(Constant.TEAMModelOS, Constant.Normal).ReadItemAsync<ArtSetting>($"{school.areaId}", new PartitionKey($"ArtSetting"));
- var allExamIds = art.settings.SelectMany(x => x.task).Where(z => z.type == 1);
- var subjects = art.subjects;
- //获取学校的所有艺术科目的uuid,并映射找到相应的知识点,知识块。
- var schoolSubjects = school.period.SelectMany(x => x.subjects).Where(s => !string.IsNullOrWhiteSpace(s.bindId) && subjects.Select(z => z.id).Contains(s.bindId));
- StringBuilder sql = new StringBuilder($"select value(c) from c");
- List<KeyValuePair<string, List<Block>>> subjectBindBlocks = new List<KeyValuePair<string, List<Block>>>();
- foreach (var schSub in schoolSubjects)
- {
- List<Block> blocks = new List<Block>();
- string code = $"Knowledge-{_schoolId}-{schSub.id}";
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School")
- .GetItemQueryIteratorSql<Knowledge>(queryText: sql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
- {
- item.blocks.ForEach(x =>
- {
- var block = blocks.Find(z => z.name.Equals(x.name));
- if (block != null)
- {
- block.points.AddRange(x.points);
- }
- else
- {
- blocks.Add(x);
- }
- });
- }
- subjectBindBlocks.Add(new KeyValuePair<string, List<Block>>(schSub.bindId, blocks));
- }
- List<ExamInfo> exams = new List<ExamInfo>();
- List<ExamResult> examResults = new();
- if (allExamIds.Any())
- {
- var queryExam = $"select value c from c where c.id in ({string.Join(",", allExamIds.Select(x => $"'{x.acId}'"))}) ";
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIteratorSql<ExamInfo>(queryText: queryExam, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Exam-{_schoolId}") }))
- {
- exams.Add(item);
- }
- foreach (var allexamId in allExamIds)
- {
- var queryResult = $"select c.id,c.name,c.subjectId,c.studentScores,c.studentIds,c.paper,c.classes,c.sRate,c.average,c.standard,c.lostStus,c.record,c.phc,c.plc,c.examId from c where c.examId = '{allexamId.acId}' and c.subjectId = '{allexamId.subject}' ";
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIteratorSql<ExamResult>(queryText: queryResult, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamResult-{allexamId.acId}") }))
- {
- examResults.Add(item);
- }
- }
- }
- (List<RMember> rmembers, List<RGroupList> groups) = await GroupListService.GetMemberByListids(_coreAPIHttpService, client, _dingDing, art.classes, art.school);
- List<ArtStudentPdf> studentPdfs = new List<ArtStudentPdf>();
- artResults.ForEach(x =>
- {
- var allSubject = x.results.GroupBy(g => g.quotaId).Select(s => new { key = s.Key, list = s.ToList() }).ToList();
- var groupSubject = x.results.GroupBy(g => $"{g.quotaId}-{g.subjectId}").Select(s => new { key = s.Key, list = s.ToList() }).ToList();
- //综合-所有科目的艺术评测指标维度。
- List<ArtQuotaPdf> allSubjectArtQuotaPdfs = new List<ArtQuotaPdf>();
- allSubject.ForEach(a =>
- {
- ArtQuotaPdf artPdf = new ArtQuotaPdf();
- List<ArtQuota> parents = ArtService.GetParentByChildId(artSetting.quotas, $"{a.key}");
- parents.ForEach(x =>
- {
- switch (true)
- {
- case bool when x.level == 1:
- artPdf.quota1 = x.id;
- artPdf.quotaN1 = x.name;
- artPdf.quotaP1 = x.percent;
- if (a.key.Equals(x.id))
- {
- artPdf.quotaName = x.name;
- }
- break;
- case bool when x.level == 2:
- artPdf.quota2 = x.id;
- artPdf.quotaN2 = x.name;
- artPdf.quotaP2 = x.percent;
- if (a.key.Equals(x.id))
- {
- artPdf.quotaName = x.name;
- }
- break;
- case bool when x.level == 3:
- artPdf.quota3 = x.id;
- artPdf.quotaN3 = x.name;
- artPdf.quotaP3 = x.percent;
- if (a.key.Equals(x.id))
- {
- artPdf.quotaName = x.name;
- }
- break;
- }
- });
- var noneScore = a.list.FindAll(x => x.score == -1);
- if (!noneScore.IsNotEmpty())
- {
- //全部未打分。
- if (noneScore.Count >= art.subjects.Count)
- {
- artPdf.quotaId = a.key;
- artPdf.score = 0;
- artPdf.scoreData = "-";
- artPdf.percent = "0";
- }
- else
- {
- //有一部分打分的,只算有分的平均分。
- var hasScore = a.list.FindAll(x => x.score >= 0);
- if (hasScore.IsNotEmpty())
- {
- var avgScore = hasScore.Sum(x => x.score) * 1.0 / a.list.Count;
- var avg = decimal.Round(decimal.Parse($"{avgScore}"), 2);
- artPdf.quotaId = a.key;
- artPdf.score = double.Parse($"{avg}");
- artPdf.scoreData = $"{avg}";
- artPdf.percent = $"{avg}";
- }
- else
- {
- artPdf.quotaId = a.key;
- artPdf.score = 0;
- artPdf.scoreData = "-";
- artPdf.percent = "0";
- }
- }
- }
- else
- {
- artPdf.quotaId = a.key;
- artPdf.score = 0;
- artPdf.scoreData = "-";
- artPdf.percent = "0";
- }
- allSubjectArtQuotaPdfs.Add(artPdf);
- });
- string level = "";
- double allScore = 0;
- if (x.subjectScores.Any())
- {
- //allScore = allSubjectArtQuotaPdfs.Sum(a => a.score) / allSubjectArtQuotaPdfs.Count;
- // allScore = allSubjectArtQuotaPdfs.Sum(a => a.score) / allSubjectArtQuotaPdfs.Count;
- allScore=Math.Round(x.subjectScores.Sum(a => a.score)*1.0/ x.subjectScores.Count,2) ;
- foreach (var xs in x.subjectScores)
- {
- var slevel = string.Empty;
- if (xs.score >= 100)
- {
- slevel = "优秀(A+)";
- }
- if (xs.score <= 0)
- {
- slevel = "待及格(D)";
- }
- if (xs.score < 100)
- {
- artSetting.reviewLevel.ForEach(r =>
- {
- if (r.value[0] <= xs.score && r.value[1] > xs.score)
- {
- slevel = r.code;
- }
- });
- }
- xs.level = slevel;
- }
- }
- if (allScore >= 100)
- {
- allScore = 100;
- level = "优秀(A+)";
- }
- if (allScore <= 0)
- {
- allScore = 0;
- level = "待及格(D)";
- }
- if (allScore < 100)
- {
- artSetting.reviewLevel.ForEach(r =>
- {
- if (r.value[0] <= allScore && r.value[1] > allScore)
- {
- level = r.code;
- }
- });
- }
- var rmbs = rmembers.FindAll(r => r.id.Equals(x.studentId) && r.type == 2 && x.code.Equals(x.school));
- if (rmbs.IsNotEmpty())
- {
- x.studentName = rmbs[0].name;
- }
- List<string> classNames = new List<string>();
- HashSet<string> periodIds = new HashSet<string>();
- x.classIds.ForEach(c =>
- {
- var gps = groups.FindAll(g => g.id.Equals(c));
- if (gps.IsNotEmpty())
- {
- classNames.Add(gps[0].name);
- if (!string.IsNullOrWhiteSpace(gps[0].periodId))
- {
- periodIds.Add(gps[0].periodId);
- }
- }
- });
- allSubjectArtQuotaPdfs.ForEach(x => x.level = level);
- var allSubjectQuotas = allSubjectArtQuotaPdfs.OrderBy(o => o.quota1).ThenBy(o => o.quota2).ThenBy(o => o.quota3);
- StringBuilder comment = new StringBuilder();
- switch (true)
- {
- case bool when level.Contains("(A+)"):
- comment.Append(comment1.Replace("{studentName}", x.studentName).Replace("{level}", "表现优异"));
- break;
- case bool when level.Contains("(A)"):
- comment.Append(comment1.Replace("{studentName}", x.studentName).Replace("{level}", "表现优秀"));
- break;
- case bool when level.Contains("(B+)"):
- comment.Append(comment1.Replace("{studentName}", x.studentName).Replace("{level}", "表现优良"));
- break;
- case bool when level.Contains("(B)"):
- comment.Append(comment1.Replace("{studentName}", x.studentName).Replace("{level}", "表现良好"));
- break;
- case bool when level.Contains("(C+)"):
- comment.Append(comment1.Replace("{studentName}", x.studentName).Replace("{level}", "还需加强"));
- break;
- case bool when level.Contains("(C)"):
- comment.Append(comment1.Replace("{studentName}", x.studentName).Replace("{level}", "有待提高"));
- break;
- case bool when level.Contains("(D)"):
- comment.Append(comment1.Replace("{studentName}", x.studentName).Replace("{level}", "还需努力"));
- break;
- }
- var score80 = allSubjectArtQuotaPdfs.Where(x => x.score >= 80);
- if (score80.Any())
- {
- List<string> quota = new List<string>();
- var quota3s = score80.Where(c => !string.IsNullOrWhiteSpace(c.quota3)).Select(z => z.quotaN3);
- if (quota3s.Any())
- {
- quota.AddRange(quota3s);
- }
- var quota2s = score80.Where(c => string.IsNullOrWhiteSpace(c.quota3) && !string.IsNullOrWhiteSpace(c.quota2)).Select(z => z.quotaN2);
- if (quota2s.Any())
- {
- quota.AddRange(quota2s);
- }
- comment.Append(comment2.Replace("{quotasHigh}", string.Join("、", quota)));
- }
- var score60 = allSubjectArtQuotaPdfs.Where(x => x.score < 60);
- if (score60.Any())
- {
- List<string> quota = new List<string>();
- var quota3s = score60.Where(c => !string.IsNullOrWhiteSpace(c.quota3)).Select(z => z.quotaN3);
- if (quota3s.Any())
- {
- quota.AddRange(quota3s);
- }
- var quota2s = score60.Where(c => string.IsNullOrWhiteSpace(c.quota3) && !string.IsNullOrWhiteSpace(c.quota2)).Select(z => z.quotaN2);
- if (quota2s.Any())
- {
- quota.AddRange(quota2s);
- }
- comment.Append(comment3.Replace("{quotasLow}", string.Join("、", quota)));
- }
- string periodId = "";
- string periodName = "";
- if (periodIds.Any())
- {
- var ps = school.period.FindAll(x => periodIds.Contains(x.id));
- if (ps.Any())
- {
- periodName = String.Join(",", ps.Select(x => x.name));
- periodId = String.Join(",", ps.Select(x => x.id));
- }
- }
- List<ArtSubjectPdf> subjectPdfs = new List<ArtSubjectPdf>();
- exams.ForEach(exam => {
- var result = examResults.FindAll(e => e.examId.Equals(exam.id));
- if (result.Any())
- {
- var datas = DoKnowledgePoint(result.First(), exam, x.studentId);
- if (exam.subjects.Any())
- {
- ArtSubjectPdf artSubjectPdf = new ArtSubjectPdf()
- {
- subjectId = exam.subjects.First().id,
- subjectName = exam.subjects.First().name
- };
- datas.pointScores.Value.ForEach(k => {
- var artPointPdfs = GetBlockAndDimension(k.score, k.tscore, artSubjectPdf.subjectId, k.name, subjectBindBlocks, artSetting);
- artSubjectPdf.pointPdfs.AddRange(artPointPdfs);
- });
- var pointHigh = artSubjectPdf.pointPdfs.Where(z => z.percent >= 0.8).Select(z => z.point).ToHashSet();
- var pointLow = artSubjectPdf.pointPdfs.Where(z => z.percent < 0.6).Select(z => z.point).ToHashSet();
- StringBuilder comment = new StringBuilder();
- if (pointHigh.Any())
- {
- comment.Append(comment4.Replace("{pointHigh}", string.Join("、", pointHigh)));
- }
- if (pointLow.Any())
- {
- comment.Append(comment5.Replace("{pointLow}", string.Join("、", pointLow)));
- }
- string custom_comment = string.Empty;
- if (artSubjectPdf.subjectId.Equals("subject_music"))
- {
- comment.Append(comment_subject_music);
- var dbcomment= x.subjectScores.Find(d => d.subjectId.Equals("subject_music"));
- custom_comment=dbcomment?.comment;
- }
- if (artSubjectPdf.subjectId.Equals("subject_painting"))
- {
- comment.Append(comment_subject_painting);
- var dbcomment = x.subjectScores.Find(d => d.subjectId.Equals("subject_painting"));
- custom_comment=dbcomment?.comment;
- }
- artSubjectPdf.comment = string.IsNullOrWhiteSpace(custom_comment)? comment.ToString():custom_comment;
- subjectPdfs.Add(artSubjectPdf);
- }
- }
- });
- ArtStudentPdf studentPdf = new ArtStudentPdf
- {
- artId = art.id,
- schoolCode = school.id,
- schoolName = school.name,
- periodId = periodId,
- periodName = periodName,
- studentId = x.studentId,
- studentName = x.studentName,
- picture = x.picture,
- classNames = classNames,
- artName = art.name,
- level = level,
- score = allScore,
- allSubjectQuotas = allSubjectQuotas.ToList(),
- comment =string.IsNullOrWhiteSpace(x.comment) ? comment.ToString() : x.comment,
- subjectPdfs = subjectPdfs,
- subjectScores=x.subjectScores,
- results=x.results
- };
- studentPdfs.Add(studentPdf);
- });
- // _ = _httpTrigger.RequestHttpTrigger(new { studentPdfs = studentPdfs, artResults, schoolCode = $"{_schoolId}" }, _option.Location, "gen-art-pdf");
-
- return (studentPdfs, artResults);
- }
- private static JsonDocument readFileJson(string path)
- {
- var sampleJson = System.IO.File.ReadAllBytes(path).AsSpan();
- Utf8JsonReader reader = new Utf8JsonReader(sampleJson);
- if (JsonDocument.TryParseValue(ref reader, out JsonDocument jsonDoc))
- {
- return jsonDoc;
- }
- else
- {
- return null;
- }
- }
- //获取本次评测所有科目结算结果
- /* List<ExamResult> examResults = new();
- ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(examId.ToString(), new PartitionKey($"Exam-{code}"));
- var query = $"select c.id,c.name,c.subjectId,c.studentScores,c.studentIds,c.paper,c.classes,c.sRate,c.average,c.standard,c.lostStus,c.record,c.phc,c.plc from c where c.examId = '{examId}' and c.subjectId = '{subjectId}' ";
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIteratorSql<ExamResult>(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamResult-{examId}") }))
- {
- examResults.Add(item);
- }*/
- private static (KeyValuePair<string, List<string>> knowledgeName,
- KeyValuePair<string, List<(string name, double score)>> pointScore,
- KeyValuePair<string, List<(string name, double score)>> pointTScore,
- KeyValuePair<string, List<(string name, double score, double tscore)>> pointScores) DoKnowledgePoint(ExamResult exam, ExamInfo info, string studentId)
- {
- HashSet<string> knowledge = new();
- List<double> point = new();
- List<List<double>> result = new();
- List<ClassRange> classes = new();
- //定位试卷信息
- int index = 0;
- foreach (ExamSubject subject in info.subjects)
- {
- if (subject.id.Equals(exam.subjectId))
- {
- break;
- }
- else
- {
- index++;
- }
- }
- if (info.papers[index].knowledge != null && info.papers[index].knowledge.Count > 0)
- {
- info.papers[index].knowledge.ForEach(k =>
- {
- k.ForEach(e =>
- {
- knowledge.Add(e);
- });
- });
- }
- else
- {
- return (default, default, default, default);
- }
- point = info.papers[index].point;
- result = exam.studentScores;
- classes = exam.classes;
- List<string> knowledgeName = new List<string>();
- foreach (string cla in knowledge)
- {
- knowledgeName.Add(cla);
- }
- for (int k = 0; k < knowledgeName.Count; k++)
- {
- if (null == knowledgeName[k])
- {
- knowledgeName.Remove(knowledgeName[k]);
- }
- }
- List<double> knowScore = new();
- //学生得分情况
- List<(string name, double score)> pointScore = new();
- List<(string name, double score)> pointTScore = new();
- List<(string name, double score, double tscore)> pointScores = new();
- for (int k = 0; k < knowledgeName.Count; k++)
- {
- double OnePoint = 0;
- List<string> itemNo = new();
- int n = 0;
- double scores = 0;
- info.papers[index].knowledge.ForEach(kno =>
- {
- if (kno.Contains(knowledgeName[k]))
- {
- var itemPersent = kno.Count > 0 ? 1 / Convert.ToDouble(kno.Count) : 0;
- OnePoint += point[n] * itemPersent;
- int stuIndex = exam.studentIds.IndexOf(studentId);
- if (exam.studentScores[stuIndex][n] > 0)
- {
- scores += exam.studentScores[stuIndex][n] * itemPersent;
- }
- }
- n++;
- });
- //单个知识点的配分
- pointScore.Add((knowledgeName[k], OnePoint));
- pointTScore.Add((knowledgeName[k], scores));
- pointScores.Add((knowledgeName[k], OnePoint, scores));
- }
- KeyValuePair<string, List<string>> key1 = new(exam.subjectId, knowledgeName);
- KeyValuePair<string, List<(string name, double score)>> key2 = new(exam.subjectId, pointScore);
- KeyValuePair<string, List<(string name, double score)>> key3 = new(exam.subjectId, pointTScore);
- KeyValuePair<string, List<(string name, double score, double tscore)>> key4 = new(exam.subjectId, pointScores);
- return (key1, key2, key3, key4);
- }
- private static List<ArtPointPdf> GetBlockAndDimension(double score, double tscore, string subjectId, string point, List<KeyValuePair<string, List<Block>>> subjectBindBlocks, ArtSetting artSetting)
- {
- var block = subjectBindBlocks.Find(z => z.Key.Equals(subjectId));
- List<ArtPointPdf> artPointPdfs = new List<ArtPointPdf>();
- if (!string.IsNullOrWhiteSpace(block.Key))
- {
- block.Value.ForEach(z => {
- if (z.points.Contains(point))
- {
- var dims = artSetting.dimensions.FindAll(m => m.blocks.Contains(z.name));
- if (dims.Any())
- {
- foreach (var dim in dims)
- {
- artPointPdfs.Add(
- new ArtPointPdf
- {
- dimension = dim.dimension,
- block = z.name,
- point = point,
- totalScore = score,
- score = tscore,
- percent = score > 0 ? tscore * 1.0 / score : 0,
- }
- );
- }
- }
- }
- });
- }
- return artPointPdfs;
- }
- }
- }
|