Forráskód Böngészése

Merge branch 'develop' of http://52.130.252.100:10000/TEAMMODEL/TEAMModelOS into develop

Li 2 éve
szülő
commit
d66f2a85e9

+ 3 - 3
TEAMModelOS.FunctionV4/CosmosDB/TriggerHomework.cs

@@ -196,7 +196,7 @@ namespace TEAMModelOS.FunctionV4
                     {
                         z.members.ForEach(y =>
                         {
-                            if (y.id.Equals(x) && y.type == 1)
+                            if (y.id.Equals(x.id) && y.type == 1)
                             {
                                 classIds.Add(z.id);
                             }
@@ -243,7 +243,7 @@ namespace TEAMModelOS.FunctionV4
                     {
                         z.members.ForEach(y =>
                         {
-                            if (y.id.Equals(x) && y.code.Equals(work.school) && y.type == 2)
+                            if (y.id.Equals(x.id) && y.code.Equals(work.school) && y.type == 2)
                             {
                                 classIds.Add(z.id);
                             }
@@ -301,7 +301,7 @@ namespace TEAMModelOS.FunctionV4
                     {
                         z.members.ForEach(y =>
                         {
-                            if (y.id.Equals(x) && y.type == 1)
+                            if (y.id.Equals(x.id) && y.type == 1)
                             {
                                 classIds.Add(z.id);
                             }

+ 2 - 2
TEAMModelOS.FunctionV4/CosmosDB/TriggerVote.cs

@@ -172,7 +172,7 @@ namespace TEAMModelOS.FunctionV4
                                     HashSet<string> classIds = new HashSet<string>();
                                     classLists.ForEach(z => {
                                         z.members.ForEach(y => {
-                                            if (y.id.Equals(x) && y.code.Equals(vote.school) && y.type == 2)
+                                            if (y.id.Equals(x.id) && y.code.Equals(vote.school) && y.type == 2)
                                             {
                                                 classIds.Add(z.id);
                                             }
@@ -217,7 +217,7 @@ namespace TEAMModelOS.FunctionV4
                                     HashSet<string> classIds = new HashSet<string>();
                                     classInfos.ForEach(z => {
                                         z.members.ForEach(y => {
-                                            if (y.id.Equals(x) && y.type == 1)
+                                            if (y.id.Equals(x.id) && y.type == 1)
                                             {
                                                 classIds.Add(z.id);
                                             }

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 24 - 0
TEAMModelOS.SDK/Models/Cosmos/Student/ErrorItems.cs


+ 19 - 7
TEAMModelOS.SDK/Models/Service/StudentService.cs

@@ -1396,16 +1396,16 @@ namespace TEAMModelOS.SDK
         /// </summary>
         /// <param name="schoolId"></param>
         /// <returns> [{id,name,picture,year,no,classId,classNo,className,gradeId,periodId},{id,name,picture,..}..]</returns>
-        public static async Task<List<object>> getAllStudent(AzureCosmosFactory _azureCosmos, DingDing _dingDing, Option _option, string schoolId)
+        public static async Task<List<object>> getAllStudent(AzureCosmosFactory _azureCosmos, DingDing _dingDing, Option _option, string schoolId,int inyear ,int graduate=0 )
         {
             try
             {
                 //TODO : 進階查詢選項調整、部分地方可用並行處理
                 //以學校學生角度去抓資料
-                Dictionary<string, List<(string id, string name, string picture, int year, string no, string periodId, string irs,string imei,string gender, List<StudentGuardian> guardians)>> dicClassStuds =
-                    new Dictionary<string, List<(string id, string name, string picture, int year, string no, string periodId, string irs, string imei, string gender, List<StudentGuardian> guardians)>>();
-                List<(string id, string name, string picture, int year, string no, string periodId, string irs, string imei, string gender, List<StudentGuardian> guardians)> notJoinClassStuds = 
-                    new List<(string id, string name, string picture, int year, string no, string periodId, string irs, string imei, string gender, List<StudentGuardian> guardians)>();
+                Dictionary<string, List<(string id, string name, string picture, int year, string no, string periodId, string irs,string imei,string gender,int graduate, List<StudentGuardian> guardians)>> dicClassStuds =
+                    new Dictionary<string, List<(string id, string name, string picture, int year, string no, string periodId, string irs, string imei, string gender, int graduate, List<StudentGuardian> guardians)>>();
+                List<(string id, string name, string picture, int year, string no, string periodId, string irs, string imei, string gender, int graduate, List<StudentGuardian> guardians)> notJoinClassStuds = 
+                    new List<(string id, string name, string picture, int year, string no, string periodId, string irs, string imei, string gender, int graduate, List<StudentGuardian> guardians)>();
 
 
                 List<Imei> imeis= new List<Imei>();
@@ -1414,7 +1414,15 @@ namespace TEAMModelOS.SDK
                    .GetItemQueryIterator<Imei>(queryText:imeiQueryText,requestOptions:new QueryRequestOptions { PartitionKey= new PartitionKey("Imei")})){
                     imeis.Add(item);
                 }
-                string queryText = $"SELECT  *  FROM c WHERE c.code = 'Base-{schoolId}'";
+                string queryText = "";
+                if (graduate == 0)
+                {
+                    queryText = $"SELECT  *  FROM c WHERE c.code = 'Base-{schoolId}' and (c.graduate = 0 or IS_DEFINED(c.graduate) = false )";
+                }
+                else {
+                    queryText = $"SELECT  *  FROM c WHERE c.code = 'Base-{schoolId}' and  c.graduate = 1 and c.year ={inyear} ";
+                }
+                 
 
                 //回傳用ContinuationToken
                 string continuationToken = string.Empty;
@@ -1464,6 +1472,7 @@ namespace TEAMModelOS.SDK
                                             $"{irs}",
                                             imeiObj?.id,//imei
                                             acc.TryGetProperty("gender", out JsonElement _gender) && _gender.ValueKind.Equals(JsonValueKind.String) ? _gender.GetString() : null,
+                                              acc.TryGetProperty("graduate", out JsonElement _graduate) && _graduate.ValueKind.Equals(JsonValueKind.Number) ? int.Parse($"{_graduate}"): 0,
                                             guardians
                                         )
                                     );
@@ -1482,6 +1491,7 @@ namespace TEAMModelOS.SDK
                                                 $"{irs}",
                                                 imeiObj?.id,//imei
                                                 acc.TryGetProperty("gender", out JsonElement _gender) && _gender.ValueKind.Equals(JsonValueKind.String) ? _gender.GetString() : null,
+                                                  acc.TryGetProperty("graduate", out JsonElement _graduate) && _graduate.ValueKind.Equals(JsonValueKind.Number) ? int.Parse($"{_graduate}") : 0,
                                                 guardians
                                             )
                                         );
@@ -1489,7 +1499,7 @@ namespace TEAMModelOS.SDK
                                 else
                                 {
                                     dicClassStuds.Add(classId,
-                                            new List<(string id, string name, string picture, int year, string no, string periodId, string irs,string imei,string gender, List<StudentGuardian> guardians)>()
+                                            new List<(string id, string name, string picture, int year, string no, string periodId, string irs,string imei,string gender,int graduate, List<StudentGuardian> guardians)>()
                                             {
                                                 (
                                                     acc.GetProperty("id").GetString(),
@@ -1500,6 +1510,7 @@ namespace TEAMModelOS.SDK
                                                     $"{irs}"  ,
                                                     imeiObj?.id,//imei
                                                     acc.TryGetProperty("gender", out JsonElement _gender) && _gender.ValueKind.Equals(JsonValueKind.String) ? _gender.GetString() : null,
+                                                      acc.TryGetProperty("graduate", out JsonElement _graduate) && _graduate.ValueKind.Equals(JsonValueKind.Number) ? int.Parse($"{_graduate}"): 0,
                                                     guardians
                                                 )
                                             }
@@ -1553,6 +1564,7 @@ namespace TEAMModelOS.SDK
                                          irs = o.irs,
                                          imei=o.imei,
                                          gender = o.gender,
+                                         graduate=   o.graduate,
                                          guardians =o.guardians,
                                      });
                     ret.AddRange(tmp);

+ 1 - 1
TEAMModelOS/ClientApp/public/lang/en-US.js

@@ -6019,7 +6019,7 @@ const LANG_EN_US = {
 
         // ExamList.vue
         newest: 'Newest Exams',
-        more: 'View More',
+        more: 'View Report',
 
         // index.vue
         module1: 'Score Analysis',

+ 1 - 1
TEAMModelOS/ClientApp/public/lang/zh-CN.js

@@ -6023,7 +6023,7 @@ const LANG_ZH_CN = {
 
         // ExamList.vue
         newest: '最新测验',
-        more: '查看更多',
+        more: '查看报告',
 
         // index.vue
         module1: '成绩分析',

+ 1 - 1
TEAMModelOS/ClientApp/public/lang/zh-TW.js

@@ -6024,7 +6024,7 @@ const LANG_ZH_TW = {
 
         // ExamList.vue
         newest: '最新評量',
-        more: '查看更多',
+        more: '查看報告',
 
         // index.vue
         module1: '成績分析',

+ 0 - 3
TEAMModelOS/ClientApp/src/api/schoolSetting.js

@@ -6,9 +6,6 @@ export default {
     findSchoolSystem: function (data) {
         return post('/school/init/find', data)
     },
-    findClassInfo: function (data) {
-        return post('/school/classroom/find', data)
-    },
     findSchoolBase: function(schoolCode) {
         let format = {
             "school_code": schoolCode

+ 1 - 1
TEAMModelOS/ClientApp/src/view/auth/Serial.vue

@@ -553,7 +553,7 @@ export default {
                     item.es = 2
                 }
                 //可使用
-                else if (item.expireStatus == "S" || item.expireStatus == "A") {
+                else if (item.endDate != 0 && (item.expireStatus == "S" || item.expireStatus == "A")) {
                     item.es = 3
                 }
                 //永久授權

+ 9 - 3
TEAMModelOS/ClientApp/src/view/classrecord/ClassRecord.less

@@ -180,12 +180,12 @@
 
 .interaction-record-wrap {
     width: 100%;
-    box-shadow: 5px 5px 500px #f0f0f0 inset;
+    // box-shadow: 5px 5px 500px #f0f0f0 inset;
     border-radius: 4px;
     border: 1px solid #f0f0f0;
     margin-bottom: 10px;
     position: relative;
-    background: #f9f9f9;
+    background: #fcfcfc;
     min-height: 300px;
 }
 
@@ -285,7 +285,7 @@
     font-size: 14px;
     width: 110px;
     padding: 3px 10px;
-    border-radius: 4px;
+    border-radius: 3px;
     cursor: pointer;
     height: fit-content;
     transition: background 0.3s;
@@ -469,4 +469,10 @@
 
 .custom-next {
     right: 10px;
+}
+.class-time{
+    color: #a5a5a5;
+}
+.class-time-value{
+    font-size: 13px;
 }

+ 33 - 0
TEAMModelOS/ClientApp/src/view/classrecord/ClassRecord.vue

@@ -100,6 +100,10 @@
                                         </span>
                                         <!-- 课件缩略图 -->
                                         <img class="page-mini-img" @click="openViewer(item.img)" :src="item.img" />
+                                        <p class="class-time">
+                                            <!-- <Icon size="16" type="md-time" /> -->
+                                            <span class="class-time-value">{{item.time}}</span>
+                                        </p>
                                         <!-- <Timeline style="margin-top:10px;margin-left:-5px">
                                             <TimelineItem v-for="(rtItem, rtIndex) in item.pageData" :key="rtIndex +''+index">
                                                 <Icon type="md-arrow-dropright" slot="dot" />
@@ -330,6 +334,31 @@ export default {
             this.curPage = event.pageIndex + 1
             this.$refs.videoPlayer.player.currentTime(event.Time)
         },
+        /**
+         * 处理TimeLine的异常
+         * 页面重复的IRS作答
+         */
+        fixEventData() {
+            this.pageEvents = this.pageEvents.filter((item, index) => {
+                if (item.Event == 'PopQuesLoad') {
+                    let firstIndex = this.pageEvents.findIndex(i => i.Pgid == item.Pgid && item.Event == i.Event)
+                    return firstIndex == index
+                } else {
+                    return true
+                }
+            })
+        },
+        //小于10 补0
+        fullZero(n) {
+            return n < 10 ? `0${n}` : `${n}`
+        },
+        formatTime(time) {
+            let h = Math.floor(time / (60 * 60))
+            time = time % (60 * 60)
+            let m = Math.floor(time / 60)
+            let s = Math.floor(time % 60)
+            return `${this.fullZero(h)}:${this.fullZero(m)}:${this.fullZero(s)}`
+        },
         //根据SokratesRecords.json处理page数据
         async getPageList() {
             this.pageList = []
@@ -344,6 +373,7 @@ export default {
                 this.sokratesRecords = JSON.parse(res)
                 this.pageIds = this.sokratesRecords.PgIdList || []
                 this.pageEvents = this.sokratesRecords.events || []
+                this.fixEventData()
             } catch (e) {
                 hasTimeLine = false
             }
@@ -357,6 +387,8 @@ export default {
                     let pageidEvent = resJson.find(item => item.Event == 'PgidList')
                     this.pageIds = pageidEvent && pageidEvent.PgIdList ? pageidEvent.PgIdList : []
                     this.pageEvents = resJson.filter(item => this.events.includes(item.Event))
+                    this.fixEventData()
+
                     this.sokratesRecords = {
                         events: this.pageEvents,
                         PgIdList: this.pageIds
@@ -425,6 +457,7 @@ export default {
                 page.page = index + 1
                 //当前页面对应的功能事件
                 page.pageData = this.pageEvents.filter(record => record.Pgid === item && this.fnEvents.includes(record.Event))
+                page.time = this.formatTime(page.pageData[0]?.Time)
                 page.pageData.forEach(e => {
                     e.pageIndex = index
                     e.eventName = this.hiTeachEvent[e.Event]?.text

+ 31 - 5
TEAMModelOS/ClientApp/src/view/classrecord/eventchart/Exam.vue

@@ -9,12 +9,14 @@
             <Icon type="md-podium" style="margin-right:5px" />
             {{$t('cusMgt.rcd.evt2')}}
         </div>
-        <div v-else class="exam-chart-wrap">
-            <ExamGrade :pieData="scoreSegment" style="margin-right:50px"></ExamGrade>
-            <ExamQu :quData="correctData[0] ? correctData[0].data : []" style="margin-right:50px"></ExamQu>
-            <ExamTable :examInfo="examDetaiInfo" :recordInfo="recordInfo"></ExamTable>
+        <div v-else>
+            <h3 @click="toEvDetail" class="exam-title">{{examDetaiInfo.name}}</h3>
+            <div class="exam-chart-wrap">
+                <ExamTable class="exam-chart-item" :examInfo="examDetaiInfo" :recordInfo="recordInfo"></ExamTable>
+                <ExamGrade class="exam-chart-item" :pieData="scoreSegment"></ExamGrade>
+                <ExamQu class="exam-chart-item" :quData="correctData[0] ? correctData[0].data : []"></ExamQu>
+            </div>
         </div>
-
     </div>
 </template>
 <script>
@@ -49,6 +51,15 @@ export default {
         }
     },
     methods: {
+        toEvDetail() {
+            this.$router.push({
+                path: '/home/evDetail',
+                query: {
+                    examId: this.examDetaiInfo.id,
+                    code: `Exam-${this.$store.state.userInfo.TEAMModelId}`
+                }
+            })
+        },
         //获取评测简要数据分析
         findSimpleAna() {
             this.simpleData = {}
@@ -300,6 +311,21 @@ export default {
 }
 </script>
 <style lang="less" scoped>
+.exam-title{
+    display: block;
+    // width: 600px;
+    // text-align: center;
+    margin-bottom: 10px;
+    color: #2b85e4;
+    cursor: pointer;
+    &:hover{
+        text-decoration: underline;
+    }
+}
+.exam-chart-item {
+    margin-bottom: 15px;
+    margin-right: 15px;
+}
 .exam-wrap {
     display: flex;
 }

+ 6 - 5
TEAMModelOS/ClientApp/src/view/classrecord/eventchart/ExamGrade.vue

@@ -48,15 +48,15 @@ export default {
                             formatter: '{b} : {c}' + this.$t('unit.text7')
                         },
                         grid: {
-                            left: 24,
+                            left: 34,
                             right: 20,
-                            top: 25,
-                            bottom: 20
+                            top: 35,
+                            bottom: 30
                         },
                         title: {
                             "text": `${this.isTotal ? this.$t('learnActivity.simple.total') : ''}${this.$t('learnActivity.simple.scoreMat')}`,
                             "left": "center",
-                            "top": 0,
+                            "top": 8,
                             "textStyle": {
                                 // "color": "#303030",
                                 fontSize: 12
@@ -110,7 +110,8 @@ export default {
 <style scoped lang="less">
 .ev-score-matrix {
     width: 260px;
-    height: 150px;
+    height: 155px;
+    box-shadow: 0px 2px 5px #e9e9e9;
 }
 </style>
 <style>

+ 7 - 6
TEAMModelOS/ClientApp/src/view/classrecord/eventchart/ExamQu.vue

@@ -48,15 +48,15 @@ export default {
                             formatter: '{b} : {c}' + this.$t('unit.text7')
                         },
                         grid: {
-                            left: 30,
+                            left: 35,
                             right: 20,
-                            top: 25,
-                            bottom: 50
+                            top: 35,
+                            bottom: 30
                         },
                         title: {
                             "text": this.$t('learnActivity.simple.quCorrectRate'),
                             "left": "center",
-                            "top": 0,
+                            "top": 10,
                             "textStyle": {
                                 fontSize: 12
                             }
@@ -145,7 +145,7 @@ export default {
                     this.option.xAxis.data = this.quData.map(item => item.quLabel)
                     // if (this.quData.length) this.option.yAxis.max = this.quData[0].correct + this.quData[0].wrong
                     if (this.quData.length) this.option.yAxis.max = 100 //计算比例不算人数
-                    if (this.quData.length > 8) {
+                    if (this.quData.length > 10) {
                         this.option.dataZoom = [
                             {
                                 show: true,
@@ -200,8 +200,9 @@ export default {
 </script>
 <style scoped lang="less">
 .qu-score-count {
-    width: 260px;
+    width: 575px;
     height: 180px;
+    box-shadow: 0px 2px 5px #e9e9e9;
 }
 </style>
 <style>

+ 1 - 34
TEAMModelOS/ClientApp/src/view/classrecord/eventchart/ExamTable.vue

@@ -54,38 +54,6 @@
                 {{ $t("totalAnalysis.more") }}
             </p>
         </div>
-        <Modal v-model="viewTableStatus" className="ed-name-modal" footer-hide :width="1000">
-            <div slot="header" class="modal-header">
-                详细作答数据
-            </div>
-            <div class="edit-name-content" style="padding-bottom:50px">
-                <Table ref="score-table" class="score-box" border :columns="tableColumn" :data="tableData" :no-data-text="$t('learnActivity.score.classNoStu')">
-                    <template slot-scope="{ row,index }" :slot="'qu'+qIndex" v-for="(item,qIndex) in quCount">
-                        <div :key="'qu'+qIndex" @click="getStuScore(row,qIndex)" style="cursor:pointer;">
-                            <span v-if="row.data[qIndex] == -1 && row.status == 1">- -</span>
-                            <Icon size="20" type="ios-create-outline" color="#2db7f5" v-else-if="row.data[qIndex] == -1 && row.status !== 1" />
-                            <span style="color:#2db7f5;" v-else>{{row.data[qIndex]}}</span>
-                        </div>
-                    </template>
-                    <template slot-scope="{ row }" slot="total">
-                        <span style="color:#2db7f5;">{{ row.total }}</span>
-                    </template>
-                    <template slot-scope="{ row }" slot="name">
-                        <span style="color:#2db7f5;cursor: pointer;" :title="row.id">{{ row.name}}</span>
-                    </template>
-                    <!-- 1: 未作答 2:未评分 3:已评分 4:缺考 5:补考中 -->
-                    <template slot-scope="{ row,index }" slot="status">
-                        <span class="stu-status-tag" :style="{'background':row.statusColor}">
-                            {{row.statusText}}
-                        </span>
-                    </template>
-                    <Loading slot="loading" :top="-50"></Loading>
-                </Table>
-                <div class="page-wrap">
-                    <Page show-total size="small" :current="currentPage" :total="studentScore.length" :page-size="pageSize" :page-size-opts="pageSizeOpts" @on-change="pageChange" @on-page-size-change="pageSizeChange" show-sizer />
-                </div>
-            </div>
-        </Modal>
     </div>
 </template>
 <script>
@@ -109,7 +77,6 @@ export default {
             currentPage: 1,
             pageSize: 10,
             pageSizeOpts: [5, 10, 20, 30, 40],
-            viewTableStatus: false,
             dataLoading: true,
             overviewInfo: {
                 total: 0,
@@ -158,7 +125,7 @@ export default {
                     examId: this.examInfo.id,
                     code: `Exam-${this.$store.state.userInfo.TEAMModelId}`
                 }
-            })  
+            })
         },
         getStatusInfo(answer, score, status) {
             //评测设置学生可以补考

+ 3 - 1
TEAMModelOS/ClientApp/src/view/syllabus/Syllabus.vue

@@ -2354,7 +2354,9 @@ export default {
       return this.$store.state.userInfo.name
     },
     getDefaultVolumeName() {
-      return this.hasSchool && this.isSchool ? this.subjectList[this.activeSubjectIndex].name + this.gradeList[this.addVolumeForm.grade] + this.semesterList[this.addVolumeForm.semester].name : ''
+      let isEnUs = localStorage.getItem('local') === 'en-us'
+      // 如果是英文语系状态下 自动拼接的课纲名称中间需要添加空格
+      return this.hasSchool && this.isSchool ? this.subjectList[this.activeSubjectIndex].name + (isEnUs ? ' ' : '') + this.gradeList[this.addVolumeForm.grade] + (isEnUs ? ' ' : '') + this.semesterList[this.addVolumeForm.semester].name : ''
     },
     getGradeName() {
       return index => {

+ 59 - 76
TEAMModelOS/Controllers/School/ClassController.cs

@@ -58,6 +58,9 @@ namespace TEAMModelOS.Controllers
                 classroom.code = "Class-" + classroom.school;
                 if (string.IsNullOrEmpty(classroom.id))
                 {
+                    if (classroom.graduate != 0) {
+                        return BadRequest("已毕业的班级不能被编辑");
+                    }
                     List<string> resultIds = new List<string>();
                     await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.periodId = '{classroom.periodId}' and c.no = '{classroom.no}' and c.year = '{classroom.year}' ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey(classroom.code) }))
                     {
@@ -86,6 +89,10 @@ namespace TEAMModelOS.Controllers
                     {
                         using var json = await JsonDocument.ParseAsync(response.ContentStream);
                         Class @class = json.ToObject<Class>();
+                        if (classroom.graduate != 0)
+                        {
+                            return BadRequest("已毕业的班级不能被编辑");
+                        }
                         if (!@class.no.Equals(classroom.no))
                         {
                             List<string> resultIds = new List<string>();
@@ -158,47 +165,65 @@ namespace TEAMModelOS.Controllers
             }
 
         }
-
+        /// <summary>
+        /// 已弃用
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
         [ProducesDefaultResponseType]
-        //[AuthToken(Roles = "teacher")]
         [HttpPost("find")]
-        [Authorize(Roles = "IES")]
+#if !DEBUG
+[Authorize(Roles = "IES")]
+#endif
         public async Task<IActionResult> Find(JsonElement request)
         {
-            //ResponseBuilder builder = ResponseBuilder.custom();
             if (!request.TryGetProperty("school_code", out JsonElement school_code)) return BadRequest();
             try
-            {
-                var client = _azureCosmos.GetCosmosClient();
-                List<object> classrooms = new List<object>();
-                StringBuilder sql = new StringBuilder();
-                sql.Append("select c.id,c.no,c.point,c.name,c.teacher,c.periodId,c.gradeId,c.sn,c.style,c.scope,c.type,c.code,c.openType,c.x,c.y,ARRAY_LENGTH(c.students) AS studCount from c ");
-                Dictionary<string, object> dict = new Dictionary<string, object>();
-                var emobj = request.EnumerateObject();
-                while (emobj.MoveNext())
+            {   
+                //增加毕业查询。当毕业查询字段1时,则需要传入入学年份。
+                int graduate = 0;
+                int inyear = 0;
+                //讀取該間學校所有的學生資訊
+                if (request.TryGetProperty("graduate", out JsonElement _graduate) && $"{_graduate}".Equals("1"))
                 {
-                    dict[emobj.Current.Name] = emobj.Current.Value;
+                    if (request.TryGetProperty("year", out JsonElement _year) && _year.ValueKind.Equals(JsonValueKind.Number))
+                    {
+                        if (int.TryParse($"{_year}", out inyear) && inyear > 0)
+                        {
+
+                        }
+                        else
+                        {
+                            return BadRequest("入学年份大于0");
+                        }
+                    }
+                    else
+                    {
+                        return BadRequest("请输入毕业学生的入学年份");
+                    }
                 }
-                //处理code
-                if (dict.TryGetValue("school_code", out object _))
-                {
-                    dict.Remove("school_code");
+                string sql = "";
+                if (graduate == 0) {
+                    sql = $"SELECT c.id,c.x,c.y,c.name,c.year,c.teacher,c.periodId,c.gradeId,c.room,c.sn,c.no,c.style,c.status,c.openType,c.school, c.graduate, " +
+                   $" ARRAY_LENGTH(c.students) AS studCount FROM c where c.graduate = 0 or  IS_DEFINED(c.graduate) = false";
+                }
+                else {
+                    sql = $"SELECT c.id,c.x,c.y,c.name,c.year,c.teacher,c.periodId,c.gradeId,c.room,c.sn,c.no,c.style,c.status,c.openType,c.school, c.graduate, " +
+                       $" ARRAY_LENGTH(c.students) AS studCount FROM c where c.graduate =1 and c.year ={inyear}";
                 }
-                AzureCosmosQuery cosmosDbQuery = SQLHelper.GetSQL(dict, sql);
-                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Class-{school_code}") }))
+                List<object> school_classes = new List<object>();
+                var client = _azureCosmos.GetCosmosClient();
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator
+                   (queryText:sql,
+                   requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Class-{school_code}") }))
                 {
-                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
-                    if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
+                    var jsonc = await JsonDocument.ParseAsync(item.ContentStream);
+                    foreach (var classeinfo in jsonc.RootElement.GetProperty("Documents").EnumerateArray())
                     {
-                        foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
-                        {
-                            classrooms.Add(obj.ToObject<object>());
-                        }
+                        school_classes.Add(classeinfo.ToObject<object>());
                     }
                 }
-                return Ok(new { classrooms });
-                /*List<Classroom> sc = await _azureCosmos.FindByDict<Classroom>(request);
-                return builder.Data(sc).build();*/
+                return Ok(new { school_classes });
             }
             catch (Exception ex)
             {
@@ -218,7 +243,10 @@ namespace TEAMModelOS.Controllers
            
             try
             {
-                string school_code = code.ToString();
+                Class clssz = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).ReadItemAsync<Class>($"{id}", new PartitionKey($"Class-{code}"));
+                if (clssz.graduate == 1) {
+                    return BadRequest("已毕业的班级不能被删除。");
+                }
                 var client = _azureCosmos.GetCosmosClient();
                 List<Student> students = new List<Student>();
                 await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryIterator<Student>(queryText: $"select *  from c where c.classId='{id}' ", requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Base-{code}") }))
@@ -247,60 +275,15 @@ namespace TEAMModelOS.Controllers
                 change.listid = $"{id}";
                 change.scope = "school";
                 change.originCode = $"{code}";
-                change.school = $"{school_code}";
+                change.school = $"{code}";
                 change.type = "class";
                 change.status = "delete";
                 var messageChange = new ServiceBusMessage(change.ToJsonString());
                 messageChange.ApplicationProperties.Add("name", "GroupChange");
                 var ActiveTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
                 await _serviceBus.GetServiceBusClient().SendMessageAsync(ActiveTask, messageChange);
-                //查询含有该班级的课程ID
-
-                /*
-                List<string> cids = new List<string>();
-                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(
-                    queryText: $"select distinct c.id from c join A0 in c.schedule where A0.classId = '{id}'",
-                    requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Course-{code}") }))
-                {
-                    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;
-                            cids.Add(account.GetProperty("id").GetString());
-                        }
-                    }
-                }
-                List<Task<ItemResponse<Course>>> taskCourses = new List<Task<ItemResponse<Course>>>();
-                List<Course> courses = new List<Course>();
-                if(cids.IsNotEmpty())
-                {
-                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<Course>(
-                       queryText: $"select value(c) from c where c.id in ({string.Join(",", cids.Select(o => $"'{o}'"))})",
-                       requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Course-{code}") }))
-                    {
-                        courses.Add(item);
-                    }
-                }
-               
-                foreach (Course course in courses)
-                {
-                    for (int i =0;i< course.schedule.Count;i++) {
-                        if (!string.IsNullOrEmpty(course.schedule[i].classId)) {
-                            string classId = course.schedule[i].classId;
-                            if (classId.Equals(id.GetString())) { 
-                                course.schedule.RemoveAt(i);
-                            }
-                        }
-                    }
-                    taskCourses.Add(client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync(course, course.id, new PartitionKey((course.code))));
-                }
-                await Task.WhenAll(taskCourses);
-                */
                 await Task.WhenAll(tasks);
-                Class classroom=   await client.GetContainer(Constant.TEAMModelOS, "School").DeleteItemAsync<Class>(id.ToString(), new PartitionKey($"Class-{school_code}"));
+                Class classroom=   await client.GetContainer(Constant.TEAMModelOS, "School").DeleteItemAsync<Class>(id.ToString(), new PartitionKey($"Class-{code}"));
                 return Ok(new { classroom });
             }
             catch (Exception ex)

+ 20 - 1
TEAMModelOS/Controllers/Student/StudentController.cs

@@ -170,8 +170,27 @@ namespace TEAMModelOS.Controllers
                         await CheckStudent(_serviceBus, _configuration, _azureCosmos, schoolId.GetString(), webStudents, preStudents);
                         return this.Ok(new { code = $"Base-{schoolId.GetString()}", students = retUpsert.studs, retUpsert.classDuplNos, retUpsert.errorIds });
                     case "read":
+                        //增加毕业查询。当毕业查询字段1时,则需要传入入学年份。
+                        int graduate = 0;
+                        int inyear = 0;
                         //讀取該間學校所有的學生資訊
-                        var students = await StudentService.getAllStudent(_azureCosmos, _dingDing, _option, schoolId.GetString());
+                        if (request.TryGetProperty("graduate", out JsonElement _graduate) && $"{_graduate}".Equals("1")) {
+                            if (request.TryGetProperty("year", out JsonElement _year) && _year.ValueKind.Equals(JsonValueKind.Number))
+                            {
+                                if (int.TryParse($"{_year}", out inyear) && inyear > 0)
+                                {
+
+                                }
+                                else {
+                                    return BadRequest("入学年份大于0");
+                                }
+                            }
+                            else {
+                                return BadRequest("请输入毕业学生的入学年份");
+                            }
+                        }
+                      
+                        var students = await StudentService.getAllStudent(_azureCosmos, _dingDing, _option, schoolId.GetString(), inyear, graduate);
                         return this.Ok(new { code = $"Base-{schoolId.GetString()}", students });
                     case "update":
                         //更新學生資料,批量密碼重置,基本資訊更新(姓名、教室ID、性別、學年及座號)

+ 3 - 1
TEAMModelOS/Controllers/Teacher/InitController.cs

@@ -617,8 +617,10 @@ namespace TEAMModelOS.Controllers
 
                 //取得班级
                 List<object> school_classes = new List<object>();
+
                 await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator
-                    (queryText: $"SELECT c.id,c.x,c.y,c.name,c.year,c.teacher,c.periodId,c.gradeId,c.room,c.sn,c.no,c.style,c.status,c.openType,c.school, ARRAY_LENGTH(c.students) AS studCount FROM c",
+                    (queryText: $"SELECT c.id,c.x,c.y,c.name,c.year,c.teacher,c.periodId,c.gradeId,c.room,c.sn,c.no,c.style,c.status,c.openType,c.school, c.graduate, " +
+                    $" ARRAY_LENGTH(c.students) AS studCount FROM c where c.graduate = 0 or  IS_DEFINED(c.graduate) = false",
                     requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Class-{school_code}") }))
                 {
                     var jsonc = await JsonDocument.ParseAsync(item.ContentStream);