Переглянути джерело

多媒体新增试评详情显示

ting.yin 5 роки тому
батько
коміт
a60278b347

+ 90 - 9
stmms-web/src/main/webapp/WEB-INF/views/include/trialDetail.jsp

@@ -1,6 +1,8 @@
 <%@ page contentType="text/html;charset=UTF-8"%>
 <link rel="stylesheet" type="text/css" href="${ctxStatic}/jBox/Source/jBox.css">
 <script type="text/javascript" src="${ctxStatic}/jBox/Source/jBox.min.js"></script>
+<link rel="stylesheet" type="text/css" href="${ctxStatic}/rich-text/css/rich-text.css">
+<script type="text/javascript" src="${ctxStatic}/rich-text/js/render.js"></script>
 
 <div id="trial-detail-content" class="container-fluid" style="display:none">
 <div class="row-fluid">
@@ -51,21 +53,100 @@ function initTrialDetailContent(libraryId){
 	                var history = data.historyList[i];
 	                $('#trial-history').append('<tr><td>'+history.loginName+'</td><td>'+history.name+'</td><td>'+history.score+'</td><td>'+history.time+'</td></tr>');
 	            }
-	            new ImageLoader( {
-	                server: data.imageServer
-	            }).merge(data.urls, data.pictureConfig, function(image){
-                    trialDetailModal.setContent($('#trial-detail-content'));
-                    $(image).width($('#trial-left-div').width()*0.95);
-                    $(image).appendTo('#trial-left-div');
-                }, function(error){
-	                trialDetailModal.setTitle('加载失败');
-	            });
+	            if(data.imageServer != undefined && data.pictureConfig != undefined){
+		            new ImageLoader( {
+		                server: data.imageServer
+		            }).merge(data.urls, data.pictureConfig, function(image){
+	                    trialDetailModal.setContent($('#trial-detail-content'));
+	                    $(image).width($('#trial-left-div').width()*0.95);
+	                    $(image).appendTo('#trial-left-div');
+	                }, function(error){
+		                trialDetailModal.setTitle('加载失败');
+		            });
+	            }else if(data.jsonServer != undefined && data.questionNumbers != undefined){
+	            	var url = data.jsonServer + data.urls;
+	            	var questionNumbers = data.questionNumbers.split(",");
+	            	let questionArr = {};
+	            	questionNumbers.forEach(questionNumber => {
+	            		questionArr[questionNumber] = true;
+	                });
+	            	/* $.get(url, function (result) {
+	            		 let questions = JSON.parse(result) || []; */
+	            		 var result = '[{"mainNumber": 6,"subNumber": 19,"body": {"sections": [{ "blocks":[{"type": "text","value": "我是题目我是题目我是题目"}]}]},"answer": {"sections": [{"blocks":[{"type": "image","value": "https://ecs-test-static.qmth.com.cn/oe-answer-file/3/8/20/3_8_20_15748452889591137.jpeg"}]},{"blocks":[{"type": "audio","value": "https://ecs-test-static.qmth.com.cn/oe-answer-file/3/8/19/3_8_19_15748452552644264.mp3"}]}]},"studentAnswer": {"sections": [{"blocks":[{"type": "image","value": "https://ecs-test-static.qmth.com.cn/oe-answer-file/3/8/20/3_8_20_15748452889591137.jpeg"},{"type": "image","value": "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1582709869784&di=39683b1330bd09bebd93c95fe925ca70&imgtype=0&src=http%3A%2F%2Fn.sinaimg.cn%2Fsinacn10108%2F170%2Fw600h370%2F20190222%2Fd6de-htknpmh2595255.jpg"},{"type": "text","value": "我是答案答案daan"}]}]}}]';
+	            		 let questions = JSON.parse(result);
+
+	            		 questions.forEach(question => {
+	            	            // 按题号过滤
+	            	            if (questionArr[question.mainNumber + "." + question.subNumber] === true) {
+	            	                let numberTitle = {
+	            	                    "blocks": [{
+	            	                        "type": "text",
+	            	                        "param": {"bold": true},
+	            	                        "value": "题号:" + question.mainNumber + "-" + question.subNumber
+	            	                    }]
+	            	                };
+	            	                let bodyTitle = {
+	            	                    "blocks": [{
+	            	                        "type": "text",
+	            	                        "param": {"bold": true},
+	            	                        "value": "题干:"
+	            	                    }]
+	            	                };
+	            	                let answerTitle = {
+	            	                    "blocks": [{
+	            	                        "type": "text",
+	            	                        "param": {"bold": true},
+	            	                        "value": "考生答案:"
+	            	                    }, {
+	            	                        "type": "text",
+	            	                        "param": {
+	            	                            "italic": true,
+	            	                            "danger": true
+	            	                        },
+	            	                        "value": "(字数统计:" + textCount(question.studentAnswer) + ")"
+	            	                    }]
+	            	                };
+	            	                let standardTitle = {
+	            	                    "blocks": [{
+	            	                        "type": "text",
+	            	                        "param": {"bold": true},
+	            	                        "value": "标准答案:"
+	            	                    }]
+	            	                };
+	            	                this.holder = $('#trial-left-div');
+	            	                $(renderSection(numberTitle)).appendTo(this.holder);
+	            	                $(renderSection(bodyTitle)).appendTo(this.holder);
+	            	                $(renderRichText(question.body)).appendTo(this.holder);
+	            	                $(renderSection(answerTitle)).appendTo(this.holder);
+	            	                $(renderRichText(question.studentAnswer)).appendTo(this.holder);
+	            	                $(renderSection(standardTitle)).appendTo(this.holder);
+	            	                $(renderRichText(question.answer)).appendTo(this.holder);
+	            	                trialDetailModal.setContent($('#trial-detail-content'));
+	            	            }
+	            	        });
+	               /*  }).error(function () {
+	                	trialDetailModal.setTitle('加载失败')
+	                }); */
+	            }
 	        }else {
 	            trialDetailModal.setTitle('加载失败')
 	        }
         }
     });
 }
+function textCount(jsonBody) {
+    let sections = jsonBody.sections || [];
+    let count = 0;
+    sections.forEach(section => {
+        let blocks = section.blocks || [];
+        blocks.forEach(block => {
+            if (block.type === 'text' && block.value != undefined) {
+                count += block.value.length;
+            }
+        });
+    });
+    return count;
+}
 </script>