فهرست منبع

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

liqk 4 سال پیش
والد
کامیت
6a2cfee736

+ 1 - 20
TEAMModelFunction/TriggerExam.cs

@@ -197,17 +197,8 @@ namespace TEAMModelFunction
 
 
                                         foreach (Students students in stuList.students)
                                         foreach (Students students in stuList.students)
                                                 {
                                                 {
-                                                    if (students.code.Contains(code))
-                                                    {
-                                                        if (!ids.Contains(students.id))
-                                                        {
-                                                            ids.Add(students.id);
-                                                        }
-                                                    }
-                                                    else
-                                                    {
+
                                                         ids.Add(students.id);
                                                         ids.Add(students.id);
-                                                    }
                                                 }
                                                 }
                                                 if (stuList.tmids.Count > 0)
                                                 if (stuList.tmids.Count > 0)
                                                 {
                                                 {
@@ -229,17 +220,7 @@ namespace TEAMModelFunction
                                         //处理发布对象为自选名单(校本)
                                         //处理发布对象为自选名单(校本)
                                         foreach (Students students in stuList.students)
                                         foreach (Students students in stuList.students)
                                         {
                                         {
-                                            if (students.code.Contains(code))
-                                            {
-                                                if (!ids.Contains(students.id))
-                                                {
-                                                    ids.Add(students.id);
-                                                }
-                                            }
-                                            else
-                                            {
                                                 ids.Add(students.id);
                                                 ids.Add(students.id);
-                                            }
                                         }                                      
                                         }                                      
                                     }                                    
                                     }                                    
                                 }
                                 }

+ 3 - 5
TEAMModelOS/ClientApp/src/components/student-web/EventView/EventContentTypeTemplate/PaperView.vue

@@ -105,18 +105,17 @@
                 this.chooseData = {}
                 this.chooseData = {}
                 this.isTestOver = false
                 this.isTestOver = false
                 //this.selectTab = "test"
                 //this.selectTab = "test"
-                console.log(this.selectTab)
                 if (this.$store.getters.getItemTitle.name !== undefined) {
                 if (this.$store.getters.getItemTitle.name !== undefined) {
                     let paper = this.$store.getters.getItemTitle
                     let paper = this.$store.getters.getItemTitle
                     let codes = this.$store.getters.getItemTitle.code.split('-')
                     let codes = this.$store.getters.getItemTitle.code.split('-')
                     let req = {
                     let req = {
                         id: paper.id,
                         id: paper.id,
                         studentId: this.$store.state.userInfo.sub,
                         studentId: this.$store.state.userInfo.sub,
-                        code: codes[1]
+                        code: codes[1],
+                        scode: paper.scode
                     }
                     }
                     let isTest = 0
                     let isTest = 0
                     this.$api.studentWeb.FindStudentPaper(req).then(res => {
                     this.$api.studentWeb.FindStudentPaper(req).then(res => {
-                        console.log(res)
                         this.stuData = res
                         this.stuData = res
                         let resData = res
                         let resData = res
                         for (let item of resData.papers) {
                         for (let item of resData.papers) {
@@ -172,7 +171,6 @@
                 }
                 }
             },
             },
             async getPaper(data) {
             async getPaper(data) {
-                console.log(data)
                 this.isExamDown = false
                 this.isExamDown = false
                 this.isLoad = true
                 this.isLoad = true
                 this.selectData = {}
                 this.selectData = {}
@@ -181,7 +179,7 @@
                     let key = data.code.split('-')
                     let key = data.code.split('-')
                     let code = {
                     let code = {
                         scope: data.scope,
                         scope: data.scope,
-                        code: key[(key.length - 1)],
+                        code: this.$store.getters.getItemTitle.owner,
                         blob: data.blob
                         blob: data.blob
                     }
                     }
                     let exam = {}
                     let exam = {}

+ 2 - 0
TEAMModelOS/ClientApp/src/utils/evTools.js

@@ -385,6 +385,8 @@ export default {
 	/* 获取完整的试卷数据 */
 	/* 获取完整的试卷数据 */
 	getStuPaper(paper,examScope){
 	getStuPaper(paper,examScope){
 		//console.log('evTools换取学生试卷' , paper)
 		//console.log('evTools换取学生试卷' , paper)
+		console.log(paper)
+		console.log(examScope)
 		let curScope = examScope || paper.scope
 		let curScope = examScope || paper.scope
 		return new Promise(async (r,j) => {
 		return new Promise(async (r,j) => {
 			let blobHost = JSON.parse(decodeURIComponent(localStorage.student_profile, "utf-8")).blob_uri
 			let blobHost = JSON.parse(decodeURIComponent(localStorage.student_profile, "utf-8")).blob_uri

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

@@ -835,6 +835,7 @@ namespace TEAMModelOS.Controllers
                 //if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
                 //if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
                 if (!requert.TryGetProperty("studentId", out JsonElement studentId)) return BadRequest();
                 if (!requert.TryGetProperty("studentId", out JsonElement studentId)) return BadRequest();
                 if (!requert.TryGetProperty("code", out JsonElement school)) return BadRequest();
                 if (!requert.TryGetProperty("code", out JsonElement school)) return BadRequest();
+                if(!requert.TryGetProperty("scode", out JsonElement scode)) return BadRequest();
                 var client = _azureCosmos.GetCosmosClient();
                 var client = _azureCosmos.GetCosmosClient();
                 var query = $"select c.id,c.code,A0.id paperId,A0.code paperCode,A0.name paperName,A0.multipleRule,A0.scope,A0.blob from c join A0 in c.papers where c.id ='{id}'";
                 var query = $"select c.id,c.code,A0.id paperId,A0.code paperCode,A0.name paperName,A0.multipleRule,A0.scope,A0.blob from c join A0 in c.papers where c.id ='{id}'";
                 List<object> papers = new List<object>();
                 List<object> papers = new List<object>();
@@ -873,7 +874,7 @@ namespace TEAMModelOS.Controllers
                     }
                     }
                 }
                 }
                 var queryClassId = $"select c.targetClassIds id from c where c.id ='{id}'";
                 var queryClassId = $"select c.targetClassIds id from c where c.id ='{id}'";
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: queryClassId, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Exam-{school}") }))
+                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: queryClassId, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{scode}") }))
                 {
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -895,7 +896,7 @@ namespace TEAMModelOS.Controllers
                         infoIds.Add(ids);
                         infoIds.Add(ids);
                     }
                     }
                 }
                 }
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Exam-{school}") }))
+                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{scode}") }))
                 {
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -908,7 +909,7 @@ namespace TEAMModelOS.Controllers
                 }
                 }
                 var querySubject = $"select A0.id,A0.name from c join A0 in c.subjects where c.id ='{id}'";
                 var querySubject = $"select A0.id,A0.name from c join A0 in c.subjects where c.id ='{id}'";
                 //List<object> props = new List<object>();
                 //List<object> props = new List<object>();
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: querySubject, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Exam-{school}") }))
+                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: querySubject, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{scode}") }))
                 {
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                     if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)

+ 124 - 131
TEAMModelOS/Controllers/School/ClassRoomController.cs

@@ -396,160 +396,153 @@ namespace TEAMModelOS.Controllers
                 var client = _azureCosmos.GetCosmosClient();
                 var client = _azureCosmos.GetCosmosClient();
                 List<object> stus = new List<object>();
                 List<object> stus = new List<object>();
                 List<string> stuIds = new List<string>();
                 List<string> stuIds = new List<string>();
-                
+                string info = "";
                 for (int i = 0; i < ids.GetArrayLength(); i++)
                 for (int i = 0; i < ids.GetArrayLength(); i++)
                 {
                 {
-                    List<object> scList = new List<object>();
-                    List<object> suList = new List<object>();
-                    List<(string id, string name, string pic, string code, string classId,string className, string groupId, string groupName, string no)> listStudent = new List<(string id, string name, string pic, string code, string classId, string className, string groupId, string groupName, string no)>();
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Student").GetItemQueryStreamIterator(
-                        queryText: $"select c.id,c.name,c.classId,c.code,c.groupId,c.groupName,c.no,c.picture from c where c.classId = '{ids[i].GetString()}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{schoolId}") }))
-                    {
-                        using var json = await JsonDocument.ParseAsync(item.ContentStream);
-                        if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
-                        {
-                            var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
-                            while (accounts.MoveNext())
-                            {
-                                JsonElement account = accounts.Current;
-                                stuIds.Add(account.GetProperty("id").GetString());
-                                var response = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(account.GetProperty("classId").GetString(), new PartitionKey($"Class-{schoolId}"));
-                                string className = "";
-                                if (response.Status == 200)
+                    //ids.Add(id[i].ToJsonString());
+                    info += ids[i].ToJsonString() + ",";
+                }
+                List<object> scList = new List<object>();
+                List<object> suList = new List<object>();
+                List<(string id, string name, string pic, string code, string classId ,string groupId, string groupName, string no)> listStudent = new List<(string id, string name, string pic, string code, string classId, string groupId, string groupName, string no)>();
+                //var response = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(ids[i].GetString(), new PartitionKey($"Class-{schoolId}"));
+                string className = "";
+                /*                if (response.Status == 200)
                                 {
                                 {
                                     using var document = await JsonDocument.ParseAsync(response.ContentStream);
                                     using var document = await JsonDocument.ParseAsync(response.ContentStream);
                                     Class @class = document.ToObject<Class>();
                                     Class @class = document.ToObject<Class>();
                                     className = @class.name;
                                     className = @class.name;
-                                }
-                                listStudent.Add((account.GetProperty("id").GetString(),
-                                    account.GetProperty("name").GetString(), 
-                                    account.GetProperty("picture").GetString(),
-                                    account.GetProperty("code").GetString(), 
-                                    account.GetProperty("classId").GetString(),
-                                    className,
-                                    account.GetProperty("groupId").GetString(),
-                                    account.GetProperty("groupName").GetString(), 
-                                    account.GetProperty("no").GetString()));
-                            }
-                            var scinfos = listStudent.Select(o =>
-                                        new
-                                        {
-                                            o.id,
-                                            o.name,
-                                            o.pic,
-                                            o.code,
-                                            o.classId,
-                                            o.className,
-                                            o.groupId,
-                                            o.groupName,
-                                            o.no
-                                        });
-                            scList.AddRange(scinfos);
-                            stus.Add(scList);
+                                }*/
+                List<(string id, string name)> listClassList = new List<(string id,string name)>();
+                await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(
+                                    queryText: $"select c.id,c.name from c where c.id in ({info[0..^1]})", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Class-{schoolId}") }))
+                {
+                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
+                    {
+                        var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
+                        while (accounts.MoveNext())
+                        {
+                            JsonElement account = accounts.Current;
+                            listClassList.Add((account.GetProperty("id").GetString(), account.GetProperty("name").GetString()));
+                            //stuIds.Add(account.GetProperty("id").GetString());                           
                         }
                         }
                     }
                     }
-                    List<(string id, string code, string stuId,string name)> listStuList = new List<(string id, string code, string stuId,string name)> ();
-                    if (scope.ToString().Equals("school", StringComparison.OrdinalIgnoreCase))
+                }
+                await foreach (var item in client.GetContainer("TEAMModelOS", "Student").GetItemQueryStreamIterator(
+                    queryText: $"select c.id,c.name,c.classId,c.code,c.groupId,c.groupName,c.no,c.picture from c where c.classId in ({info[0..^1]})", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{schoolId}") }))
+                {
+                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                     {
                     {
-                        List<StuList> stuLists = new List<StuList>();
-                        await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c where c.id = '{ids[i].GetString()}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList-{schoolId}") }))
+                        var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
+                        while (accounts.MoveNext())
                         {
                         {
-                            stuLists.Add(item);
+                            JsonElement account = accounts.Current;
+                            stuIds.Add(account.GetProperty("id").GetString());
+
+                            listStudent.Add((account.GetProperty("id").GetString(),
+                                account.GetProperty("name").GetString(),
+                                account.GetProperty("picture").GetString(),
+                                account.GetProperty("code").GetString(),
+                                account.GetProperty("classId").GetString(),
+                                account.GetProperty("groupId").GetString(),
+                                account.GetProperty("groupName").GetString(),
+                                account.GetProperty("no").GetString()));
                         }
                         }
-                        if (stuLists.Count > 0)
+                    }
+                }
+                var scinfos = listStudent.Select(o =>
+                                    new
+                                    {
+                                        o.id,
+                                        o.name,
+                                        o.pic,
+                                        o.code,
+                                        o.classId,
+                                        className = listClassList.FirstOrDefault(c => c.id == o.classId).name,
+                                        o.groupId,
+                                        o.groupName,
+                                        o.no
+                                    });
+                scList.AddRange(scinfos);
+                stus.Add(scList);
+                List<(string id, string code, string stuId, string name)> listStuList = new List<(string id, string code, string stuId, string name)>();
+                if (scope.ToString().Equals("school", StringComparison.OrdinalIgnoreCase))
+                {
+                    List<StuList> stuLists = new List<StuList>();
+                    await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c where c.id in ({info[0..^1]})", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList-{schoolId}") }))
+                    {
+                        stuLists.Add(item);
+                    }
+                    if (stuLists.Count > 0)
+                    {
+                        foreach (StuList stuList in stuLists)
                         {
                         {
-                            foreach (StuList stuList in stuLists)
+                            foreach (Students stu in stuList.students)
                             {
                             {
-                                foreach (Students stu in stuList.students)
-                                {
-                                    if (stu.code.Contains(schoolId.GetString()))
-                                    {
-                                        if (!stuIds.Contains(stu.id))
-                                        {
-                                            listStuList.Add((stu.id,
-                                                    stu.code,
-                                                    stuList.id,
-                                                    stuList.name));
-                                        }
-                                    }
-                                    else
-                                    {
-                                        listStuList.Add((stu.id,
-                                                    stu.code,
-                                                    stuList.id,
-                                                    stuList.name));
-                                    }
-                                }
-                                
+                                    listStuList.Add((stu.id,
+                                                stu.code,
+                                                stuList.id,
+                                                stuList.name));
                             }
                             }
-                            var infos = listStuList.Select(o =>
-                                        new
-                                        {
-                                            o.id,
-                                            o.code,
-                                            o.stuId,
-                                            o.name
-                                        });
-                            suList.AddRange(infos);
-                            stus.Add(suList);
+
                         }
                         }
+                        var infos = listStuList.Select(o =>
+                                    new
+                                    {
+                                        o.id,
+                                        o.code,
+                                        o.stuId,
+                                        o.name
+                                    });
+                        suList.AddRange(infos);
+                        stus.Add(suList);
                     }
                     }
-                    else {
-                        //处理发布对象为自选名单(个人)
-                        List<StuList> stuLists1 = new List<StuList>();
-                        await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c where c.id = '{ids[i].GetString()}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
-                        {
-                            stuLists1.Add(item);
-                        }
-                        if (stuLists1.Count > 0)
+                }
+                else
+                {
+                    //处理发布对象为自选名单(个人)
+                    List<StuList> stuLists1 = new List<StuList>();
+                    await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c where c.id in ({info[0..^1]})", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
+                    {
+                        stuLists1.Add(item);
+                    }
+                    if (stuLists1.Count > 0)
+                    {
+                        foreach (StuList stuList in stuLists1)
                         {
                         {
-                            foreach (StuList stuList in stuLists1)
+                            foreach (Students students in stuList.students)
                             {
                             {
-                                foreach (Students students in stuList.students)
+
+                                    listStuList.Add((students.id,
+                                                students.code,
+                                                stuList.id,
+                                                stuList.name));
+                            }
+                            if (stuList.tmids.Count > 0)
+                            {
+                                foreach (string tid in stuList.tmids)
                                 {
                                 {
-                                    if (students.code.Contains(schoolId.GetString()))
-                                    {
-                                        if (!stuIds.Contains(students.id))
-                                        {
-                                            listStuList.Add((students.id,
-                                                    students.code,
-                                                    stuList.id,
-                                                    stuList.name));
-                                        }
-                                    }
-                                    else
-                                    {
-                                        listStuList.Add((students.id,
-                                                    students.code,
-                                                    stuList.id,
-                                                    stuList.name));
-                                    }
+                                    listStuList.Add((tid,
+                                                default,
+                                                stuList.id,
+                                                stuList.name));
                                 }
                                 }
-                                if (stuList.tmids.Count > 0)
-                                {
-                                    foreach (string tid in stuList.tmids)
-                                    {
-                                        listStuList.Add((tid,
-                                                    default,
-                                                    stuList.id,
-                                                    stuList.name));
-                                    }
-                                }                               
                             }
                             }
-                            var infos = listStuList.Select(o =>
-                                       new
-                                       {
-                                           o.id,
-                                           o.code,
-                                           o.stuId,
-                                           o.name
-                                       });
-                            suList.AddRange(infos);
-                            stus.Add(suList);
                         }
                         }
+                        var infos = listStuList.Select(o =>
+                                   new
+                                   {
+                                       o.id,
+                                       o.code,
+                                       o.stuId,
+                                       o.name
+                                   });
+                        suList.AddRange(infos);
+                        stus.Add(suList);
                     }
                     }
-
-                }               
+                }             
                 return Ok(new { stus });
                 return Ok(new { stus });
             }
             }
             catch (Exception ex)
             catch (Exception ex)