فهرست منبع

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

OnePsycho 4 سال پیش
والد
کامیت
aea06b99cc

+ 2 - 2
TEAMModelFunction/TriggerVote.cs

@@ -176,7 +176,7 @@ namespace TEAMModelFunction
                                 progress = "finish",
                                 owner = vote.owner
                             };
-                            await client.GetContainer("TEAMModelOS", "School").UpsertItemAsync<ActivityData>(data, new Azure.Cosmos.PartitionKey(data.code));
+                            await client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync<ActivityData>(data,data.id, new Azure.Cosmos.PartitionKey(data.code));
                         }
                         else if (vote.scope == "private")
                         {
@@ -196,7 +196,7 @@ namespace TEAMModelFunction
                                 owner = vote.owner
                                 // tmdids = vote.tmdids
                             };
-                            await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync<ActivityData>(data, new Azure.Cosmos.PartitionKey(data.code));
+                            await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<ActivityData>(data,data.id, new Azure.Cosmos.PartitionKey(data.code));
                         }
                         break;
                 }

+ 10 - 8
TEAMModelOS/ClientApp/src/common/BaseLayout.vue

@@ -214,32 +214,34 @@
                         icon: 'iconfont icon-activityS',
                         name: this.$t('system.menu.scAc'),
                         router: '',
-                        role: 'admin',
-                        permission: 'schoolAc-read|schoolAc-upd',
+                        // role: 'admin',
+                        // permission: 'schoolAc-read|schoolAc-upd',
+                        role: 'teacher|admin',
+                        permission: '',
                         child: [
                             {
                                 icon: 'iconfont icon-test',
                                 name: this.$t('system.menu.scEv'),
                                 router: '/home/schoolEvaluation',
                                 tag: '*',
-                                role: 'admin',
-                                permission: 'schoolAc-read|schoolAc-upd'
+                                role: 'teacher|admin',
+                                permission: ''
                             },
                             {
                                 icon: 'iconfont icon-vote',
                                 name: this.$t('system.menu.scVote'),
                                 router: '/home/manageVote',
                                 tag: '*',
-                                role: 'admin',
-                                permission: 'schoolAc-read|schoolAc-upd'
+                                role: 'teacher|admin',
+                                permission: ''
                             },
                             {
                                 icon: 'iconfont icon-questionnaire',
                                 name: this.$t('system.menu.scQu'),
                                 router: '/home/manageQuestionnaire',
                                 tag: '*',
-                                role: 'admin',
-                                permission: 'schoolAc-read|schoolAc-upd'
+                                role: 'teacher|admin',
+                                permission: ''
                             },
                         ]
                     },

+ 34 - 9
TEAMModelOS/ClientApp/src/store/index.js

@@ -12,7 +12,7 @@ import teachers from './module/teachers'
 import studentWeb from './module/studentWeb'
 import scboard from './module/scboard'
 import serviceDriveAuth from './module/serviceDriveAuth'
-import  { GLOBAL }  from '@/static/Global.js'
+import { GLOBAL } from '@/static/Global.js'
 import spaceAuth from './module/spaceAuth'
 import studentAclassOneAuth from './module/studentAclassOneAuth'
 
@@ -33,15 +33,40 @@ const mutations = {
     setSchoolSas(state, obj) {
         state.schoolSas = obj
     },
-    setUserInfo(state, obj) {
+    setUserInfo(state, obj) { //obj还是原来的逻辑传参,没有变化。只是这里内部逻辑添加了判断是否为班主任,班主任对应的班级id,以及授课班级id三个字段的处理逻辑
         obj.schoolCode = obj.schoolCode || GLOBAL.DEFAULT_SCHOOL_CODE
         obj.hasSchool = obj.schoolCode !== GLOBAL.DEFAULT_SCHOOL_CODE
-		state.userInfo = obj
-	},
-	setSchoolCode(state,obj){
-		state.userInfo.schoolCode = obj || GLOBAL.DEFAULT_SCHOOL_CODE
-		state.userInfo.hasSchool = obj !== GLOBAL.DEFAULT_SCHOOL_CODE
-	}
+        obj.isHeadmaster = false      //默认不是班主任
+        obj.mgtClasses = []           //班主任管理的班级id
+        obj.teachClasses = []         //授课班级id
+        let schoolStr = localStorage.getItem('school_profile')
+        if (schoolStr) {
+            schoolStr = decodeURIComponent(schoolStr, "utf-8")
+            let schoolJson = JSON.parse(schoolStr)
+            let mgtClasses = schoolJson.school_classes.filter(item=>{
+                return item.teacher.id == obj.TEAMModelId
+            })
+            if(mgtClasses.length){
+                obj.isHeadmaster = true //是班主任
+                obj.mgtClasses = mgtClasses.map(item=>{
+                    return item.id
+                })
+            }
+            if(schoolJson.school_courses){
+                schoolJson.school_courses.forEach(item => {
+                    let classIds = item.classes.map(classItem =>{
+                        return classItem.id
+                    })
+                    obj.teachClasses.push(...classIds)
+                })
+            }
+        }
+        state.userInfo = obj
+    },
+    setSchoolCode(state, obj) {
+        state.userInfo.schoolCode = obj || GLOBAL.DEFAULT_SCHOOL_CODE
+        state.userInfo.hasSchool = obj !== GLOBAL.DEFAULT_SCHOOL_CODE
+    }
 }
 
 // ACTIONS
@@ -64,7 +89,7 @@ export default new Vuex.Store({
             TEAMModelId: '',
             name: '',
             schoolCode: '',
-			hasSchool:false
+            hasSchool: false
         }
     },
     modules: {

+ 39 - 16
TEAMModelOS/ClientApp/src/view/learnactivity/MgtPrivEva.vue

@@ -5,7 +5,17 @@
             <!--评测列表-->
             <div class="evaluation-list-wrap" slot="left">
                 <div class="evaluation-list-title">
-                    <span>{{$t('learnActivity.mgtScEv.listLabel')}}</span>
+                    <span v-if="!$store.state.userInfo.isHeadmaster">{{$t('learnActivity.mgtScEv.listLabel')}}</span>
+                    <Dropdown v-else class="sort-dropdown" trigger="click" placement="bottom-start" @on-click="function(e){ curEvValue = e }" @on-visible-change="dropdownStates">
+                        <span style="cursor: pointer;">
+                            <!-- {{$t('learnActivity.mgtScEv.period')}} -->
+                            <b class="title">{{ curEvLabel }}</b>
+                            <Icon type="ios-arrow-down" style="margin-left:8px;"></Icon>
+                        </span>
+                        <DropdownMenu slot="list" v-for="(item,index) in evFilter" :value="item.value" :key="index">
+                            <DropdownItem :name="item.value">{{ item.label }}</DropdownItem>
+                        </DropdownMenu>
+                    </Dropdown>
                     <Icon type="md-add" class=" to-create-icon" @click="goToCreate" :title="$t('learnActivity.mgtScEv.create')" />
                     <Icon type="md-trash" v-show="evaListShow.length" class="to-create-icon" :title="$t('learnActivity.mgtScEv.delete')" @click="deleteEvaluation" />
                     <Icon type="md-create" v-show="evaListShow.length && evaListShow[curEvaIndex].progress == 'pending'" class="to-create-icon" @click="editEvaluation" :title="$t('learnActivity.mgtScEv.edit')" />
@@ -98,6 +108,7 @@ export default {
     inject: ['reload'],
     data() {
         return {
+            curEvValue:0,
             split1: 0.2,
             scope: '',//school 校本 private 个人
             showBack: false,
@@ -109,15 +120,34 @@ export default {
             examDetaiInfo: {},
             targetList: [],
             isLoading: false,
-            filterPeriod: undefined,
             schoolBase: {
                 period: []
             },
+            evFilter:[
+                {
+                    label:'我发布的评测',
+                    value:0
+                },
+                {
+                    label:'数学评测',
+                    value:1
+                },
+                {
+                    label:'英语评测',
+                    value:2
+                }
+            ],
             scoreLoading: false,
             answerLoading: false
         }
     },
     methods: {
+        dropdownStates(flag) {
+            if (!flag) this.filterByTag()
+        },
+        filterByTag() {
+            this.curEvaIndex = 0
+        },
         // 模拟教师评分数据
         mockScoring() {
             this.scoreLoading = true
@@ -387,10 +417,6 @@ export default {
             (res) => {
                 if (res) {
                     this.schoolBase = res.school_base
-                    // 預設搜尋給第一個
-                    if (res.school_base.period && res.school_base.period.length) {
-                        this.filterPeriod = res.school_base.period[0].id
-                    }
                 }
             }
         ).finally(() => {
@@ -410,16 +436,13 @@ export default {
         }
     },
     computed: {
-        filterPeriodName: function () {
-            let pId = this.filterPeriod
-            let name = ''
-            if (pId) {
-                let temp = this.$store.state.user.schoolProfile.school_base.period.filter(item => {
-                    return pId == item.id
-                })
-                if (temp.length > 0) name = temp[0].name
-            }
-            return name
+        curEvLabel: function () {
+            let value = this.curEvValue
+            console.log(this.curEvValue)
+            let curObj = this.evFilter.find(item=>{
+                return item.value == value
+            })
+            return curObj.label
         },
     }
 }

+ 6 - 4
TEAMModelOS/ClientApp/src/view/learnactivity/MgtSchoolEva.vue

@@ -15,9 +15,9 @@
                             <DropdownItem :name="item.id">{{ item.name }}</DropdownItem>
                         </DropdownMenu>
                     </Dropdown>
-                    <Icon type="md-add" class=" to-create-icon" @click="goToCreate" :title="$t('learnActivity.mgtScEv.create')" />
-                    <Icon type="md-trash" v-show="evaListShow.length" class="to-create-icon" :title="$t('learnActivity.mgtScEv.delete')" @click="deleteEvaluation" />
-                    <Icon type="md-create" v-show="evaListShow.length && evaListShow[curEvaIndex] && evaListShow[curEvaIndex].progress == 'pending'" class="to-create-icon" @click="editEvaluation" :title="$t('learnActivity.mgtScEv.edit')" />
+                    <Icon type="md-add" class=" to-create-icon" @click="goToCreate" :title="$t('learnActivity.mgtScEv.create')" v-if="$access.can('admin.*|schoolAc-upd')"/>
+                    <Icon type="md-trash" v-show="evaListShow.length" class="to-create-icon" :title="$t('learnActivity.mgtScEv.delete')" @click="deleteEvaluation" v-if="$access.can('admin.*|schoolAc-upd')"/>
+                    <Icon type="md-create" v-show="evaListShow.length && evaListShow[curEvaIndex] && evaListShow[curEvaIndex].progress == 'pending'" class="to-create-icon" @click="editEvaluation" :title="$t('learnActivity.mgtScEv.edit')" v-if="$access.can('admin.*|schoolAc-upd')"/>
                 </div>
                 <div class="evaluation-list-main">
                     <vuescroll>
@@ -330,8 +330,10 @@ export default {
 
         //查询评测列表
         findEvaluation() {
+            console.log('123456',this.$access.hasRole('admin'))
             let requestData = {
-                code: this.scope == 'school' ? this.$store.state.userInfo.schoolCode : this.$store.state.userInfo.TEAMModelId
+                code: this.scope == 'school' ? this.$store.state.userInfo.schoolCode : this.$store.state.userInfo.TEAMModelId,
+                classIds:this.$access.hasRole('admin') ? undefined : this.$store.state.userInfo.teachClasses
             }
             this.$api.learnActivity.FindExamInfo(requestData).then(
                 res => {

+ 2 - 0
TEAMModelOS/ClientApp/src/view/login/Index.vue

@@ -409,6 +409,7 @@ export default {
               }).catch(err=>{
                 isFail = true
               })
+              console.log('res***',result)
               if(isFail){
                 this.loginErrText = this.$t('login.apiError.text1')
                 this.loading = false
@@ -538,6 +539,7 @@ export default {
       await this.$api.login.loginIES(item, schoolCode).then( res => {
         result = res
       })
+      console.log('////',result)
 
       //設定權限並登入
       let identity = localStorage.getItem('identity')

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

@@ -216,17 +216,27 @@ namespace TEAMModelOS.Controllers
         {
             try
             {
-                //ResponseBuilder builder = ResponseBuilder.custom();
-                //if (!requert.TryGetProperty("id_token", out JsonElement id_token)) return BadRequest();
                 if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
-                //if (!requert.TryGetProperty("school", out JsonElement school_code)) return BadRequest();
-                //if (!requert.TryGetProperty("scope", out JsonElement scope)) return BadRequest();
-                //var jwt = new JwtSecurityToken(id_token.GetString());
-                //if (!jwt.Payload.Iss.Equals("account.teammodel", StringComparison.Ordinal)) return BadRequest();
-                //var id = jwt.Payload.Sub;
-                var client = _azureCosmos.GetCosmosClient();
-                List<ExamInfo> examInfo = new List<ExamInfo>();
                 var query = $"select c.id,c.name,c.code,c.period,c.startTime,c.endTime,c.stuCount,c.type,c.progress,c.examType,c.createTime, c.subjects, c.grades, c.scope from c ";
+                if (requert.TryGetProperty("classIds", out JsonElement classIds)) {
+                    List<string> ids = classIds.ToObject<List<string>>();
+                    HashSet<string> strs = new HashSet<string>();
+                    if (ids.Count > 1)
+                    {
+                        foreach (string id in ids) {
+                            strs.Add($"array_contains(c.targetClassIds,'{id}')");
+                        }                           
+                    }
+                    else
+                    {
+                        string ssr = ids.Count > 0 ? ids[0] : "";
+                        strs.Add($"array_contains(c.targetClassIds,'{ssr}')");
+                    }
+                    string ss = string.Join(" or ", strs);
+                    query = $"select c.id,c.name,c.code,c.period,c.startTime,c.endTime,c.stuCount,c.type,c.progress,c.examType,c.createTime, c.subjects, c.grades, c.scope from c where ({ss})";
+                };
+                var client = _azureCosmos.GetCosmosClient();
+                List<ExamInfo> examInfo = new List<ExamInfo>();                
                 await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Exam-{code}") }))
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);

+ 73 - 1
TEAMModelOS/Controllers/Knowledge/KnowledgesController.cs

@@ -30,12 +30,14 @@ namespace TEAMModelOS.Controllers
         private readonly AzureCosmosFactory _azureCosmos;
         private readonly DingDing _dingDing;
         private readonly Option _option;
-        public KnowledgesController(AzureCosmosFactory azureCosmos, SnowflakeId snowflakeId, DingDing dingDing, IOptionsSnapshot<Option> option)
+        private readonly AzureRedisFactory _azureRedis;
+        public KnowledgesController(AzureCosmosFactory azureCosmos, SnowflakeId snowflakeId, DingDing dingDing, IOptionsSnapshot<Option> option, AzureRedisFactory azureRedis)
         {
             _azureCosmos = azureCosmos;
             _snowflakeId = snowflakeId;
             _dingDing = dingDing;
             _option = option?.Value;
+            _azureRedis = azureRedis;
         }
         /**
          * 
@@ -94,8 +96,78 @@ namespace TEAMModelOS.Controllers
                 knowledge.id = Guid.NewGuid().ToString();
                 knowledge = await client.GetContainer("TEAMModelOS", "School").CreateItemAsync(knowledge, new PartitionKey($"{knowledge.code}"));
             }
+            var count= new { pcount = knowledge.points!=null ? knowledge.points.Count:0,bcount= knowledge.blocks!=null? knowledge.blocks.Count:0 };
+            //处理知识点,知识块计数问题
+            await _azureRedis.GetRedisClient(8).HashSetAsync($"Knowledge:Count:{knowledge.owner}-{knowledge.subjectId}", knowledge.periodId, count.ToJsonString());
             return Ok(knowledge);
         }
+        /// <summary>
+        /**
+        
+        {
+            !"hbcn-ac73f07d-2cc8-4174-85ae-b39cc5b6beef":"ca484aa8-e7b5-4a7c-8ef3-bd9e7b7d4fp2",
+        }
+       
+        单个Item查询一个学校某个科目知识点,知识块数量,如果需要确定某一个学段,则需要加学段。
+         **/
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
+        [ProducesDefaultResponseType]
+        [HttpPost("find-count")]
+        public async Task<IActionResult> FindCount(Dictionary<string,string> request) 
+        {
+            List<dynamic> datas = new List<dynamic>();
+            foreach (var kp in request) {
+                var countPoint = 0;
+                var countBlock = 0;
+                if (!string.IsNullOrWhiteSpace(kp.Value))
+                {
+                    var value = _azureRedis.GetRedisClient(8).HashGet($"Knowledge:Count:{kp.Key}", kp.Value);
+                    if (value != default && !value.IsNullOrEmpty)
+                    {
+                        
+                        JsonElement record = value.ToString().ToObject<JsonElement>();
+                        if (record.TryGetProperty("pcount", out JsonElement pcout))
+                        {
+                            int.TryParse($"{pcout}", out countPoint);
+                        }
+                        if (record.TryGetProperty("bcount", out JsonElement bcout))
+                        {
+                            int.TryParse($"{bcout}", out countBlock);
+                        }
+                    }
+                }
+                else {
+                    var values = _azureRedis.GetRedisClient(8).HashGetAll($"Knowledge:Count:{kp.Key}");
+                    if (values != null) {
+                        foreach (var value in values) 
+                        {
+                            JsonElement record = value.ToString().ToObject<JsonElement>();
+                            if (record.TryGetProperty("pcount", out JsonElement pcout))
+                            {
+                                if (int.TryParse($"{pcout}", out int countP)) 
+                                {
+                                    countPoint = countPoint + countP;
+                                }
+                            }
+                            if (record.TryGetProperty("bcount", out JsonElement bcout))
+                            {
+                                if(int.TryParse($"{bcout}", out int countB)) 
+                                {
+                                    countBlock = countBlock + countB;
+                                }
+                            }
+                        }
+                    }
+                }
+                datas.Add( new { key = kp.Key, countPoint, countBlock });
+            }
+            return Ok(new { datas });
+        }
+
+
+          
         /**
          * {
             ?"periodId": "ca484aa8-e7b5-4a7c-8ef3-bd9e7b7d4fp2",