Kaynağa Gözat

对接批注API,调整批量删除

liqk 4 yıl önce
ebeveyn
işleme
43e10bc102

+ 23 - 1
TEAMModelOS/ClientApp/src/api/learnActivity.js

@@ -258,9 +258,31 @@ export default {
     },
 
     /*
-     * 结束评测
+     * 手动结束评测
      */
     FinishEva: function (data) {
         return post('/common/exam/finish', data)
+    },
+
+    /*
+     * 模拟学生作答数据
+     */
+    mockAnswer: function (data) {
+        return post('/analysis/answer', data)
+    },
+
+    /*
+     * 模拟教师评分数据
+     */
+    mockScoring: function (data) {
+        return post('/analysis/scoring', data)
+    },
+
+    /*
+     *修改学生答案 (批注)
+     */
+    upsertAnswer: function (data) {
+        return post('/teacher/comment/upsert-answer', data)
     }
+
 }

+ 1 - 1
TEAMModelOS/ClientApp/src/view/learnactivity/MgtPrivEva.less

@@ -257,4 +257,4 @@
     padding: 2px 4px;
     color: white;
     border-radius: 2px;
-}
+}

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

@@ -120,6 +120,7 @@ export default {
         }
     },
     methods: {
+        
         handleEnd(index) {
             this.$Modal.confirm({
                 title: '结束评测',

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

@@ -222,4 +222,10 @@
     padding: 2px 4px;
     color: white;
     border-radius: 2px;
+}
+.mock-stu-answer{
+    margin-right: 20px;
+}
+.mock-tea-scoring{
+    margin-right: 40px;
 }

+ 22 - 0
TEAMModelOS/ClientApp/src/view/learnactivity/MgtSchoolEva.vue

@@ -60,6 +60,14 @@
                 <div class="evaluation-detail-bar">
                     <span :class="curBarIndex == 0 ? 'evalustion-bar-item line-bottom-active line-bottom':'evalustion-bar-item line-bottom'" @click="selectBar(0)">评测数据</span>
                     <span :class="curBarIndex == 1 ? 'evalustion-bar-item line-bottom-active line-bottom':'evalustion-bar-item line-bottom'" @click="selectBar(1)">评测试卷</span>
+                    <div style="float:right;">
+                        <Tooltip content="此功能仅用于展示情景快速模拟学生作答数据,且学生作答为随机生成,仅供参考!!!" :max-width="240">
+                            <Button type="success" size="small" class="mock-stu-answer" @click="mockAnswer">一键作答</Button>
+                        </Tooltip>
+                        <Tooltip content="此功能仅用于展示情景快速模拟教师评分数据,且分数为随机生成,仅供参考!!!" :max-width="240">
+                            <Button type="warning" size="small" class="mock-tea-scoring" @click="mockScoring">一键评分</Button>
+                        </Tooltip>
+                    </div>
                 </div>
                 <!--试卷信息-->
                 <div :class="curBarIndex == 1 ? 'animated fadeIn evaluation-base-info':'evaluation-base-info animated fadeOutRight'" v-show="curBarIndex == 1">
@@ -136,6 +144,20 @@ export default {
         }
     },
     methods: {
+        // 模拟教师评分数据
+        mockScoring() {
+            this.$api.learnActivity.mockScoring({
+                id: this.evaListShow[this.curEvaIndex].id,
+                code: this.evaListShow[this.curEvaIndex].code.replace('Exam-', '')
+            })
+        },
+        // 模拟学生作答数据
+        mockAnswer() {
+            this.$api.learnActivity.mockAnswer({
+                id: this.evaListShow[this.curEvaIndex].id,
+                code: this.evaListShow[this.curEvaIndex].code.replace('Exam-', '')
+            })
+        },
         handleEnd(index) {
             this.$Modal.confirm({
                 title: '结束评测',

+ 15 - 4
TEAMModelOS/ClientApp/src/view/learnactivity/PaperScore.vue

@@ -371,19 +371,30 @@ export default {
             answerIframe.onload = () => { }
         },
         saveMark(data) {
-            console.log(data)
             let img = document.createElement('img')
-            console.log(img)
             img.src = data.base64
-            // img.style.width = '100%'
             console.log('img', img)
             console.log('htmlstr', img.outerHTML)
             this.$set(this.studentAnswer.answers, this.curAnIndex, [img.outerHTML])
             this.curAnIndex = -1
             this.markStatus = false
-            this.$Message.warning('暂未对接保存批注API')
             let answerIframe = document.getElementById('answerIframe')
             answerIframe.onload = () => { }
+            this.$api.learnActivity.upsertAnswer({
+                "id": this.examId,
+                "answer": this.studentAnswer.answers,
+                "studentId": this.studentAnswer.id,
+                "subjectId": this.subjectId,
+                "classId": this.studentAnswer.classId,
+                "code": this.paperInfo.code,
+            }).then(
+                res => {
+                    this.$$Message.success('批注成功!')
+                },
+                err => {
+                    this.$$Message.error('批注成功!')
+                }
+            )
         },
         // 批注学生作答数据
         markStuAnswer(index) {

+ 4 - 1
TEAMModelOS/ClientApp/src/view/teachcontent/index.vue

@@ -532,7 +532,7 @@ export default {
             }
 
             let names = this.selections.map((item) => { return item.name })
-            let blobs = this.selections.map((item) => { return item.blob.substring(1) })
+
             this.$Modal.confirm({
                 title: this.$t('teachContent.props1'),
                 content: "<p class='dialog-p'>" + names.join(', ') + '</p>',
@@ -567,6 +567,9 @@ export default {
                             })
                         })
                     } else {
+                        let blobs = this.selections.map((item) => {
+                            return item.url.substring(0, item.url.lastIndexOf('?'))
+                        })
                         this.$api.uploadFile.deleteBlobs({
                             cntr: this.routerScope == 'school' ? this.$store.state.userInfo.schoolCode : this.$store.state.userInfo.TEAMModelId,
                             urls: blobs

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

@@ -35,7 +35,7 @@ namespace TEAMModelOS.Controllers
         private readonly AzureServiceBusFactory _serviceBus;
         private readonly DingDing _dingDing;
         private readonly Option _option;
-        public readonly AzureStorageFactory _azureStorage;
+        private readonly AzureStorageFactory _azureStorage;
 
         public ExamController(AzureCosmosFactory azureCosmos, AzureServiceBusFactory serviceBus, SnowflakeId snowflakeId, DingDing dingDing, IOptionsSnapshot<Option> option, AzureStorageFactory azureStorage)
         {

+ 68 - 2
TEAMModelOS/Controllers/Teacher/CommentController.cs

@@ -13,6 +13,8 @@ using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Helper.Common.CollectionHelper;
 using TEAMModelOS.SDK.Helper.Common.StringHelper;
+using TEAMModelOS.Models;
+using Microsoft.Extensions.Options;
 
 namespace TEAMModelOS.Controllers
 {
@@ -24,9 +26,15 @@ namespace TEAMModelOS.Controllers
     public class CommentController :ControllerBase
     {
         private readonly AzureCosmosFactory _azureCosmos;
-        public CommentController(AzureCosmosFactory azureCosmos)
+        private readonly DingDing _dingDing;
+        private readonly Option _option;
+        private readonly AzureStorageFactory _azureStorage;
+        public CommentController(AzureCosmosFactory azureCosmos, DingDing dingDing, IOptionsSnapshot<Option> option, AzureStorageFactory azureStorage)
         {
             _azureCosmos = azureCosmos;
+            _dingDing = dingDing;
+            _option = option?.Value;
+            _azureStorage = azureStorage;
         }
 
         /// <summary>
@@ -123,6 +131,64 @@ namespace TEAMModelOS.Controllers
             return Ok();
         }
 
-         
+        //批注
+        [ProducesDefaultResponseType]
+        //[AuthToken(Roles = "Teacher")]
+        [HttpPost("upsert-answer")]
+        public async Task<IActionResult> upsertAnswer(JsonElement request)
+        {
+
+            if (!request.TryGetProperty("id", out JsonElement id)) return BadRequest();
+            //if (!request.TryGetProperty("code", out JsonElement code)) return BadRequest();
+            if (!request.TryGetProperty("answer", out JsonElement answer)) return BadRequest();
+            if (!request.TryGetProperty("studentId", out JsonElement studentId)) return BadRequest();
+            if (!request.TryGetProperty("subjectId", out JsonElement subjectId)) return BadRequest();
+            if (!request.TryGetProperty("classId", out JsonElement classId)) return BadRequest();
+            //if (!request.TryGetProperty("multipleRule", out JsonElement multipleRule)) return BadRequest();
+            //if (!request.TryGetProperty("answers ", out JsonElement tandardAnswer)) return BadRequest();
+            //if (!request.TryGetProperty("paperId", out JsonElement paperId)) return BadRequest();
+            //根据不同评测的类型返回对应的编码
+            if (!request.TryGetProperty("code", out JsonElement school)) return BadRequest();
+            try
+            {
+                var client = _azureCosmos.GetCosmosClient();
+                List<ExamClassResult> examClassResults = new List<ExamClassResult>();
+                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(
+                    queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}' and c.info.id = '{classId}'",
+                    requestOptions: new QueryRequestOptions() { PartitionKey = new 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>());
+                        }
+                    }
+                }
+                ExamClassResult classResult = new ExamClassResult();              
+                List<List<string>> ans = answer.ToObject<List<List<string>>>();
+                List<List<string>> standard = new List<List<string>>();
+                List<double> points = new List<double>();                
+                foreach (ExamClassResult result in examClassResults)
+                {
+                    int index = result.studentIds.IndexOf(studentId.ToString());
+                    string FileName = result.examId + "/" + result.subjectId + "/" + studentId;
+                    string blob = await _azureStorage.UploadFileByContainer(school.ToString(), ans.ToJsonString(), "exam", FileName + "/" + "ans.json");
+                    result.studentAnswers[index].Add(blob);                  
+                    classResult = await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(result, result.id, new PartitionKey($"{result.code}"));
+                }
+
+                return Ok(new { classResult });
+            }
+            catch (Exception e)
+            {
+                await _dingDing.SendBotMsg($"OS,{_option.Location},teacher/comment/upsertAnswer()\n{e.Message}", GroupNames.醍摩豆服務運維群組);
+                return BadRequest();
+            }
+
+        }
+
+
     }
 }