@zykjcommon/questions 0.0.13 → 0.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/.env.production +2 -1
  2. package/.env.test +2 -1
  3. package/dist/zykjcommon-questions.common.js +14850 -2485
  4. package/dist/zykjcommon-questions.css +1 -1
  5. package/dist/zykjcommon-questions.umd.js +14851 -2494
  6. package/dist/zykjcommon-questions.umd.min.js +24 -1
  7. package/package.json +2 -2
  8. package/src/App.vue +2 -0
  9. package/src/assets/js/fun.js +23 -2
  10. package/src/assets/js/http.js +1 -1
  11. package/src/assets/scss/questions/index.scss +85 -22
  12. package/src/components/common/IframeComponent.vue +60 -76
  13. package/src/components/common/Loading.vue +9 -20
  14. package/src/components/common/TextAreaEditor.vue +72 -87
  15. package/src/components/exam/QuestionCard.vue +3 -3
  16. package/src/components/questions/QuestionReader.js +4 -4
  17. package/src/components/questions/Question_BriefAnswer.vue +146 -0
  18. package/src/components/questions/Question_FillBlank.vue +151 -0
  19. package/src/components/questions/Question_MultipleChoice.vue +179 -0
  20. package/src/components/questions/Question_Programming.vue +285 -0
  21. package/src/components/questions/Question_Reading.vue +173 -0
  22. package/src/components/questions/Question_SingleChoice.vue +7 -21
  23. package/src/components/questions/buildEntry.js +130 -5
  24. package/src/components/questions/const.js +15 -0
  25. package/src/components/questions/developmentEntry.js +130 -5
  26. package/src/components/questions/entry.js +2 -18
  27. package/src/components/questions/store.js +44 -0
  28. package/src/main.ts +17 -13
  29. package/src/views/exam/Analysis.vue +620 -7
  30. package/src/views/exam/Exam.vue +612 -11
  31. package/vue.config.js +8 -4
@@ -3,9 +3,134 @@
3
3
  */
4
4
  //给VUE2用是编译前的文件,和vue2项目一起打包构建
5
5
  import Question_SingleChoice from './Question_SingleChoice.vue'
6
- export default {
7
- install(Vue){
8
- Vue.component('Question_SingleChoice',Question_SingleChoice)
9
- },
10
- Question_SingleChoice
6
+ import Question_MultipleChoice from './Question_MultipleChoice.vue'
7
+ import Question_Reading from './Question_Reading.vue'
8
+ import Question_BriefAnswer from './Question_BriefAnswer.vue'
9
+ import Question_FillBlank from './Question_FillBlank.vue'
10
+ import Question_Programming from './Question_Programming.vue'
11
+ import {questionMapper} from "./const";
12
+ import fun from "../../assets/js/fun";
13
+ import storeOptions from './store'
14
+ export default function(store){
15
+ //动态注册store
16
+ store.registerModule('zykjcommonQuestions',storeOptions)
17
+ return {
18
+ install(Vue){
19
+ let version = fun.getVueVersion()
20
+ Vue.mixin({
21
+ methods: {
22
+ //公共解析questionItem方法
23
+ parseQuestionListItem(mode,question_list,answer_map,parentIndex = undefined){
24
+ function parseContent(arr,contentWidth){
25
+ arr.forEach((item)=>{
26
+ if(item['<>'] === 'img'){
27
+ if(item.hasOwnProperty('width')){
28
+ let width = Number(item.width)
29
+ if(width > contentWidth){
30
+ item.width = Math.floor(contentWidth)
31
+ item.height && delete item.height
32
+ }
33
+ }
34
+ }
35
+ if(item.html && item.html.length){
36
+ parseContent(item.html,contentWidth)
37
+ }
38
+ })
39
+ }
40
+ question_list.forEach((item,index)=>{
41
+ item.questionComponent = questionMapper[item.question_type]
42
+ // item.questionIndex = index + 1
43
+ if(parentIndex === undefined){
44
+ item.questionIndex = index + 1
45
+ }else{
46
+ item.questionIndex = (parentIndex + 1) + '-' + (index + 1)
47
+ item.questionIndex2 = index + 1
48
+ }
49
+ if(answer_map && answer_map.hasOwnProperty(item.question_id)){
50
+ item.answerMap = answer_map[item.question_id]
51
+ if(mode === 'analysis'){
52
+ //analysis页面特殊处理
53
+ if(item.answerMap.user_coding_file){
54
+ item.answerMap.oss_temp_url = item.answerMap.user_coding_file
55
+ }
56
+ //analysis页面特殊处理score字段为 answerMap.question_max_score
57
+ item.score = item.answerMap.question_max_score
58
+ //预览接口学生答案以user_开头,为适配考试的学生答案,做处理
59
+ let answerMapKeys = Object.keys(item.answerMap)
60
+ let reg = /^user_/ig
61
+ answerMapKeys.forEach((answerMapKeysItem)=>{
62
+ if(reg.test(answerMapKeysItem)){
63
+ let newProp = answerMapKeysItem.replace(reg,'')
64
+ item.answerMap[newProp] = item.answerMap[answerMapKeysItem]
65
+ }
66
+ })
67
+ }
68
+ }else{
69
+ item.answerMap = null
70
+ }
71
+ let question_type = item.question_type
72
+ if(question_type == 3){
73
+ //判断题手动构造选项数组
74
+ item.exam_options_data = [
75
+ {
76
+ index:1,data:{
77
+ name:'正确'
78
+ }
79
+ },
80
+ {
81
+ index:2,data:{
82
+ name:'错误'
83
+ }
84
+ }
85
+ ]
86
+ }else{
87
+ if(item.exam_options_data && item.exam_options_data.length){
88
+ item.exam_options_data.forEach((subItem,subIndex)=>{
89
+ subItem.enIndex = fun.indexToEnIndex(subIndex+1)
90
+ })
91
+ }
92
+ }
93
+ //转化content富文本
94
+ try{
95
+
96
+ let contentArr = JSON.parse(item.content)
97
+ let contentWidth = jQuery('.question-list').width() - 30
98
+ //图片宽度超出框架的时候把宽度设置成框架大小
99
+ parseContent(contentArr,contentWidth)
100
+ item.htmlContent = $.json2html({}, contentArr);
101
+ }catch(e){
102
+ item.htmlContent = item.content
103
+ }
104
+ //转化analysis富文本
105
+ try{
106
+ if(item.analysis){
107
+ item.analysisHtmlContent = $.json2html({}, JSON.parse(item.analysis));
108
+ }else{
109
+ item.analysisHtmlContent = ''
110
+ }
111
+ }catch(e){
112
+ item.analysisHtmlContent = item.analysis
113
+ }
114
+ //如果是阅读题要递归解析
115
+ if(item.sub_questions && item.sub_questions.length){
116
+ this.parseQuestionListItem(mode,item.sub_questions,answer_map,index)
117
+ }
118
+ })
119
+ }
120
+ }
121
+ })
122
+ Vue.component('Question_SingleChoice',Question_SingleChoice)
123
+ Vue.component('Question_MultipleChoice',Question_MultipleChoice)
124
+ Vue.component('Question_Reading',Question_Reading)
125
+ Vue.component('Question_BriefAnswer',Question_BriefAnswer)
126
+ Vue.component('Question_FillBlank',Question_FillBlank)
127
+ Vue.component('Question_Programming',Question_Programming)
128
+ },
129
+ Question_SingleChoice,
130
+ Question_MultipleChoice,
131
+ Question_Reading,
132
+ Question_BriefAnswer,
133
+ Question_FillBlank,
134
+ Question_Programming
135
+ }
11
136
  }
@@ -3,24 +3,8 @@
3
3
  */
4
4
  // import ZYKJQuestionsPlugin from "../../../dist/zykjcommon-questions.umd.min"
5
5
  // import ZYKJQuestionsPluginDev from "./developmentEntry.js"
6
- function getVueVersion(){
7
- let version = ''
8
- /*if(!Vue){
9
- if(createApp){
10
- let v = createApp({})
11
- version = v.version
12
- }else{
13
- version = 'undefined'
14
- }
15
- }else{
16
- version = Vue.version || 'undefined'
17
- }*/
18
- let Vue = require('vue')
19
- Vue = Vue.default || Vue
20
- version = Vue.version || 'undefined'
21
- return version
22
- }
23
- let version = getVueVersion()
6
+ import fun from "../../assets/js/fun";
7
+ let version = fun.getVueVersion()
24
8
  let exportObj = null
25
9
  if(version!='undefined'){
26
10
  version = parseInt(version)
@@ -0,0 +1,44 @@
1
+ let api = {
2
+ editorUrl: '/open/editor-url'
3
+ }
4
+ import {postWeb,getWeb} from "../../assets/js/http.js";
5
+ /**
6
+ * user模块
7
+ */
8
+
9
+
10
+ const state = {
11
+ pythonCodeWebPath:'',
12
+ scratchCodeWebPath:'',
13
+ cplusCodeWebPath:''
14
+ }
15
+
16
+ export default {
17
+ namespaced: true,
18
+ state,
19
+ getters: {},
20
+ mutations: {
21
+ setCodeWebPath(state, payload) {
22
+ state.pythonCodeWebPath = payload.pythonCodeWebPath
23
+ state.scratchCodeWebPath = payload.scratchCodeWebPath
24
+ state.cplusCodeWebPath = payload.cplusCodeWebPath
25
+ }
26
+ },
27
+ actions: {
28
+ getEditorUrlActions({commit,dispatch}){
29
+ return new Promise((resolve, reject) => {
30
+ getWeb(`${api.editorUrl}`).then((res) => {
31
+ let {error_code, data} = res;
32
+ if (!error_code){
33
+ let {pythonCodeWebPath,scratchCodeWebPath,cplusCodeWebPath} = data
34
+ commit('setCodeWebPath',{pythonCodeWebPath,scratchCodeWebPath,cplusCodeWebPath})
35
+ }
36
+ resolve(res)
37
+ }, (err) => {
38
+ reject(err)
39
+ })
40
+ })
41
+ }
42
+ }
43
+ }
44
+
package/src/main.ts CHANGED
@@ -41,18 +41,6 @@ import '@src/assets/js/arms'
41
41
  let vueInstance = createApp(App)
42
42
  // console.log(vueInstance,77);
43
43
 
44
- // import ZYKJQuestionsPlugin from "@src/components/questions/entry.js"
45
- // console.log(ZYKJQuestionsPlugin,799);
46
- // vueInstance.use(ZYKJQuestionsPlugin as any)
47
- // import '../dist/zykjcommon-questions.css';
48
-
49
- import ZYKJQuestionsPlugin from "@zykjcommon/questions"
50
- vueInstance.use(ZYKJQuestionsPlugin as any)
51
- import '@zykjcommon/questions/dist/zykjcommon-questions.css';
52
-
53
- // console.log(ZYKJQuestionsPlugin,111);
54
-
55
-
56
44
  vueInstance.component('remote-js', {
57
45
  render() {
58
46
  let self = this;
@@ -115,7 +103,7 @@ vueInstance.component('remote-css', {
115
103
  }
116
104
  }
117
105
  })
118
- vueInstance.component('Loading',Loading)
106
+ // vueInstance.component('Loading',Loading)
119
107
  vueInstance.component('ContentDialog',ContentDialog)
120
108
  //全局注册题型组件
121
109
  // Object.keys(QuestionReader).forEach((key)=>{
@@ -181,5 +169,21 @@ vueInstance.directive('returnTop',{
181
169
  })
182
170
 
183
171
  vueInstance.use(validationPlugin)
172
+
173
+
174
+
175
+ import ZYKJQuestionsPlugin from "@src/components/questions/entry.js"
176
+ vueInstance.use((ZYKJQuestionsPlugin as any)(store))
177
+ import '../dist/zykjcommon-questions.css';
178
+
179
+ // import ZYKJQuestionsPlugin from "@zykjcommon/questions"
180
+ // import ZYKJQuestionsPlugin from "@src/components/questions/developmentEntry.js"
181
+ // vueInstance.use((ZYKJQuestionsPlugin as any)(store))
182
+ // import '@zykjcommon/questions/dist/zykjcommon-questions.css';
183
+ // import '@src/assets/scss/questions/index.scss';
184
+
185
+ // console.log(ZYKJQuestionsPlugin,111);
186
+
187
+
184
188
  vueInstance.use(store).use(router(store)).mount('#app')
185
189
  window.vm.$store = store