|
@@ -22,7 +22,7 @@
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</body>
|
|
<script type="text/javascript">
|
|
<script type="text/javascript">
|
|
-var url = "${answerServer}${answerUrl}";
|
|
|
|
|
|
+var url = "${jsonServer}${answerUrl}";
|
|
var questionNumbers ="${questionNumbers}";
|
|
var questionNumbers ="${questionNumbers}";
|
|
|
|
|
|
$(document).ready(function() {
|
|
$(document).ready(function() {
|
|
@@ -40,34 +40,75 @@ function initJsonPopover(url,questionNumbers){
|
|
//var data ='[{"mainNumber": 6,"subNumber": 1,"body": {"sections": [{ "blocks":[{"type": "text","value": "我是题目我是题目我是题目"}]}]},"answer": {"sections": [{"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"}]}]}}]';
|
|
//var data ='[{"mainNumber": 6,"subNumber": 1,"body": {"sections": [{ "blocks":[{"type": "text","value": "我是题目我是题目我是题目"}]}]},"answer": {"sections": [{"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"}]}]}}]';
|
|
//data = JSON.parse(data);
|
|
//data = JSON.parse(data);
|
|
let questions = data || [];
|
|
let questions = data || [];
|
|
- if(questionNumbers != undefined && questionNumbers != ""){
|
|
|
|
- var questionNumberArr = questionNumbers.split(",");
|
|
|
|
- questions.forEach(question => {
|
|
|
|
- //按题号过滤
|
|
|
|
- if(questionNumberArr.indexOf(question.mainNumber+"."+question.subNumber) == -1){
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
- var questionTitle = '<span>题号:'+ question.mainNumber+'-'+question.subNumber +'<span></br>';
|
|
|
|
- $(questionTitle).appendTo($('#json-view-content'));
|
|
|
|
- $("<span>题干:<span>"+renderRichText(question.body)).appendTo($('#json-view-content'));
|
|
|
|
- $("<span>考生答案:<span>"+renderRichText(question.studentAnswer)).appendTo('#json-view-content');
|
|
|
|
- $("<span>标准答案:<span>"+renderRichText(question.answer)).appendTo('#json-view-content');
|
|
|
|
- });
|
|
|
|
- }else{
|
|
|
|
- questions.forEach(question => {
|
|
|
|
- var questionTitle = '<span>题号:'+ question.mainNumber+'-'+question.subNumber +'<span><br/>';
|
|
|
|
- $(questionTitle).appendTo($('#json-view-content'));
|
|
|
|
- $("<span>题干:<span>"+renderRichText(question.body)).appendTo($('#json-view-content'));
|
|
|
|
- $("<span>考生答案:<span>"+renderRichText(question.studentAnswer)).appendTo('#json-view-content');
|
|
|
|
- $("<span>标准答案:<span>"+renderRichText(question.answer)).appendTo('#json-view-content');
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- const viewer = new Viewer($('#json-view-content')[0], {
|
|
|
|
- });
|
|
|
|
|
|
+ questions.forEach(question => {
|
|
|
|
+ // 按题号过滤
|
|
|
|
+ if (questionNumbers[question.mainNumber + "." + question.subNumber] === true || questionNumbers=="") {
|
|
|
|
+ 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 = $('#json-view-content');
|
|
|
|
+ $(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);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ if (this.viewer !== undefined) {
|
|
|
|
+ this.viewer.destroy();
|
|
|
|
+ }
|
|
|
|
+ const viewer = new Viewer($('#json-view-content')[0], {});
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+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>
|
|
</script>
|
|
|
|
|
|
|
|
|