소스 검색

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

OnePsycho 4 년 전
부모
커밋
fb61041357

+ 41 - 16
TEAMModelOS.SDK/Models/Cosmos/Common/Vote.cs

@@ -12,60 +12,85 @@ namespace TEAMModelOS.SDK.Models
     /// 投票
     /// </summary>    
     public class Vote : CosmosEntity
-    {   
+    {
         public Vote()
         {
             pk = "Vote";
             options = new List<OptionsVote>();
 
         }
-        
+
         /// <summary>
         /// 投票名称
         /// </summary>
         public string name { get; set; }
+        public string school { get; set; }
         public string creatorId { get; set; }
+        public int year { get; set; }
         public string progress { get; set; }
         public List<OptionsVote> options { get; set; }
         public bool secret { get; set; }
+        public int selectMax { get; set; }
+        public int stuCount { get; set; }
+        public string scope { get; set; }
+        public List<string> targetClassIds { get; set; }
         /// <summary>
-        /// 投票周期/once一次,day天,week周,month月,年year等
+        /// 发布模式 0 立即发布 1 定时
         /// </summary>
-        public string times { get; set; }
-        //周期内可投票数
-        public int voteNum { get; set; }
-        public string scope { get; set; }
-        public TeacherRange teacher { get; set; }
-        public TeacherRange student { get; set; }
+        public string publishModel { get; set; }
+
         /// <summary>
         /// 开始时间
         /// </summary>
         public long startTime { get; set; }
         public long createTime { get; set; }
+
         /// <summary>
         /// 结束时间
         /// </summary>
         public long endTime { get; set; }
 
+
         /// <summary>
         /// 投票描述
         /// </summary>
         public string description { get; set; }
+
+
+        /*        /// <summary>
+                /// 投票附件
+                /// </summary>
+                [ProtoMember(9)]
+                public List<ProcessRes> resource { get; set; }
+        */
+
         /// <summary>
-        /// (100:待发布 200:已发布 300:已结束)
+        /// 状态 (100:待发布 200:已发布 300:已结束)
         /// </summary>
         public int status { get; set; }
 
 
+        /*        /// <summary>
+                /// 模式
+                /// </summary>
+                [ProtoMember(11)]
+                public List<string> other { get; set; }*/
+
+        /*
+                public string url { get; set; }
+
+                /// <summary>
+                /// 选项
+                /// </summary>
+                [ProtoMember(12)]
+                public List<Option> option { get; set; }*/
+
+        //public long sequenceNumber { get; set; }
     }
-    public class OptionsVote { 
+    public class OptionsVote
+    {
         public string code { get; set; }
         public string value { get; set; }
         public string desc { get; set; }
     }
-    public class TeacherRange
-    {
-        public bool all { get; set; }
-        public string target { get; set; }
-    }
 }

+ 290 - 290
TEAMModelOS/ClientApp/src/components/student-web/EventView/EventContentTypeTemplate/LessonTestReport.vue

@@ -41,7 +41,7 @@
                                 </div>
                             </Card>
                         </i-col>
-                        <i-col :xs="24" :sm="24" :md="24" :lg="24">
+                        <i-col :xs="24" :sm="24" :md="24" :lg="24" style="display:none">
                             <Card class="comment-card">
                                 <p class="card-title">{{$t('studentWeb.exam.smartComment')}}</p>
                                 <div class="card-comment">
@@ -123,8 +123,6 @@
                 }
             },
             testJudge() {
-                console.log(this.examInfo)
-                console.log(this.paperInfo)
                 if (this.examInfo.subject !== undefined) {
                     this.testState = 0
                     let k = 0
@@ -291,301 +289,303 @@
 </script>
 
 <style scoped>
-        .lesson-test-report {
-            min-height: 600px;
-        }
-
-        .scoreboard {
-            width: 100%;
-            /*height: 638px;*/
-            background: rgb(240, 240, 240);
-            /*border: 1px solid rgba(0, 0, 0, 0.1);*/
-            border-radius: 8px;
-            padding: 44px 50px;
-        }
-
-            .scoreboard .ivu-card {
-                margin-bottom: 20px;
-            }
-
-        .card-title {
-            font-size: 16px;
-            color: rgb(109, 114, 120);
-        }
-
-        .myscore {
-            font-size: 60px;
-            font-weight: 700;
-            /*font-family: Arial, Helvetica, sans-serif;*/
-            color: rgb(72, 72, 72);
-        }
-
-        .card-content {
-            text-align: center;
-        }
-
-        .score-card {
-            height: 140px;
-        }
-
-        .comment-card {
-            padding-bottom: 20px;
-        }
-        /*.chart-card {
-      height: 550px;
-    }*/
-        .keypoint {
-            color: #03966a;
-        }
-
+    .lesson-test-report {
+        min-height: 600px;
+    }
+
+    .scoreboard {
+        width: 100%;
+        /*height: 638px;*/
+        background: rgb(240, 240, 240);
+        /*border: 1px solid rgba(0, 0, 0, 0.1);*/
+        border-radius: 8px;
+        padding: 44px 50px;
+    }
+
+        .scoreboard .ivu-card {
+            margin-bottom: 20px;
+        }
+
+    .card-title {
+        font-size: 16px;
+        color: rgb(109, 114, 120);
+    }
+
+    .myscore {
+        font-size: 60px;
+        font-weight: 700;
+        /*font-family: Arial, Helvetica, sans-serif;*/
+        color: rgb(72, 72, 72);
+    }
+
+    .card-content {
+        text-align: center;
+    }
+
+    .score-card {
+        height: 140px;
+    }
+
+    .comment-card {
+        padding-bottom: 20px;
+    }
+
+    .chart-card {
+        z-index: 1
+    }
+
+    .keypoint {
+        color: #03966a;
+    }
+
+    .difficulty-rate {
+        text-align: center;
+        margin-top: 20px;
+        font-size: 32px;
+        /*font-family: Arial, Helvetica, sans-serif;*/
+        font-weight: 700;
+    }
+
+    .testReport-subject {
+        position: absolute;
+        right: 0px;
+        top: 85px;
+        border: solid 1px rgba(0, 0, 0, 0.2);
+        padding: 0px 20px;
+        border-radius: 4px;
+        font-size: 20px;
+    }
+
+    .subject-title {
+        color: #24b880 !important;
+    }
+
+    @media screen and (max-width: 1366px) {
         .difficulty-rate {
-            text-align: center;
-            margin-top: 20px;
-            font-size: 32px;
-            /*font-family: Arial, Helvetica, sans-serif;*/
-            font-weight: 700;
-        }
-
-        .testReport-subject {
-            position: absolute;
-            right: 0px;
-            top: 85px;
-            border: solid 1px rgba(0, 0, 0, 0.2);
-            padding: 0px 20px;
-            border-radius: 4px;
-            font-size: 20px;
-        }
-
-        .subject-title {
-            color: #24b880 !important;
-        }
-
-        @media screen and (max-width: 1366px) {
-            .difficulty-rate {
-                margin-top: 10px !important;
-                line-height: 30px;
-                font-size: 30px;
-            }
-
-            .ivu-rate {
-                white-space: nowrap;
-            }
-        }
-
-        .qcontent {
-            margin-top: 10px;
-            list-style-type: none;
-        }
-
-        .qcol {
-            border-bottom: 1px solid rgba(0, 0, 0, 0.1);
-            padding: 20px 0px;
-            padding-right: 0px;
-        }
-
-        .qtype {
-            color: #6d7278;
-            border: 2px #979797 solid;
-            border-radius: 4px;
-            padding: 2px;
-            text-align: center;
-        }
-
-        .qtypeEn {
-            padding: 2px;
-            font-size: 6px;
-        }
-
-        .qAnsCondition {
-            width: 4%;
-            padding: 2px;
-            text-align: center;
-        }
-
-        .qdesc {
-            color: rgb(72, 72, 72);
-        }
-
-        .qScore {
-            font-weight: 800;
-            color: gray;
-            text-align: right;
-        }
-
-        .qIcon {
-            width: 24px;
-            height: 24px;
-            margin-right: 20px;
-        }
-
+            margin-top: 10px !important;
+            line-height: 30px;
+            font-size: 30px;
+        }
+
+        .ivu-rate {
+            white-space: nowrap;
+        }
+    }
+
+    .qcontent {
+        margin-top: 10px;
+        list-style-type: none;
+    }
+
+    .qcol {
+        border-bottom: 1px solid rgba(0, 0, 0, 0.1);
+        padding: 20px 0px;
+        padding-right: 0px;
+    }
+
+    .qtype {
+        color: #6d7278;
+        border: 2px #979797 solid;
+        border-radius: 4px;
+        padding: 2px;
+        text-align: center;
+    }
+
+    .qtypeEn {
+        padding: 2px;
+        font-size: 6px;
+    }
+
+    .qAnsCondition {
+        width: 4%;
+        padding: 2px;
+        text-align: center;
+    }
+
+    .qdesc {
+        color: rgb(72, 72, 72);
+    }
+
+    .qScore {
+        font-weight: 800;
+        color: gray;
+        text-align: right;
+    }
+
+    .qIcon {
+        width: 24px;
+        height: 24px;
+        margin-right: 20px;
+    }
+
+    .qAnaly {
+        margin-top: 0px;
+        padding-left: 8.5%;
+    }
+
+    @media screen and (max-width: 767px) {
         .qAnaly {
-            margin-top: 0px;
-            padding-left: 8.5%;
-        }
-
-        @media screen and (max-width: 767px) {
-            .qAnaly {
-                padding-left: 4.5%;
-            }
-        }
-
-        .qAnaly .rightAns {
-            color: rgb(20, 114, 199);
-        }
-
-        .qAnserlist {
-            color: gray;
-        }
-
-        .qAnaly .rightAnalys {
-            color: gray;
-        }
-
-        .rightAnsItem {
-            color: rgb(20, 114, 199);
-        }
-
-        .wrongAnsItem {
-            color: rgb(199, 71, 20);
-        }
-
-        .TitleRec1 {
-            position: relative;
-            top: 2px;
-            width: 10px;
-            height: 16px;
-            margin-right: 5px;
-            background-color: rgb(20, 114, 199);
-            float: left;
-        }
-
-        .TitleRec2 {
-            position: relative;
-            top: 2px;
-            width: 10px;
-            height: 16px;
-            margin-right: 5px;
-            float: left;
-            background-color: gray;
-        }
-
-        .TitleRec3 {
-            position: relative;
-            top: 2px;
-            width: 10px;
-            height: 16px;
-            margin-right: 5px;
-            float: left;
-            background-color: gray;
-        }
-
-        .related-question {
-            margin-top: 1%;
-            margin-left: 1.5%;
-        }
-
-            .related-question li {
-                margin-top: 5px;
-            }
-
-        /**對問題進行篩選 */
-        .filterBtn {
-            display: inline-block;
-        }
-
-        .checkAns {
-            display: inline-block;
-            margin-left: 10px;
-        }
-
-            .checkAns input[type="checkbox"] {
-                visibility: hidden;
-                margin-left: -10px;
-            }
-
-            .checkAns:hover {
-                cursor: pointer;
-            }
-
-            .checkAns span {
-                position: relative;
-                z-index: 2;
-                padding: 10px;
-                padding-right: 12px;
-                font-weight: bolder;
-            }
-
-            .checkAns input[type="checkbox"]:checked ~ span {
-                color: #fff;
-                font-weight: bolder;
-            }
-
-            .checkAns input[type="checkbox"]:checked ~ .noAnsBtn {
-                background-color: rgb(183, 183, 183) !important;
-                border: none;
-            }
-
-            .checkAns input[type="checkbox"]:checked ~ .rightBtn {
-                background-color: rgb(20, 114, 199) !important;
-                border: none;
-            }
-
-            .checkAns input[type="checkbox"]:checked ~ .wrongBtn {
-                background-color: rgb(255, 85, 8) !important;
-                border: none;
-            }
-
-        .noAnsBtn,
-        .rightBtn,
-        .wrongBtn {
-            background-color: #fff;
-            position: relative;
-            height: 26px;
-            top: -24px;
-            margin-bottom: -20px;
-            z-index: 1;
-            border-radius: 4px;
-            border: 1px solid rgb(197, 197, 197);
-        }
-
-        .ansDetail,
-        .ansDetail:hover,
-        .closeAnsDetail:hover {
-            float: right;
-            height: 28px;
-            width: 28px;
-            margin-top: -40px;
-            margin-bottom: -40px;
-            color: #03966a;
+            padding-left: 4.5%;
+        }
+    }
+
+    .qAnaly .rightAns {
+        color: rgb(20, 114, 199);
+    }
+
+    .qAnserlist {
+        color: gray;
+    }
+
+    .qAnaly .rightAnalys {
+        color: gray;
+    }
+
+    .rightAnsItem {
+        color: rgb(20, 114, 199);
+    }
+
+    .wrongAnsItem {
+        color: rgb(199, 71, 20);
+    }
+
+    .TitleRec1 {
+        position: relative;
+        top: 2px;
+        width: 10px;
+        height: 16px;
+        margin-right: 5px;
+        background-color: rgb(20, 114, 199);
+        float: left;
+    }
+
+    .TitleRec2 {
+        position: relative;
+        top: 2px;
+        width: 10px;
+        height: 16px;
+        margin-right: 5px;
+        float: left;
+        background-color: gray;
+    }
+
+    .TitleRec3 {
+        position: relative;
+        top: 2px;
+        width: 10px;
+        height: 16px;
+        margin-right: 5px;
+        float: left;
+        background-color: gray;
+    }
+
+    .related-question {
+        margin-top: 1%;
+        margin-left: 1.5%;
+    }
+
+        .related-question li {
+            margin-top: 5px;
+        }
+
+    /**對問題進行篩選 */
+    .filterBtn {
+        display: inline-block;
+    }
+
+    .checkAns {
+        display: inline-block;
+        margin-left: 10px;
+    }
+
+        .checkAns input[type="checkbox"] {
+            visibility: hidden;
+            margin-left: -10px;
+        }
+
+        .checkAns:hover {
             cursor: pointer;
         }
 
-        .closeAnsDetail {
-            float: right;
-            height: 28px;
-            width: 28px;
-            margin-top: -40px;
-            margin-bottom: -40px;
-            color: gray;
-            cursor: pointer;
-        }
-
-        .hideqAnaly {
-            display: none;
+        .checkAns span {
+            position: relative;
+            z-index: 2;
+            padding: 10px;
+            padding-right: 12px;
+            font-weight: bolder;
         }
 
-        .aclassoneloading3 {
+        .checkAns input[type="checkbox"]:checked ~ span {
+            color: #fff;
             font-weight: bolder;
-            position: absolute;
-            text-align: center;
-            top: -70%;
-            right: -40%;
-            font-size: 20px;
-            color: rgba(0, 0, 0, 0.5)
         }
 
-        .vld-overlay {
-            outline: none;
-            border: none
-        }
+        .checkAns input[type="checkbox"]:checked ~ .noAnsBtn {
+            background-color: rgb(183, 183, 183) !important;
+            border: none;
+        }
+
+        .checkAns input[type="checkbox"]:checked ~ .rightBtn {
+            background-color: rgb(20, 114, 199) !important;
+            border: none;
+        }
+
+        .checkAns input[type="checkbox"]:checked ~ .wrongBtn {
+            background-color: rgb(255, 85, 8) !important;
+            border: none;
+        }
+
+    .noAnsBtn,
+    .rightBtn,
+    .wrongBtn {
+        background-color: #fff;
+        position: relative;
+        height: 26px;
+        top: -24px;
+        margin-bottom: -20px;
+        z-index: 1;
+        border-radius: 4px;
+        border: 1px solid rgb(197, 197, 197);
+    }
+
+    .ansDetail,
+    .ansDetail:hover,
+    .closeAnsDetail:hover {
+        float: right;
+        height: 28px;
+        width: 28px;
+        margin-top: -40px;
+        margin-bottom: -40px;
+        color: #03966a;
+        cursor: pointer;
+    }
+
+    .closeAnsDetail {
+        float: right;
+        height: 28px;
+        width: 28px;
+        margin-top: -40px;
+        margin-bottom: -40px;
+        color: gray;
+        cursor: pointer;
+    }
+
+    .hideqAnaly {
+        display: none;
+    }
+
+    .aclassoneloading3 {
+        font-weight: bolder;
+        position: absolute;
+        text-align: center;
+        top: -70%;
+        right: -40%;
+        font-size: 20px;
+        color: rgba(0, 0, 0, 0.5)
+    }
+
+    .vld-overlay {
+        outline: none;
+        border: none
+    }
 </style>

+ 7 - 3
TEAMModelOS/ClientApp/src/components/student-web/EventView/EventContentTypeTemplate/LessonTestReportCharts/KeyPointPerformChart.vue

@@ -17,11 +17,14 @@ export default {
       series: [
         {
           name: this.$t('studentWeb.exam.chart.me'),
-          data: [80, 50, 30, 40, 100]
+          //data: [80, 50, 30, 40, 100]
+          data: [0,0,0,0,0]
         },
         {
           name: this.$t('studentWeb.exam.chart.participantAverage'),
-          data: [20, 30, 40, 80, 20]
+          //data: [20, 30, 40, 80, 20]
+            data: [0, 0, 0, 0, 0]
+
         },
        
       ],
@@ -79,7 +82,8 @@ export default {
         },
         xaxis: {
           type: "category",
-          categories: localStorage.getItem('lang')=='tw'?["內積空間", "向量", "矩陣", "行列式", "線性轉換"]:["Inner product space", "vector", "matrix", "determinant", "linear transformation"],
+          //categories: localStorage.getItem('lang')=='tw'?["內積空間", "向量", "矩陣", "行列式", "線性轉換"]:["Inner product space", "vector", "matrix", "determinant", "linear transformation"],
+            categories: ["知识点1", "知识点2", "知识点3", "知识点4", "知识点5"],
           labels: {
             style: {
               colors: ["#000", "#000", "#000", "#000", "#000"],

+ 6 - 3
TEAMModelOS/ClientApp/src/components/student-web/EventView/EventContentTypeTemplate/LessonTestReportCharts/RecognizePerformChart.vue

@@ -17,11 +17,13 @@ export default {
       series2: [
         {
           name:this.$t('studentWeb.exam.chart.me'),
-          data: [80, 50, 30, 40, 100, 70]
+              //data: [80, 50, 30, 40, 100, 70]
+            data: [0,0,0,0,0,0]
         },
         {
           name: this.$t('studentWeb.exam.chart.participantAverage'),
-          data: [20, 30, 40, 80, 42, 80]
+          //data: [20, 30, 40, 80, 42, 80]
+            data:[0,0,0,0,0,0]
         }
       ],
 
@@ -78,7 +80,8 @@ export default {
         },
         xaxis: {
           type: "category",
-          categories: localStorage.getItem('lang')=='tw'?["知識", "理解", "應用", "分析", "綜合", "評鑑"]:["Knowledge", "Understanding", "Application", "Analysis", "Integration", "Evaluation"],
+          //categories: localStorage.getItem('lang')=='tw'?["知識", "理解", "應用", "分析", "綜合", "評鑑"]:["Knowledge", "Understanding", "Application", "Analysis", "Integration", "Evaluation"],
+          categories: ["知识", "理解", "应用", "分析", "综合", "评鉴"],
           labels: {
             style: {
               colors: ["#000", "#000", "#000", "#000", "#000", "#000"],

+ 16 - 0
TEAMModelOS/ClientApp/src/components/student-web/EventView/EventContentTypeTemplate/PaperTest.vue

@@ -474,4 +474,20 @@
 
 <style scoped>
     @import "~@/assets/student-web/component_styles/lesson-testpop.css";
+    .que-item /deep/ table {
+        border-top: 1px solid #ccc;
+        border-left: 1px solid #ccc;
+    }
+
+    .que-item /deep/ table td,
+    table th {
+        border-right: 1px solid #ccc;
+        padding: 3px 5px;
+    }
+
+        .que-item /deep/ table th {
+            border-bottom: 1px solid #ccc;
+            border-right: 1px solid #ccc;
+            text-align: center;
+        }
 </style>

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

@@ -115,6 +115,8 @@
                             this.paperData[i].stuAns = resData.stuAns[i]
                             this.paperData[i].stuScore = resData.stuScore[i]
                         }
+                        console.log('已有数据',this.selectData)
+                        this.opentestWithSubject(this.paperData[0])
                     })
                 }
             },
@@ -154,18 +156,15 @@
                             exam = item
                         }
                     }
-                    console.log(code)
                     if (exam.id == undefined) {
                         this.selectData = await this.$evTools.getStuPaper(code)
                         this.examData.push(this.selectData)
                     } else {
                         this.selectData = exam
                     }
-                    console.log(this.selectData)
                     this.chooseData = data
                     this.isLoad = false
                     if (this.selectData.item.length > 0) {
-                        console.log(data.stuAns[0])
                         if (data.stuAns[0] !== undefined) {
                             this.isExamDown = true
                         }
@@ -188,6 +187,7 @@
         watch: {
             $route: {
                 handler(val, oldval) {
+                    console.log('122112221212125251')
                     this.isExamDown = false
                     this.examData = []
                     this.getPaperData()

+ 0 - 29
TEAMModelOS/ClientApp/src/components/student-web/EventView/EventList.vue

@@ -251,35 +251,6 @@
 
         components: { PreviewProgressPie },
         watch: {
-            /*eventTypeCheckers: function (value) {
-              let countfit = 0;
-
-              for (let i = 0; i < this.mockdata.length; i++) {
-                if (
-                  value == "" &&
-                  this.mockdata[i].eventName.includes(this.search) == true
-                ) {
-                  countfit += 1;
-                } else if (
-                  value == "" &&
-                  this.mockdata[i].eventName.includes(this.search) == false
-                ) {
-                  countfit += 0;
-                } else if (value != "") {
-                  if (
-                    value.includes(this.mockdata[i].eventType) &&
-                    this.mockdata[i].eventName.includes(this.search)
-                  ) {
-                    countfit++;
-                  } else if (value.includes(this.mockdata[i].eventType) == false) {
-                    countfit += 0;
-                  }
-                }
-              }
-              if (countfit == 0 && this.search != "") {
-                this.isListNoItem = true;
-              } else this.isListNoItem = false;
-            },*/
             search: function (value) {
                 let countfit = 0;
                 for (let i = 0; i < this.eventList.length; i++) {

+ 0 - 2
TEAMModelOS/ClientApp/src/store/module/studentWeb.js

@@ -139,8 +139,6 @@ export default {
             state.currentQuestionNo = no;
         },
         SetPaperInfo(state, data) {
-            console.log('存入数据')
-            console.log(data)
             state.paperInfo = {}
             state.paperInfo = data
         },

+ 133 - 107
TEAMModelOS/Controllers/Common/VoteController.cs

@@ -17,8 +17,6 @@ using TEAMModelOS.SDK.DI.AzureCosmos.Inner;
 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.Learn
 {
@@ -32,19 +30,15 @@ namespace TEAMModelOS.Controllers.Learn
     [ApiController]
     public class VoteController : ControllerBase
     {
-        private readonly AzureCosmosFactory _azureCosmos;
         private readonly SnowflakeId _snowflakeId;
+        private readonly AzureCosmosFactory _azureCosmos;
         private readonly AzureServiceBusFactory _serviceBus;
-        private readonly DingDing _dingDing;
-        private readonly Option _option;
 
-        public VoteController(AzureCosmosFactory azureCosmos, AzureServiceBusFactory serviceBus, SnowflakeId snowflakeId, DingDing dingDing, IOptionsSnapshot<Option> option)
+        public VoteController(AzureCosmosFactory azureCosmos, AzureServiceBusFactory serviceBus, SnowflakeId snowflakeId)
         {
+            _snowflakeId = snowflakeId;
             _azureCosmos = azureCosmos;
             _serviceBus = serviceBus;
-            _snowflakeId = snowflakeId;
-            _dingDing = dingDing;
-            _option = option?.Value;
         }
 
 
@@ -54,123 +48,153 @@ namespace TEAMModelOS.Controllers.Learn
         /// <param name="request"></param>
         /// <returns></returns>
         [ProducesDefaultResponseType]
-        [HttpPost("save")]
-        public async Task<IActionResult> Save(Vote request)
+        [HttpPost("upsert")]
+        public async Task<IActionResult> Upsert(VoteDto request)
         {
-            try {
-                //新增Vote
-                var client = _azureCosmos.GetCosmosClient();
-                request.code = request.pk + "-" + request.code;
-                request.createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
+            /*ResponseBuilder builder = ResponseBuilder.custom();
+            //新增
+            if (string.IsNullOrEmpty(request.vote.id))
+            {
+                request.vote.id = _snowflakeId.NextId()+"";
+                request.vote.status = 100;
+                request.vote.code = typeof(Vote).Name + "-" + request.vote.code;
+            }
+            if (request.vote.publishModel.Equals("0"))
+            {
+                request.vote.startTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
+                request.vote.status = 200;
+                
+            } else if (request.vote.publishModel.Equals("1")) {
+
+                string msgId = _snowflakeId.NextId() + "";
+                long SequenceNumber = await _serviceBus.GetServiceBusClient().SendLeamMessage<Vote>(Constants.TopicName, request.vote.id, request.vote.code, request.vote.startTime, 200, msgId);
+                request.vote.sequenceNumber = SequenceNumber;
+            }*/
 
-                if (string.IsNullOrEmpty(request.id))
+
+            //新增ote
+            //string code = request.vote.code;
+            var client = _azureCosmos.GetCosmosClient();
+            Vote vote = new Vote();
+            request.vote.school = request.vote.code;
+            request.vote.code = request.vote.pk + "-" + request.vote.code;
+            request.vote.createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
+            /*if (request.vote.publishModel.Equals("0"))
+            {
+                //request.vote.startTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
+                request.vote.progress = "going";
+            }
+            else if (request.vote.publishModel.Equals("1"))
+            {
+
+                string msgId = _snowflakeId.NextId() + "";
+                long SequenceNumber = await _serviceBus.GetServiceBusClient().SendLeamMessage<Survey>(Constants.TopicName, request.vote.id, request.vote.code, request.vote.startTime, "going", msgId);
+                request.vote.sequenceNumber = SequenceNumber;
+
+            }*/
+            if (string.IsNullOrEmpty(request.vote.id))
+            {
+                request.vote.id = Guid.NewGuid().ToString();
+                //request.survey.status = 100;
+                request.vote.progress = "pending";
+                /* long SequenceNumber = await _serviceBus.GetServiceBusClient().SendLeamMessage<Vote>(Constants.TopicName, request.vote.id, request.vote.code, request.vote.startTime);
+                 request.vote.sequenceNumber = SequenceNumber;*/
+                vote = await client.GetContainer("TEAMModelOS", "Common").CreateItemAsync(request.vote, new PartitionKey($"{request.vote.code}"));
+                /*if (request.vote.scope.Equals("school"))
                 {
-                    request.id = Guid.NewGuid().ToString();
-                    request.progress = "pending";
-                    request = await client.GetContainer("TEAMModelOS", "Common").CreateItemAsync(request, new PartitionKey($"{request.code}"));
+                    vote = await client.GetContainer("TEAMModelOS", "School").CreateItemAsync(request.vote, new PartitionKey($"Vote-{code}"));
                 }
                 else
                 {
-                    Vote info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Vote>(request.id, new PartitionKey($"{request.code}"));
-                    if (info.progress.Equals("going"))
-                    {
-                        return Ok(new { v = "活动正在进行中" });
-                    }
-                    request.progress = info.progress;
-                    request = await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(request, info.id, new PartitionKey($"{info.code}"));
-                }
-                return Ok(new { request });
-            } catch (Exception e) {
-                await _dingDing.SendBotMsg($"OS,{_option.Location},common/vote/save()\n{e.Message}", GroupNames.醍摩豆服務運維群組);
-                return BadRequest(e.StackTrace);
-            }
-        }
-        /// <summary>
-        /// 查询投票活动,用于列表,编辑,查看
-        /// </summary>
-        /// <param name="request"></param>
-        /// <returns></returns>
-        [ProducesDefaultResponseType]
-        [HttpPost("find")]
-        public async Task<IActionResult> Find(JsonElement requert) {
-            try {
-                if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
-                List<object> votes = new List<object>();
-                var client = _azureCosmos.GetCosmosClient();
-                var query = $"select c.id,c.name,c.code,c.startTime,c.progress, from c ";
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Vote-{code}") }))
-                {
-                    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())
-                        {
-                            votes.Add(obj);
-                        }
-                    }
-                }
-                return Ok(votes);
-            } catch (Exception ex) {
-                await _dingDing.SendBotMsg($"OS,{_option.Location},common/vote/find()\n{ex.Message}", GroupNames.醍摩豆服務運維群組);
-                return BadRequest(ex.StackTrace);
+                    vote = await client.GetContainer("TEAMModelOS", "Teacher").CreateItemAsync(request.vote, new PartitionKey($"Vote-{code}"));
+                }*/
             }
-        }
-
-        /// 查询投票活动,用于列表,编辑,查看
-        /// </summary>
-        /// <param name="request"></param>
-        /// <returns></returns>
-        [ProducesDefaultResponseType]
-        [HttpPost("find-id")]
-        public async Task<IActionResult> FindById(JsonElement requert) {
-            try {
-                var client = _azureCosmos.GetCosmosClient();
-                if (!requert.TryGetProperty("id", out JsonElement id)) return BadRequest();
-                if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
-                Vote vote = null;
-                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<Vote>(queryText: $"select value(c) from c where c.id = '{id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
+            else
+            {
+                Vote info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Vote>(request.vote.id, new PartitionKey($"{request.vote.code}"));
+                if (info.progress.Equals("going"))
                 {
-                    vote = item;
-                    break;
+                    return Ok(new { v = "活动正在进行中" });
                 }
-                if (vote != null)
+                //request.vote.code = info.code;
+                request.vote.progress = info.progress;
+                /* await _serviceBus.GetServiceBusClient().cancelMessage(Constants.TopicName,info.sequenceNumber);
+                 long SequenceNumber = await _serviceBus.GetServiceBusClient().SendLeamMessage<Vote>(Constants.TopicName, request.vote.id, request.vote.code, request.vote.startTime);
+                 request.vote.sequenceNumber = SequenceNumber;*/
+                vote = await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(request.vote, info.id, new PartitionKey($"{info.code}"));
+                /*if (request.vote.scope.Equals("school"))
                 {
-                    return Ok(vote);
+                    vote = await client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync(request.vote, request.vote.id, new PartitionKey($"{request.vote.code}"));
                 }
                 else
                 {
-                    return BadRequest("id,code不存在!");
-                }
-            } catch (Exception ex) {
-                await _dingDing.SendBotMsg($"OS,{_option.Location},common/vote/find-id()\n{ex.Message}", GroupNames.醍摩豆服務運維群組);
-                return BadRequest(ex.StackTrace);
+                    vote = await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(request.vote, request.vote.id, new PartitionKey($"{request.vote.code}"));
+                }*/
             }
-            
-        }
-        /// <summary>
-        /// 查询投票活动,用于学生可以投票的列表
-        /// </summary>
-        /// <json>
-        /// 
-        /// </json>
-        /// <param name="request"></param>
-        /// <returns></returns>
-        [ProducesDefaultResponseType]
-        [HttpPost("find-stu")]
-        public async Task<IActionResult> FindStu(JsonElement requert) {
-            var(id,name,_,school) = HttpContext.GetAuthTokenInfo();
+            //Vote homeWork = await _azureCosmos.SaveOrUpdate<Vote>(request.vote);
+
+            //设定结束时间
+            //_timerWorkService.TimerWork<Vote>(request.vote.endTime, 300, new Dictionary<string, object> { { "id", request.vote.id } });
+            //设定结束时间
+            //await _serviceBus.GetServiceBusClient().SendLeamMessage<Vote>(Constants.TopicName, request.vote.id, request.vote.code, request.vote.endTime);
+            //清除作业
+            /*  if (!request.reset)
+              {
+                  //根据作业发布对象查找到每一个具体学生生成关联关系表 HomeWorkStudent
+
+                  List<VoteRecord> voteRecords = await _azureCosmos.FindByDict<VoteRecord>(new Dictionary<string, object> { { "id", request.vote.id } });
+
+                  if (voteRecords.IsNotEmpty())
+                  {
+                      await _azureCosmos.DeleteAll(voteRecords);
+                  }*/
+            //List<Target> targets = request.@params.vote.target;
+            //List<VoteRecord> votekStudents = new List<VoteRecord>();
+            //foreach (Target target in targets)
+            //{
+            //    //查询之前是否有 关联关系表 HomeWorkStudent 有则删除
 
-            return Ok();
+            //    List<ClassStudent> classroom = await _cosmos.FindByDict<ClassStudent>(new Dictionary<string, object> { { "id", target.classroomCode } });
+            //    if (classroom.IsNotEmpty() && classroom[0].code!=null)
+            //    {
+            //        foreach (ClassStudent student in classroom)
+            //        {
+            //            VoteRecord voteStudent = new VoteRecord();
+            //            voteStudent.id = request.@params.vote.id;
+            //            voteStudent.code = student.code;
+            //            voteStudent.classroom.code = target.classroomCode;
+            //            voteStudent.classroom.name = target.classroomName;
+            //            votekStudents.Add(voteStudent);
+            //        }
+            //    }
+            //}
+            //if (votekStudents.IsNotEmpty())
+            //{
+            //    foreach (VoteRecord voteRecord in votekStudents)
+            //    {
+            //        List<Student> student = await _cosmos.FindByDict<Student>(new Dictionary<string, object> { { "studentId", voteRecord.code } });
+            //        if (student.IsNotEmpty())
+            //        {
+            //            voteRecord.name = student[0].name;
+            //            voteRecord.code = student[0].studentId;
+            //        }
+            //    }
+            //    await _cosmos.SaveOrUpdateAll(votekStudents);
+            //}
+            /*            }*/
+            //return builder.Data(homeWork).build();
+            return Ok(new { vote });
         }
 
         /// <summary>
-        /// 查询投票活动,用于教师投票的列表
+        /// 查询投票活动
         /// </summary>
         /// <param name="request"></param>
         /// <returns></returns>
+
         [ProducesDefaultResponseType]
-        [HttpPost("find-tch")]
-        public async Task<IActionResult> FindTch(JsonElement requert)
+        [HttpPost("find")]
+        public async Task<IActionResult> Find(JsonElement requert)
         {
 
             var client = _azureCosmos.GetCosmosClient();
@@ -404,9 +428,11 @@ namespace TEAMModelOS.Controllers.Learn
         }
 
 
-        public class Options {
+        public class Options
+        {
 
-            public Options() {
+            public Options()
+            {
                 students = new List<VoteRecord>();
             }
 
@@ -419,7 +445,7 @@ namespace TEAMModelOS.Controllers.Learn
             /// 选项value
             /// </summary>
             public string optionValue { get; set; }
-            
+
             /// <summary>
             /// 选项人
             /// </summary>

+ 14 - 0
TEAMModelOS/Models/Dto/VoteDto.cs

@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using TEAMModelOS.SDK.Models;
+
+namespace TEAMModelOS.Models.Dto
+{
+    public class VoteDto
+    {
+        public Vote vote { get; set; }
+        public bool reset { get; set; }
+    }
+}