Browse Source

Merge branch 'develop5.0-tmd' of http://106.12.23.251:10080/TEAMMODEL/TEAMModelOS into develop5.0-tmd

CrazyIter_Bin 4 years ago
parent
commit
3f7d215a71

+ 130 - 59
TEAMModelFunction/TriggerExam.cs

@@ -205,11 +205,13 @@ namespace TEAMModelFunction
                                 };
                                 result.info.id = cla;
                                 List<string> ans = new List<string>();
+                                List<List<string>> anses = new List<List<string>>();
                                 List<double> ansPoint = new List<double>();
                                 List<string> ids = new List<string>();
                                 foreach (double p in info.papers[m].point)
                                 {
                                     //ans.Add(new List<string>());
+                                    anses.Add(new List<string>());
                                     ansPoint.Add(-1);
                                 }
                                 var sresponse = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(cla, new Azure.Cosmos.PartitionKey($"Class-{info.school}"));
@@ -282,6 +284,7 @@ namespace TEAMModelFunction
                                     result.studentIds.Add(stu);
                                     result.studentAnswers.Add(ans);
                                     result.studentScores.Add(ansPoint);
+                                    result.ans.Add(anses);
                                     result.sum.Add(0);
                                 }
 
@@ -424,20 +427,10 @@ namespace TEAMModelFunction
             }
         }
         //处理全部学生选题计数
-        public static async Task examRecordCount(ExamInfo info, ExamSubject subject, DingDing _dingDing, int no, AzureStorageFactory _azureStorage, ExamResult result)
+        public static async Task examRecordCount(ExamInfo info, ExamSubject subject, DingDing _dingDing, int no, ExamResult result, List<ExamClassResult> classResults, AzureCosmosFactory _azureCosmos)
         {
             try
             {
-                string blobcntr = "";
-                if (info.scope.Equals("school"))
-                {
-                    blobcntr = info.school;
-                }
-                else
-                {
-                    blobcntr = info.creatorId;
-                }
-
                 List<double> scores = new List<double>();
                 foreach (List<double> sc in result.studentScores)
                 {
@@ -445,72 +438,144 @@ namespace TEAMModelFunction
                 }
                 //确定高分组 最低分数
                 scores.Sort((s1, s2) => { return s2.CompareTo(s1); });
-
-                double rhwCount = scores.Count * 0.27;
+                double rhwCount = Math.Floor(scores.Count * 0.27);
                 double rhw = rhwCount > 0 ? scores[int.Parse(rhwCount.ToString("0"))] : 0;
-                //double rhw = resultSum[int.Parse(rhwCount.ToString("0"))];
                 //确定低分组 最高分数
-                scores.Sort((s1, s2) => { return s1.CompareTo(s2); });
-                double rhlCount = scores.Count * 0.27;
+                //scores.Sort((s1, s2) => { return s1.CompareTo(s2); });
+                double rhlCount = Math.Ceiling(scores.Count * 0.73);
                 double rhl = rhlCount > 0 ? scores[int.Parse(rhlCount.ToString("0"))] : 0;
                 //存放高分组学生ID
                 List<string> phId = new List<string>();
                 List<string> plId = new List<string>();
-                foreach (string id in result.studentIds)
+                int phcount = 0;
+                int plcount = 0;
+                List<List<List<string>>> opth = new List<List<List<string>>>();
+                List<List<List<string>>> optl = new List<List<List<string>>>();
+                //存放并去重知识点
+                HashSet<string> kname = new HashSet<string>();
+                info.papers[no].knowledge.ForEach(kno =>
                 {
-                    int index = result.studentIds.IndexOf(id);
-                    if (result.studentScores[index].Sum() >= rhw)
+                    kno.ForEach(k =>
                     {
-                        phId.Add(id);
-                        continue;
-                    }
-                    if (result.studentScores[index].Sum() <= rhl)
+                        kname.Add(k);
+                    });
+                });
+                List<string> knowledgeName = new List<string>();
+                foreach (string cla in kname)
+                {
+                    knowledgeName.Add(cla);
+                }
+                for (int k = 0; k < knowledgeName.Count; k++)
+                {
+                    if (null == knowledgeName[k])
                     {
-                        plId.Add(id);
-                        continue;
+                        knowledgeName.Remove(knowledgeName[k]);
                     }
                 }
 
-                var ContainerClient = _azureStorage.GetBlobContainerClient(blobcntr);
-                List<string> items = await ContainerClient.List($"exam/{info.id}/{subject.id}");
-                List<List<List<string>>> ansList = new List<List<List<string>>>();
-                List<List<List<string>>> phAnsList = new List<List<List<string>>>();
-                List<List<List<string>>> plAnsList = new List<List<List<string>>>();
-                List<string> phItems = new List<string>();
-                List<string> plItems = new List<string>();
-                foreach (string item in items)
+                foreach (ExamClassResult classResult in classResults)
                 {
-                    //确定高分组选项内容
-                    foreach (string id in phId) {
-                        if (item.Contains($"/{id}/"))
+                    if (classResult.subjectId.Equals(subject.id)) {
+                        //List<int> phc = new List<int>();
+                        List<int> ph = new List<int>();
+                        List<int> pl = new List<int>();
+                        List<int> pc = new List<int>();
+                        List<double> persent = new List<double>();
+                        for (int i = 0; i < knowledgeName.Count; i++)
                         {
-                            var phDownload = await _azureStorage.GetBlobContainerClient(blobcntr).GetBlobClient(item).DownloadAsync();
-                            var phjson = await JsonDocument.ParseAsync(phDownload.Value.Content);
-                            var phRecord = phjson.RootElement.ToObject<List<List<string>>>();
-                            phAnsList.Add(phRecord);
-                            break;
+                            //初始化单个知识点得分
+                            double score = 0;
+                            double allScore = 0;
+                            int n = 0;
+                            int phCount = 0;
+                            int plCount = 0;
+                            int pCount = 0;
+                            foreach (List<string> str in info.papers[no].knowledge)
+                            {
+                                if (str.Contains(knowledgeName[i]))
+                                {
+                                    var itemPersent = str.Count > 0 ? 1 / Convert.ToDouble(str.Count) : 0;
+                                    allScore += info.papers[no].point[n] * itemPersent;
+                                    foreach (string id in classResult.studentIds)
+                                    {
+                                        int index = classResult.studentIds.IndexOf(id);
+                                        if (classResult.studentScores[index].Count > 0)
+                                        {
+                                            score += classResult.studentScores[index][n];
+                                            if (classResult.studentScores[index].Sum() >= rhw && phcount < rhwCount)
+                                            {
+                                                if (classResult.studentScores[index][n] == 0)
+                                                {
+                                                    phCount++;
+                                                }
+                                                phcount++;
+                                                continue;
+                                            }
+                                            if (classResult.studentScores[index].Sum() <= rhl && plcount < (scores.Count - rhlCount))
+                                            {
+                                                if (classResult.studentScores[index][n] == 0)
+                                                {
+                                                    plCount++;
+                                                }
+                                                plcount++;
+                                                continue;
+                                            }
+                                            if (classResult.studentScores[index][n] == 0)
+                                            {
+                                                pCount++;
+                                            }
+                                        }
+                                    }
+                                }
+                                n++;
+                            }
+                            pc.Add(pCount);
+                            ph.Add(phCount);
+                            pl.Add(plCount);
+                            double per = classResult.studentIds.Count > 0 ? Math.Round(score / classResult.studentIds.Count, 2) : 0;
+                            persent.Add(per / allScore);
                         }
-                    }
-                    //确定低分组选项内容
-                    foreach (string id in plId)
+                        classResult.phc = ph;
+                        classResult.plc = pl;
+                        classResult.pc = pc;
+                        classResult.krate = persent;
+                    }                    
+                    await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(classResult, classResult.id, new Azure.Cosmos.PartitionKey($"{classResult.code}"));
+                }
+                //
+                int PHCount = 0;
+                int PLCount = 0;
+                foreach (ExamClassResult classResult in classResults)
+                {
+                    if (classResult.subjectId.Equals(subject.id))
                     {
-                        if (item.Contains($"/{id}/"))
+                        foreach (string id in classResult.studentIds)
                         {
-                            var plDownload = await _azureStorage.GetBlobContainerClient(blobcntr).GetBlobClient(item).DownloadAsync();
-                            var pljson = await JsonDocument.ParseAsync(plDownload.Value.Content);
-                            var plRecord = pljson.RootElement.ToObject<List<List<string>>>();
-                            plAnsList.Add(plRecord);
-                            break;
+                            int index = classResult.studentIds.IndexOf(id);
+                            if (classResult.studentScores[index].Sum() >= rhw && PHCount < rhwCount)
+                            {
+                                if (classResult.ans.Count > 0)
+                                {
+                                    opth.Add(classResult.ans[index]);
+                                    PHCount++;
+                                    continue;
+                                }
+
+                            }
+                            if (classResult.studentScores[index].Sum() <= rhl && PLCount < (scores.Count - rhlCount))
+                            {
+                                if (classResult.ans.Count > 0)
+                                {
+                                    optl.Add(classResult.ans[index]);
+                                    PLCount++;
+                                    continue;
+                                }
+                            }
                         }
                     }
-                    var Download = await _azureStorage.GetBlobContainerClient(blobcntr).GetBlobClient(item).DownloadAsync();
-                    var json = await JsonDocument.ParseAsync(Download.Value.Content);
-                    var Record = json.RootElement.ToObject<List<List<string>>>();
-                    ansList.Add(Record);
                 }
-                result.record = getMore(info, no, ansList);
-                result.phc = getMore(info, no, phAnsList);
-                result.plc = getMore(info, no, plAnsList);
+                result.phc = getMore(info, no, opth);
+                result.plc = getMore(info, no, optl);
             }
             catch (Exception ex)
             {
@@ -575,11 +640,16 @@ namespace TEAMModelFunction
             List<ClassRange> classRanges = new List<ClassRange>();
             List<string> lostStu = new List<string>();
             List<double> csRate = new List<double>();
+            List<List<List<string>>> opt = new List<List<List<string>>>();
             foreach (ExamClassResult classResult in examClassResults)
             {
                 double classSrate = 0;
                 if (classResult.subjectId.Equals(subject.id))
                 {
+                    foreach (List<List<string>> op in classResult.ans)
+                    {
+                        opt.Add(op);
+                    }
                     //记录缺考学生索引位置
                     int index = 0;
                     foreach (List<double> scores in classResult.studentScores)
@@ -633,8 +703,11 @@ namespace TEAMModelFunction
                     }
                     csRate.Add(result.studentIds.Count > 0 ? Math.Round(classSrate * 1.0 / classResult.studentIds.Count, 2) : 0 / allScore);
                     //powSum += Math.Pow(classSrate - result.average, 2);
+                    //处理选项计数内容
                 }
             }
+            await examRecordCount(info, subject, _dingDing, no, result, examClassResults, _azureCosmos);
+            result.record = getMore(info, no, opt);
             result.average = result.studentIds.Count > 0 ? Math.Round(score * 1.0 / result.studentIds.Count, 2) : 0;
             foreach (ExamClassResult classResult in examClassResults)
             {
@@ -650,8 +723,6 @@ namespace TEAMModelFunction
                 }
 
             }
-            //处理选项计数内容
-            await examRecordCount(info, subject, _dingDing, no, _azureStorage, result);
             result.standard = Math.Round(result.studentIds.Count > 0 ? Math.Pow(powSum / result.studentIds.Count, 0.5) : 0, 2);
             result.csRate = csRate;
             result.lostStus = lostStu;

+ 12 - 5
TEAMModelOS.SDK/Models/Cosmos/Common/ExamClassResult.cs

@@ -6,8 +6,8 @@ using TEAMModelOS.SDK.Context.Attributes.Azure;
 using TEAMModelOS.SDK.DI;
 
 namespace TEAMModelOS.SDK.Models
-{    
-    public class ExamClassResult :CosmosEntity
+{
+    public class ExamClassResult : CosmosEntity
     {
         public ExamClassResult() {
             pk = "ExamClassResult";
@@ -18,6 +18,7 @@ namespace TEAMModelOS.SDK.Models
             studentScores = new List<List<double>>();
             sum = new List<double>();
             mark = new List<string>();
+            ans = new List<List<List<string>>>();
         }
         public string school { get; set; }
         public string examId { get; set; }
@@ -30,16 +31,22 @@ namespace TEAMModelOS.SDK.Models
         //public List<double> point { get; set; }
         public List<string> studentIds { get; set; }
         public List<List<string>> studentAnswers { get; set; }
+        //记录学生客观题选项内容,便于学情分析
+        public List<List<List<string>>> ans { get; set; }
         public List<List<double>> studentScores { get; set; }
-        //蠶蛁
+        //批注
         public List<string> mark { get; set; }
         public string scope { get; set; }
         public List<double> sum { get; set; }
         public double average { get; set; }
-        //等褪等啤腕煦薹
+        //单科单班得分率
         public double srate { get; set; }
-        //等褪等啤梓袧船
+        //单科单班标准差
         public double standard { get; set; }
+        public List<double> krate { get; set; } = new List<double>();
+        public List<int> phc { get; set; } = new List<int>();
+        public List<int> plc { get; set; } = new List<int>();
+        public List<int> pc { get; set; } = new List<int>();
     }
 /*    public class PaperSimple {
         public string id { get; set; }

+ 28 - 6
TEAMModelOS/ClientApp/src/view/learnactivity/CreatePrivEva.vue

@@ -40,17 +40,20 @@
                                 </el-cascader>
                             </FormItem>
                             <FormItem :label="$t('learnActivity.createEv.publishType')" prop="publish">
-                                <RadioGroup v-model="evaluationInfo.publish" style="color:white;">
+                                <!-- <RadioGroup v-model="evaluationInfo.publish" style="color:white;">
                                     <Radio :label="item.value" :key="index" v-for="(item,index) in $GLOBAL.PUBLISH_TYPE()" style="width:120px;">
                                         <span>{{ item.label }}</span>
                                     </Radio>
-                                </RadioGroup>
+                                </RadioGroup> -->
+                                <Checkbox v-model="evaluationInfo.publish" :true-value="$GLOBAL.PUBLISH_TYPE()[0].value" :false-value="$GLOBAL.PUBLISH_TYPE()[1].value" @on-change="publishChange">
+                                    <span style="color:white;margin-left:5px;user-select: none;">{{$GLOBAL.PUBLISH_TYPE()[0].label}}</span>
+                                </Checkbox>
                             </FormItem>
                             <FormItem :label="$t('learnActivity.createEv.startTime')" v-if="evaluationInfo.publish == 1" prop="startTime">
-                                <DatePicker type="datetime" format="yyyy/MM/dd HH:mm" v-model="startTime" split-panels :placeholder="$t('learnActivity.createEv.sTimeHolder')" style="width:100%" @on-change="getDate($event,0)"></DatePicker>
+                                <DatePicker :options="dateOpt" type="datetime" format="yyyy/MM/dd HH:mm" v-model="startTime" split-panels :placeholder="$t('learnActivity.createEv.sTimeHolder')" style="width:100%" @on-change="getDate($event,0)"></DatePicker>
                             </FormItem>
                             <FormItem :label="$t('learnActivity.createEv.endTime')" prop="endTime">
-                                <DatePicker type="datetime" format="yyyy/MM/dd HH:mm" v-model="endTime" split-panels :placeholder="$t('learnActivity.createEv.eTimeHolder')" style="width:100%" @on-change="getDate($event,1)"></DatePicker>
+                                <DatePicker :options="dateOpt1" type="datetime" format="yyyy/MM/dd HH:mm" v-model="endTime" split-panels :placeholder="$t('learnActivity.createEv.eTimeHolder')" style="width:100%" @on-change="getDate($event,1)"></DatePicker>
                             </FormItem>
                         </Form>
                     </vuescroll>
@@ -220,6 +223,16 @@ export default {
             schoolBase: {
                 period: []
             },
+            dateOpt: {
+                disabledDate(date) {
+                    return date && date.valueOf() < Date.now() - 86400000
+                }
+            },
+            dateOpt1: {
+                disabledDate(date) {
+                    return _this.evaluationInfo.startTime && _this.evaluationInfo.startTime > date.valueOf() + 86400000
+                }
+            },
             courseList: [],
             schoolTree: [],
             privateTree: [],
@@ -281,6 +294,12 @@ export default {
         }
     },
     methods: {
+        publishChange(data){
+            if(data == 0){
+                this.startTime = new Date()
+                this.evaluationInfo.startTime = Date.now()
+            }
+        },
         //根据id获取stulist信息
         getListInfo(ids) {
             let requestData = {
@@ -576,6 +595,10 @@ export default {
             if (flag == 0) {
                 this.startTime = value
                 this.evaluationInfo.startTime = new Date(value).getTime()
+                if (this.evaluationInfo.startTime > this.evaluationInfo.endTime) {
+                    this.endTime = undefined
+                    this.evaluationInfo.endTime = undefined
+                }
             } else if (flag == 1) {
                 this.endTime = value
                 this.evaluationInfo.endTime = new Date(value).getTime()
@@ -786,7 +809,7 @@ export default {
     created() {
         // 处理默认时间
         this.startTime = new Date()
-        this.evaluationInfo.startTime = new Date()
+        this.evaluationInfo.startTime = new Date().getTime()
         this.endTime = new Date(new Date(new Date().toLocaleDateString()).getTime() + 2 * 24 * 60 * 60 * 1000 - 1)
         this.evaluationInfo.endTime = new Date(new Date().toLocaleDateString()).getTime() + 2 * 24 * 60 * 60 * 1000 - 1
 
@@ -807,7 +830,6 @@ export default {
         let routerData = this.$route.params.evaluationInfo
         if (routerData !== undefined) {
             this.isEdit = true
-            console.log(routerData)
             this.startTime = new Date(routerData.startTime)
             this.endTime = new Date(routerData.endTime)
             routerData.paperInfo = []

+ 30 - 6
TEAMModelOS/ClientApp/src/view/learnactivity/CreateSchoolEva.vue

@@ -44,17 +44,20 @@
                                 </el-cascader>
                             </FormItem>
                             <FormItem :label="$t('learnActivity.createEv.publishType')" prop="publish">
-                                <RadioGroup v-model="evaluationInfo.publish" style="color:white;">
+                                <!-- <RadioGroup v-model="evaluationInfo.publish" style="color:white;">
                                     <Radio :label="item.value" :key="index" v-for="(item,index) in $GLOBAL.PUBLISH_TYPE()" style="width:120px;">
                                         <span>{{ item.label }}</span>
                                     </Radio>
-                                </RadioGroup>
+                                </RadioGroup> -->
+                                <Checkbox v-model="evaluationInfo.publish" :true-value="$GLOBAL.PUBLISH_TYPE()[0].value" :false-value="$GLOBAL.PUBLISH_TYPE()[1].value" @on-change="publishChange">
+                                    <span style="color:white;margin-left:5px;user-select: none;">{{$GLOBAL.PUBLISH_TYPE()[0].label}}</span>
+                                </Checkbox>
                             </FormItem>
                             <FormItem :label="$t('learnActivity.createEv.startTime')" v-if="evaluationInfo.publish == 1" prop="startTime">
-                                <DatePicker type="datetime" format="yyyy/MM/dd HH:mm" v-model="startTime" split-panels :placeholder="$t('learnActivity.createEv.sTimeHolder')" style="width:100%" @on-change="getDate($event,0)"></DatePicker>
+                                <DatePicker :options="dateOpt" type="datetime" format="yyyy/MM/dd HH:mm" v-model="startTime" split-panels :placeholder="$t('learnActivity.createEv.sTimeHolder')" style="width:100%" @on-change="getDate($event,0)"></DatePicker>
                             </FormItem>
                             <FormItem :label="$t('learnActivity.createEv.endTime')" prop="endTime">
-                                <DatePicker type="datetime" format="yyyy/MM/dd HH:mm" v-model="endTime" split-panels :placeholder="$t('learnActivity.createEv.eTimeHolder')" style="width:100%" @on-change="getDate($event,1)"></DatePicker>
+                                <DatePicker :options="dateOpt1" type="datetime" format="yyyy/MM/dd HH:mm" v-model="endTime" split-panels :placeholder="$t('learnActivity.createEv.eTimeHolder')" style="width:100%" @on-change="getDate($event,1)"></DatePicker>
                             </FormItem>
                         </Form>
                     </vuescroll>
@@ -114,6 +117,7 @@ export default {
         ManualPaper,
     },
     data() {
+        let _this = this
         return {
             schoolClasses: [],
             props: {
@@ -124,6 +128,16 @@ export default {
             schoolBase: {
                 period: []
             },
+            dateOpt: {
+                disabledDate(date) {
+                    return date && date.valueOf() < Date.now() - 86400000
+                }
+            },
+            dateOpt1: {
+                disabledDate(date) {
+                    return _this.evaluationInfo.startTime && _this.evaluationInfo.startTime > date.valueOf() + 86400000
+                }
+            },
             startTime: '',
             endTime: '',
             privClassList: [],
@@ -191,6 +205,12 @@ export default {
         }
     },
     methods: {
+        publishChange(data){
+            if(data == 0){
+                this.startTime = new Date()
+                this.evaluationInfo.startTime = Date.now()
+            }
+        },
         //设置学科名称
         setSubjectName() {
             this.evaluationInfo.subjects = this.curSubjects.filter(item => {
@@ -291,7 +311,7 @@ export default {
         /**
          * 将日期控件时间格式转成时间戳
          * @param value
-         * @param date
+         * @param flag 0 开始时间 1 结束时间
          */
         getDate(value, flag) {
             if (value.indexOf('00:00') > 0) {
@@ -300,6 +320,10 @@ export default {
             if (flag == 0) {
                 this.startTime = value
                 this.evaluationInfo.startTime = new Date(value).getTime()
+                if (this.evaluationInfo.startTime > this.evaluationInfo.endTime) {
+                    this.endTime = undefined
+                    this.evaluationInfo.endTime = undefined
+                }
             } else if (flag == 1) {
                 this.endTime = value
                 this.evaluationInfo.endTime = new Date(value).getTime()
@@ -617,7 +641,7 @@ export default {
     created() {
         // 处理默认时间
         this.startTime = new Date()
-        this.evaluationInfo.startTime = new Date()
+        this.evaluationInfo.startTime = new Date().getTime()
         this.endTime = new Date(new Date(new Date().toLocaleDateString()).getTime() + 2 * 24 * 60 * 60 * 1000 - 1)
         this.evaluationInfo.endTime = new Date(new Date().toLocaleDateString()).getTime() + 2 * 24 * 60 * 60 * 1000 - 1
 

File diff suppressed because it is too large
+ 3826 - 3823
TEAMModelOS/Controllers/Analysis/AchievementController.cs


File diff suppressed because it is too large
+ 349 - 700
TEAMModelOS/Controllers/Analysis/AnalysisController.cs


+ 19 - 3
TEAMModelOS/Controllers/Common/ExamController.cs

@@ -477,6 +477,19 @@ namespace TEAMModelOS.Controllers
                 List<Task<string>> tasks = new List<Task<string>>();
                 foreach (ExamClassResult result in examClassResults) {
                     int index = result.studentIds.IndexOf(studentId.ToString());
+                    //存放客观题作答详情
+                    if (result.ans.Count == 0) {
+                        foreach (string cc in result.studentIds)
+                        {
+                            List<List<string>> anc = new List<List<string>>();
+                            foreach (List<string> opc in standard) {                              
+                                anc.Add(new List<string>());
+                            }
+                            result.ans.Add(anc);
+                        }
+                    }
+                    
+                    //List<List<string>> oq = new List<List<string>>();
                     //classResult.studentAnswers[index] = ans;
                     if (index == -1)
                     {
@@ -514,6 +527,7 @@ namespace TEAMModelOS.Controllers
                     //List<(int index ,string content, double count)> acount = new List<(int index,string content, double count)>();
                     for (int i = 0; i < ans.Count; i++)
                     {
+                        //List<string> op = new List<string>();
                         var ac = ans[i].Count;
                         var sc = standard[i].Count;
                         //记录次数
@@ -522,6 +536,7 @@ namespace TEAMModelOS.Controllers
                         //算分处理
                         if (sc > 0)
                         {
+                            result.ans[index][i] = ans[i];
                             if (ac == sc && sc == 1)
                             {
                                 foreach (string right in ans[i])
@@ -626,13 +641,14 @@ namespace TEAMModelOS.Controllers
                                                 break;
                                         }
                                     }
-                                    else {
+                                    else
+                                    {
                                         result.studentScores[newIndex][i] = 0;
                                     }
-                                    
+
                                 }
                             }
-                        }
+                        }                       
                     }
                     /*if (result.studentScores.Contains(-1)) {