Browse Source

Merge branch 'develop3.0-tmd' into develop3.0

JAELYS 4 years ago
parent
commit
9b60d53a57

+ 22 - 5
TEAMModelFunction/ExamTrigger.cs

@@ -20,17 +20,34 @@ namespace TEAMModelFunction
             ExamInfo info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(input.Id, new Azure.Cosmos.PartitionKey($"{code}"));
             List<ExamClassResult> examClassResults = new List<ExamClassResult>();
             List<ExamSubject> examSubjects = new List<ExamSubject>();
-            await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: $"select value(c) from c where c.examId = '{info.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"ExamClassResult-{school}") }))
+            if (info.scope.Equals("teacher", StringComparison.OrdinalIgnoreCase) || info.scope.Equals("private", StringComparison.OrdinalIgnoreCase))
             {
-                using var json = await JsonDocument.ParseAsync(item.ContentStream);
-                if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
+                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: $"select value(c) from c where c.examId = '{info.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"ExamClassResult-{info.creatorId}") }))
                 {
-                    foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
+                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                     {
-                        examClassResults.Add(obj.ToObject<ExamClassResult>());
+                        foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
+                        {
+                            examClassResults.Add(obj.ToObject<ExamClassResult>());
+                        }
+                    }
+                }
+            }
+            else {
+                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: $"select value(c) from c where c.examId = '{info.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"ExamClassResult-{school}") }))
+                {
+                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
+                    {
+                        foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
+                        {
+                            examClassResults.Add(obj.ToObject<ExamClassResult>());
+                        }
                     }
                 }
             }
+            
 
             List<ChangeRecord> records = await _azureStorage.FindListByDict<ChangeRecord>(new Dictionary<string, object>() { { "RowKey", input.Id }, { "PartitionKey", info.progress } });
             //ChangeRecord record = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ChangeRecord>(input.Id, new Azure.Cosmos.PartitionKey($"{info.progress}"));

+ 14 - 7
TEAMModelFunction/MonitorServicesBus.cs

@@ -151,14 +151,21 @@ namespace TEAMModelFunction
         public async Task Blob([ServiceBusTrigger("active-task", "blob", Connection = "Azure:ServiceBus:ConnectionString")] string msg) {
             try
             {
-                await _dingDing.SendBotMsg($"ServiceBus,Blob(){msg}", GroupNames.醍摩豆服務運維群組);
+               // await _dingDing.SendBotMsg($"ServiceBus,Blob(){msg}", GroupNames.醍摩豆服務運維群組);
                 var jsonMsg = JsonDocument.Parse(msg);
-                jsonMsg.RootElement.TryGetProperty("code", out JsonElement name);
-                var client = _azureStorage.GetBlobContainerClient($"{name}");
-                var size = await client.GetBlobsCatalogSize();
-                await _azureRedis.GetRedisClient(8).HashSetAsync($"Blob:Record",new RedisValue($"{name}"),new RedisValue($"{long.Parse($"{size.Item1}")}"));
-                await _dingDing.SendBotMsg($"ServiceBus,Blob() 容器:{name}更新大小:{size.Item1}",
-                        GroupNames.醍摩豆服務運維群組);
+                if(jsonMsg.RootElement.TryGetProperty("name", out JsonElement name)&& name.ValueKind==JsonValueKind.String)
+                {
+                    var client = _azureStorage.GetBlobContainerClient($"{name}");
+                    var size = await client.GetBlobsCatalogSize();
+                    await _azureRedis.GetRedisClient(8).HashSetAsync($"Blob:Record", new RedisValue($"{name}"), new RedisValue($"{long.Parse($"{size.Item1}")}"));
+                    foreach (var key in size.Item2.Keys)
+                    {
+                        await _azureRedis.GetRedisClient(8).SortedSetRemoveAsync($"Blob:Catalog:{name}", key);
+                        await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync($"Blob:Catalog:{name}", key, size.Item2[key].HasValue ? size.Item2[key].Value : 0);
+                    }
+                    await _dingDing.SendBotMsg($"ServiceBus,Blob() 容器:{name}使用:{size.Item1},文件分类:{size.Item2.ToJsonString()}",
+                            GroupNames.醍摩豆服務運維群組);
+                }
             }
             catch (Exception ex)
             {

+ 6 - 0
TEAMModelOS/ClientApp/src/view/learnactivity/MgtPrivEva.less

@@ -258,3 +258,9 @@
     color: white;
     border-radius: 2px;
 }
+.mock-stu-answer{
+    margin-right: 20px;
+}
+.mock-tea-scoring{
+    margin-right: 40px;
+}

+ 66 - 4
TEAMModelOS/ClientApp/src/view/learnactivity/MgtPrivEva.vue

@@ -54,6 +54,15 @@
                     <span :class="curBarIndex == 1 ? 'evalustion-bar-item line-bottom-active line-bottom':'evalustion-bar-item line-bottom'" @click="selectBar(1)">
                         {{$t('learnActivity.mgtScEv.tab2')}}
                     </span>
+                    <!-- <div style="float:right;" v-show="evaListShow[curEvaIndex] && evaListShow[curEvaIndex].progress == 'going'"> -->
+                    <div style="float:right;">
+                        <Tooltip :content="$t('learnActivity.mgtScEv.autoTips1')" :max-width="240">
+                            <Button type="success" size="small" :loading="answerLoading" class="mock-stu-answer" @click="mockAnswer">{{$t('learnActivity.mgtScEv.autoAnswer')}}</Button>
+                        </Tooltip>
+                        <Tooltip :content="$t('learnActivity.mgtScEv.autoTips2')" :max-width="240">
+                            <Button type="warning" size="small" :loading="scoreLoading" class="mock-tea-scoring" @click="mockScoring">{{$t('learnActivity.mgtScEv.autoScore')}}</Button>
+                        </Tooltip>
+                    </div>
                 </div>
                 <!--试卷信息-->
                 <div :class="curBarIndex == 1 ? 'animated fadeIn evaluation-base-info':'evaluation-base-info animated fadeOutRight'" v-show="curBarIndex == 1">
@@ -86,6 +95,7 @@ export default {
         TestPaper,
         Scoring
     },
+    inject: ['reload'],
     data() {
         return {
             split1: 0.2,
@@ -102,10 +112,56 @@ export default {
             filterPeriod: undefined,
             schoolBase: {
                 period: []
-            }
+            },
+            scoreLoading: false,
+            answerLoading: false
         }
     },
     methods: {
+        // 模拟教师评分数据
+        mockScoring() {
+            this.scoreLoading = true
+            this.$api.learnActivity.mockScoring({
+                id: this.evaListShow[this.curEvaIndex].id,
+                code: this.evaListShow[this.curEvaIndex].code.replace('Exam-', '')
+            }).then(
+                res => {
+                    setTimeout(() => {
+                        this.$Message.success(this.$t('learnActivity.mgtScEv.mockOk'))
+                    }, 500)
+                },
+                err => {
+                    this.$Message.error(this.$t('learnActivity.mgtScEv.mockErr'))
+                }
+            ).finally(() => {
+                setTimeout(() => {
+                    this.scoreLoading = false
+                    this.reload()
+                }, 500)
+            })
+        },
+        // 模拟学生作答数据
+        mockAnswer() {
+            this.answerLoading = true
+            this.$api.learnActivity.mockAnswer({
+                id: this.evaListShow[this.curEvaIndex].id,
+                code: this.evaListShow[this.curEvaIndex].code.replace('Exam-', '')
+            }).then(
+                res => {
+                    setTimeout(() => {
+                        this.$Message.success(this.$t('learnActivity.mgtScEv.mockOk'))
+                    }, 500)
+                },
+                err => {
+                    this.$Message.error(this.$t('learnActivity.mgtScEv.mockErr'))
+                }
+            ).finally(() => {
+                setTimeout(() => {
+                    this.answerLoading = false
+                    this.reload()
+                }, 500)
+            })
+        },
         handleEnd(index) {
             this.$Modal.confirm({
                 title: this.$t('learnActivity.mgtScEv.stopTitle'),
@@ -297,10 +353,16 @@ export default {
                 async res => {
                     if (!res.error) {
                         let resData = res.examInfo[0]
+                        resData.score = 0
                         for (let index in resData.papers) {
-                            resData.papers[index].scope = resData.scope
-                            resData.papers[index].examId = resData.id
-                            resData.papers[index] = await this.$evTools.getFullPaper(resData.papers[index])
+                            resData.score += resData.papers[index].point.reduce((total, item) => {
+                                return total + parseInt(item)
+                            }, 0)
+                            if (resData.papers[index].blob) {
+                                resData.papers[index].scope = resData.scope
+                                resData.papers[index].examId = resData.id
+                                resData.papers[index] = await this.$evTools.getFullPaper(resData.papers[index])
+                            }
                         }
                         this.evaListShow.splice(this.curEvaIndex, 1, resData)
                         this.examDetaiInfo = resData

+ 2 - 2
TEAMModelOS/ClientApp/src/view/learnactivity/Scoring.vue

@@ -259,8 +259,8 @@ export default {
             if (!this.chooseClass) return;
             let requestData = {
                 id: this.chooseClass,
-                scope: this.routerScope,
-                school_code: this.routerScope == 'school' ? this.$store.state.userInfo.schoolCode : this.$store.state.userInfo.TEAMModelId,
+                scope: this.examInfo.scope == 'private' ? 'private' : 'school',
+                school_code: this.examInfo.scope == 'private' ? this.$store.state.userInfo.TEAMModelId : this.$store.state.userInfo.schoolCode,
             };
             this.$api.schoolSetting.getClassroomStudent(requestData).then((res) => {
                 if (!res.error) {

+ 36 - 20
TEAMModelOS/ClientApp/src/view/learnactivity/SimpleAnalysis.vue

@@ -78,6 +78,14 @@
                 </span>
             </div>
         </div>
+        <div v-show="calculating">
+            <p style="text-align: center;color: white;margin: 20px 0px;">
+                成绩数据结算中,
+                <span style="text-decoration: underline;color: #1cc0f3;cursor: pointer;" @click="reload()">
+                    点此刷新
+                </span>
+            </p>
+        </div>
     </div>
 </template>
 <script>
@@ -88,6 +96,7 @@ export default {
         AvgCompare,
         ScoreMatrix
     },
+    inject: ['reload'],
     props: {
         examInfo: {
             default: () => {
@@ -114,7 +123,8 @@ export default {
     data() {
         return {
             simpleData: {},
-            allData: {}
+            allData: {},
+            calculating: false
         }
     },
     methods: {
@@ -127,20 +137,26 @@ export default {
             this.$api.learnActivity.simpleAna(requestData).then(
                 res => {
                     if (!res.error) {
-                        for (let i in res.averageMap) {
-                            for (let j in res.averageMap[i].ClassAverage) {
-                                res.averageMap[i].ClassAverage[j] = parseFloat(res.averageMap[i].ClassAverage[j].toFixed(2))
-                            }
-                            let subject = this.examInfo.papers.find(item=>{
-                                return item.subjectId == res.averageMap[i].subjectId
-                            })
-                            if(subject){
-                                res.averageMap[i].subjectId = subject.subjectName
+                        if (res.averageMap.length && res.averageMap.length) {
+                            this.calculating = false
+                            for (let i in res.averageMap) {
+                                for (let j in res.averageMap[i].ClassAverage) {
+                                    res.averageMap[i].ClassAverage[j] = parseFloat(res.averageMap[i].ClassAverage[j].toFixed(2))
+                                }
+                                let subject = this.examInfo.papers.find(item => {
+                                    return item.subjectId == res.averageMap[i].subjectId
+                                })
+                                if (subject) {
+                                    res.averageMap[i].subjectId = subject.subjectName
+                                }
                             }
+                            this.allData[this.examInfo.id] = res
+                            this.simpleData = res
+                        } else {
+                            this.calculating = true
+                            this.$Message.error('数据结算中,请稍后查看')
                         }
 
-                        this.allData[this.examInfo.id] = res
-                        this.simpleData = res
                     } else {
                         this.$Message.error('API ERROR!')
                     }
@@ -156,7 +172,7 @@ export default {
     watch: {
         examInfo: {
             handler() {
-                console.log('评测信息:',this.examInfo)
+                console.log('评测信息:', this.examInfo)
                 if (this.examInfo.progress == 'finish') {
                     if (this.allData[this.examInfo.id]) {
                         this.simpleData = this.allData[this.examInfo.id]
@@ -206,23 +222,23 @@ export default {
             }
         },
         scoreSegment() {
-            if (this.examScore > 0 && this.stuTotalScores.length) {
+            if (this.stuTotalScores.length) {
                 let segment = []
-                let max = Math.max(...this.stuTotalScores)
                 let unit = this.examScore / 10
-                for(let i = 0; i < 10; i++){
+                console.log('unit', unit)
+                for (let i = 0; i < 10; i++) {
                     let startScore = unit * i
                     let endScore = unit * (i + 1)
-                    let s = this.stuTotalScores.filter(item=>{
+                    let s = this.stuTotalScores.filter(item => {
                         return item >= startScore && item < endScore
                     })
                     segment.push({
-                        name:`${startScore}-${endScore}`,
-                        value:s.length
+                        name: `${startScore}-${endScore}`,
+                        value: s.length
                     })
                 }
                 return segment
-            }else{
+            } else {
                 return []
             }
 

+ 1 - 0
TEAMModelOS/ClientApp/src/view/learnactivity/echarts/ScoreMatrix.vue

@@ -92,6 +92,7 @@ export default {
     watch: {
         pieData: {
             handler(n, o) {
+                console.log('新的',this.pieData)
                 this.$nextTick(() => {
                     if (!this.progressPie) {
                         this.progressPie = this.$echarts.init(document.getElementById('ev-score-matrix'))

+ 5 - 1
TEAMModelOS/Controllers/Common/ExamController.cs

@@ -73,7 +73,7 @@ namespace TEAMModelOS.Controllers
                     int count = 0;
                     for (int i = 0; i < request.targetClassIds.Count; i++)
                     {
-                        if (request.scope.Equals("private"))
+                        if (request.scope.Equals("private") || request.scope.Equals("teacher"))
                         {
                              var sresponse = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemStreamAsync(request.targetClassIds[i], new PartitionKey($"Class-{code}"));
                             if (sresponse.Status == 200)
@@ -370,6 +370,10 @@ namespace TEAMModelOS.Controllers
                     int newIndex = result.studentIds.IndexOf(studentId.ToString());
                     /*if (flagCount != standard.Count)
                     {*/
+/*                    StringBuilder builder = new StringBuilder();
+                    builder.Append(result.examId + "/");
+                    builder.Append(result.subjectId + "/");
+                    builder.Append(studentId);*/
                         string FileName = result.examId + "/" + result.subjectId + "/" + studentId;
                         string blob = FileName + "/" + "ans.json";
                         tasks.Add(_azureStorage.UploadFileByContainer(school.ToString(), ans.ToJsonString(), "exam", FileName + "/" + "ans.json", false));

+ 20 - 3
TEAMModelOS/Controllers/Core/BlobController.cs

@@ -271,6 +271,7 @@ namespace TEAMModelOS.Controllers.Core
             var size = await client.GetBlobsCatalogSize();
             await _azureRedis.GetRedisClient(8).HashSetAsync($"Blob:Record", name, size.Item1);
             foreach (var key in size.Item2.Keys) {
+                await _azureRedis.GetRedisClient(8).SortedSetRemoveAsync($"Blob:Catalog:{name}", key);
                 await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync($"Blob:Catalog:{name}", key, size.Item2[key].HasValue?size.Item2[key].Value:0);
             }
             return Ok(new { size = size.Item1, catalog = size.Item2 });
@@ -294,6 +295,19 @@ namespace TEAMModelOS.Controllers.Core
             return Ok(new {  urlsSize });
         }
 
+        /*
+         * 
+         {
+            "containerName": "hbcn",
+            "cache": true,
+            "optUrls": [
+                {
+                    "url": "video%2F37Z888piCvm9.mp4",
+                    "size": 1000
+                }
+            ]
+         }
+        */
         /// <summary>
         /// 测试单个文本内容的上传
         /// {"containerName":"hbcn","uploadSize":5000,"optUrls":[{"url":"video/37Z888piCvm9.mp4","size":0},{}]}
@@ -310,7 +324,6 @@ namespace TEAMModelOS.Controllers.Core
             var client = _azureStorage.GetBlobContainerClient(name);
             var disSize = urls.Select(x => x.size).Sum();
             RedisValue value = default;
-            long? useSize = 0;
             long blobSize = 0;
             value = _azureRedis.GetRedisClient(8).HashGet($"Blob:Record", name);
             if (value != default && !value.IsNullOrEmpty)
@@ -320,9 +333,13 @@ namespace TEAMModelOS.Controllers.Core
                 {
                 }
             }
-            useSize = useSize + disSize;
+            long? useSize = blobSize + disSize;
             await _azureRedis.GetRedisClient(8).HashSetAsync($"Blob:Record", name, useSize);
-            var messageBlob = new ServiceBusMessage(new {id=Guid.NewGuid().ToString(), progress = "update",code=name}.ToJsonString());
+             
+            foreach (var x in urls) {
+                await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync($"Blob:Catalog:{name}", System.Web.HttpUtility.UrlDecode(x.url, Encoding.UTF8).Split("/")[0], x.size);
+            }
+            var messageBlob = new ServiceBusMessage(new {id=Guid.NewGuid().ToString(), progress = "update",name=name}.ToJsonString());
             messageBlob.ApplicationProperties.Add("name", "Blob");
             await _serviceBus.GetServiceBusClient().SendMessageAsync("active-task", messageBlob);
             return Ok(new { size=useSize });

+ 0 - 1
TEAMModelOS/TEAMModelOS.csproj

@@ -51,7 +51,6 @@
   <ItemGroup>
     <Folder Include="JwtRsaFile\" />
     <Folder Include="Services\Evaluation\" />
-    <Folder Include="wwwroot\" />
   </ItemGroup>
   
   <ItemGroup>