调整页面

This commit is contained in:
wanggeng 2022-08-12 23:14:33 +08:00
parent ae158c0ab8
commit 95b13a89f4
5 changed files with 113 additions and 219 deletions

View File

@ -0,0 +1,11 @@
package ink.wgink.module.examine.service.examine;
/**
* @ClassName: IExamineService
* @Description: 考试
* @Author: wanggeng
* @Date: 2022/8/9 11:40
* @Version: 1.0
*/
public interface IExamineService {
}

View File

@ -0,0 +1,81 @@
package ink.wgink.module.examine.service.examine.impl;
import ink.wgink.module.examine.service.examine.IExamineService;
import org.springframework.stereotype.Service;
import java.util.Observable;
/**
* @ClassName: ExamineServiceImpl
* @Description: 考试
* @Author: wanggeng
* @Date: 2022/8/9 11:41
* @Version: 1.0
*/
@Service
public class ExamineServiceImpl extends Observable implements IExamineService {
private String text;
public static void main(String[] args) {
// JSONObject jsonObject = JSONObject.of("k1", "v1");
// JSONObject jo2 = JSONObject.of("k21", "v21");
// jsonObject.put("k2", jo2);
//
// System.out.println(jsonObject.keySet());
// String regular = "var datas = []; function callback() {return datas}";
//
// ScriptEngine engine = new ScriptEngineManager().getEngineByName("javascript");
// try {
// engine.eval(regular);
// if (engine instanceof Invocable) {
// Invocable invoke = (Invocable) engine;
// Object result = invoke.invokeFunction("callback");
// System.out.println(result);
// } else {
// System.out.println("error");
// }
// } catch (ScriptException e) {
// System.out.println("表达式runtime错误:" + e.getMessage());
// } catch (NoSuchMethodException e) {
// throw new RuntimeException(e);
// }
ExamineServiceImpl observer = new ExamineServiceImpl();
//添加观察者
observer.addObserver((o, arg) -> {
ExamineServiceImpl examineService = (ExamineServiceImpl) o;
System.out.println(examineService.getText());
System.out.println(arg);
System.out.println("观察者1收到通知");
});
observer.addObserver((o, arg) -> {
System.out.println("观察者2收到通知");
});
observer.addObserver((o, arg) -> {
System.out.println("观察者3收到通知");
});
observer.addObserver((o, arg) -> {
System.out.println("观察者4收到通知");
});
observer.addObserver((o, arg) -> {
System.out.println("观察者5收到通知");
});
observer.addObserver((o, arg) -> {
System.out.println("观察者6收到通知");
});
observer.setText("123");
observer.setChanged(); //数据变化
observer.notifyObservers(); //通知
}
public String getText() {
return text == null ? "" : text.trim();
}
public void setText(String text) {
this.text = text;
}
}

View File

@ -209,7 +209,6 @@ public class QuestionServiceImpl extends DefaultBaseService implements IQuestion
return questionDTO;
}
@Override
public List<QuestionDTO> list(Map<String, Object> params) throws SearchException {
List<QuestionDTO> questionDTOs = questionDao.list(params);

View File

@ -34,7 +34,7 @@
<div class="layui-form-item layui-form-text">
<label class="layui-form-label">题目(填空题用下划线"_"占位,一个下划线对应一个答案)</label>
<div class="layui-input-block">
<div id="subject"></div>
<textarea id="subject" name="subject" required lay-verify="required" placeholder="请输入题目" class="layui-textarea"></textarea>
</div>
</div>
<div class="layui-form-item">
@ -148,7 +148,7 @@
<div class="layui-form-item layui-form-text">
<label class="layui-form-label">解析</label>
<div class="layui-input-block">
<div id="analysis"></div>
<textarea id="analysis" name="analysis" required lay-verify="required" placeholder="请输入解析" class="layui-textarea"></textarea>
</div>
</div>
<div class="layui-form-item" pane>
@ -216,7 +216,7 @@
// 刷新空格
function refreshFillInTheBlanks() {
var blankCount = 0;
var subject = wangEditorObj['subject'].txt.text();
var subject = $('#subject').val();
for(var i = 0, item; item = subject[i++];) {
if(item === '_') {
blankCount++;
@ -234,96 +234,17 @@
document.getElementById('fillInTheBlanksAnswerTemplateBox').innerHTML = html;
});
}
// 富文本设置
function editorMenus() {
return [
'bold', // 粗体
'italic', // 斜体
'underline', // 下划线
'strikeThrough', // 删除线
'foreColor', // 文字颜色
'backColor', // 背景颜色
'link', // 插入链接
'list', // 列表
'quote', // 引用
'image', // 插入图片
'table', // 表格
'undo', // 撤销
'redo' // 重复
]
}
function editorPasteTextHandle(content) {
if (content == '' && !content) {
return ''
// 课题输入事件
$(document).on('keyup', '#subject', function() {
if(type != 'fillInTheBlanks') {
return;
}
var str = content;
str = str.replace(/<xml>[\s\S]*?<\/xml>/ig, '');
str = str.replace('/class=(")?Mso[a-zA-Z]+(")?)/g', '');
str = str.replace(/\n|\r/ig, '')
var reg = new RegExp('<!--(.*?)-->','g')
str = str.replace(/<style>[\s\S]*?<\/style>/ig, '')
str = str.replace(/<\/?[^>]*>/g, '')
str = str.replace(/[ | ]*\n/g, '')
str = str.replace(/&nbsp;/ig, '')
str = str.replace(reg,'')
return str;
}
// 初始化题目富文本
function initSubjectRichText() {
var editor = new wangEditor('#subject');
editor.customConfig.zIndex = 50;
editor.customConfig.uploadImgMaxSize = 5 * 1024 * 1024;
editor.customConfig.uploadImgMaxLength = 1;
editor.customConfig.uploadFileName = 'image';
editor.customConfig.uploadImgServer = 'api/file/wangeditorimage';
editor.customConfig.uploadImgHooks = {
fail: function (xhr, editor, result) {
top.dialog.msg('系统错误,图片上传失败');
},
error: function (xhr, editor) {
top.dialog.msg('网络异常');
},
timeout: function (xhr, editor) {
top.dialog.msg('网络请求超时');
}
};
editor.customConfig.menus = editorMenus();
editor.customConfig.onchange = function(html) {
if(type != 'fillInTheBlanks') {
return;
}
setFillInTheBlanksAnswerContent();
refreshFillInTheBlanks();
}
editor.customConfig.pasteTextHandle = editorPasteTextHandle;
editor.create();
wangEditorObj['subject'] = editor;
}
setFillInTheBlanksAnswerContent();
refreshFillInTheBlanks();
});
// 初始化解析富文本
function initAnalysisRichText() {
var editor = new wangEditor('#analysis');
editor.customConfig.zIndex = 50;
editor.customConfig.uploadImgMaxSize = 5 * 1024 * 1024;
editor.customConfig.uploadImgMaxLength = 1;
editor.customConfig.uploadFileName = 'image';
editor.customConfig.uploadImgServer = 'api/file/wangeditorimage';
editor.customConfig.uploadImgHooks = {
fail: function (xhr, editor, result) {
top.dialog.msg('系统错误,图片上传失败');
},
error: function (xhr, editor) {
top.dialog.msg('网络异常');
},
timeout: function (xhr, editor) {
top.dialog.msg('网络请求超时');
}
};
editor.customConfig.menus = editorMenus();
editor.customConfig.pasteTextHandle = editorPasteTextHandle;
editor.create();
wangEditorObj['analysis'] = editor;
}
function initAnalysisRichText() {}
// 设置选择答案 - 用于缓存临时答案,防止新增时取消状态
function setQuestionOptionAnswer() {
var dataFormData = {};
@ -463,14 +384,6 @@
}
// 提交表单
form.on('submit(submitForm)', function(formData) {
if(!wangEditorObj['subject'].txt.text()) {
top.dialog.msg('题目不能为空');
return;
}
if(!wangEditorObj['analysis'].txt.text()) {
top.dialog.msg('解析不能为空');
return;
}
if(formData.field['type'] === 'choice') {
if(choiceOption.optionArray.length === 0) {
top.dialog.msg('试题选项不能为空');
@ -508,8 +421,6 @@
top.dialog.close(index);
var loadLayerIndex;
formData.field['subject'] = wangEditorObj['subject'].txt.html();
formData.field['analysis'] = wangEditorObj['analysis'].txt.html();
formData.field['options'] = choiceOption.optionArray;
top.restAjax.post(top.restAjax.path('api/question/save', []), formData.field, null, function(code, data) {
var layerIndex = top.dialog.msg(top.dataMessage.commitSuccess, {
@ -536,10 +447,7 @@
});
// 初始化内容
function initData() {
initSubjectRichText();
initAnalysisRichText();
}
function initData() {}
initData();
// 单选事件
form.on('radio(choiceTypeSingleFilter)', function(data) {

View File

@ -34,7 +34,7 @@
<div class="layui-form-item layui-form-text">
<label class="layui-form-label layui-form">题目</label>
<div class="layui-input-block">
<div id="subject"></div>
<textarea id="subject" name="subject" required lay-verify="required" placeholder="请输入题目" class="layui-textarea"></textarea>
</div>
</div>
<div class="layui-form-item">
@ -148,7 +148,7 @@
<div class="layui-form-item layui-form-text">
<label class="layui-form-label layui-form">解析</label>
<div class="layui-input-block">
<div id="analysis"></div>
<textarea id="analysis" name="analysis" required lay-verify="required" placeholder="请输入解析" class="layui-textarea"></textarea>
</div>
</div>
<div class="layui-form-item" pane>
@ -239,107 +239,14 @@
function closeBox() {
parent.layer.close(parent.layer.getFrameIndex(window.name));
}
function refreshDownloadTemplet(fileName, file) {
var dataRander = {};
dataRander[fileName] = file;
laytpl(document.getElementById(fileName +'FileDownload').innerHTML).render(dataRander, function(html) {
document.getElementById(fileName +'FileBox').innerHTML = html;
});
}
// 富文本设置
function editorMenus() {
return [
'bold', // 粗体
'italic', // 斜体
'underline', // 下划线
'strikeThrough', // 删除线
'foreColor', // 文字颜色
'backColor', // 背景颜色
'link', // 插入链接
'list', // 列表
'quote', // 引用
'image', // 插入图片
'table', // 表格
'undo', // 撤销
'redo' // 重复
]
}
function editorPasteTextHandle(content) {
if (content == '' && !content) {
return ''
// 课题输入事件
$(document).on('keyup', '#subject', function() {
if(type != 'fillInTheBlanks') {
return;
}
var str = content;
str = str.replace(/<xml>[\s\S]*?<\/xml>/ig, '');
str = str.replace('/class=(")?Mso[a-zA-Z]+(")?)/g', '');
str = str.replace(/\n|\r/ig, '')
var reg = new RegExp('<!--(.*?)-->','g')
str = str.replace(/<style>[\s\S]*?<\/style>/ig, '')
str = str.replace(/<\/?[^>]*>/g, '')
str = str.replace(/[ | ]*\n/g, '')
str = str.replace(/&nbsp;/ig, '')
str = str.replace(reg,'')
return str;
}
// 初始化题目富文本
function initSubjectRichText(value) {
var editor = new wangEditor('#subject');
editor.customConfig.zIndex = 50;
editor.customConfig.uploadImgMaxSize = 5 * 1024 * 1024;
editor.customConfig.uploadImgMaxLength = 1;
editor.customConfig.uploadFileName = 'image';
editor.customConfig.uploadImgServer = 'api/file/wangeditorimage';
editor.customConfig.uploadImgHooks = {
fail: function (xhr, editor, result) {
top.dialog.msg('系统错误,图片上传失败');
},
error: function (xhr, editor) {
top.dialog.msg('网络异常');
},
timeout: function (xhr, editor) {
top.dialog.msg('网络请求超时');
}
};
editor.customConfig.menus = editorMenus();
editor.customConfig.onchange = function(html) {
if(type != 'fillInTheBlanks') {
return;
}
setFillInTheBlanksAnswerContent();
refreshFillInTheBlanks();
}
editor.customConfig.pasteTextHandle = editorPasteTextHandle;
editor.create();
editor.txt.html(value);
wangEditorObj['subject'] = editor;
}
// 初始化解析富文本
function initAnalysisRichText(value) {
var editor = new wangEditor('#analysis');
editor.customConfig.zIndex = 50;
editor.customConfig.uploadImgMaxSize = 5 * 1024 * 1024;
editor.customConfig.uploadImgMaxLength = 1;
editor.customConfig.uploadFileName = 'image';
editor.customConfig.uploadImgServer = 'api/file/wangeditorimage';
editor.customConfig.uploadImgHooks = {
fail: function (xhr, editor, result) {
top.dialog.msg('系统错误,图片上传失败');
},
error: function (xhr, editor) {
top.dialog.msg('网络异常');
},
timeout: function (xhr, editor) {
top.dialog.msg('网络请求超时');
}
};
editor.customConfig.menus = editorMenus();
editor.customConfig.pasteTextHandle = editorPasteTextHandle;
editor.create();
editor.txt.html(value);
wangEditorObj['analysis'] = editor;
}
setFillInTheBlanksAnswerContent();
refreshFillInTheBlanks();
});
// 设置选择答案 - 用于缓存临时答案,防止新增时取消状态
function setQuestionOptionAnswer() {
var dataFormData = {};
@ -487,14 +394,6 @@
}
// 提交表单
form.on('submit(submitForm)', function(formData) {
if(!wangEditorObj['subject'].txt.text()) {
top.dialog.msg('题目不能为空');
return;
}
if(!wangEditorObj['analysis'].txt.text()) {
top.dialog.msg('解析不能为空');
return;
}
if(formData.field['type'] === 'choice') {
if(choiceOption.optionArray.length === 0) {
top.dialog.msg('试题选项不能为空');
@ -530,8 +429,6 @@
top.dialog.confirm(top.dataMessage.commit, function(index) {
top.dialog.close(index);
var loadLayerIndex;
formData.field['subject'] = wangEditorObj['subject'].txt.html();
formData.field['analysis'] = wangEditorObj['analysis'].txt.html();
formData.field['options'] = choiceOption.optionArray;
top.restAjax.put(top.restAjax.path('api/question/update/{questionId}', [questionId]), formData.field, null, function(code, data) {
var layerIndex = top.dialog.msg(top.dataMessage.updateSuccess, {
@ -565,8 +462,6 @@
for(var i in data) {
dataFormData[i] = data[i] +'';
}
initSubjectRichText(data['subject']);
initAnalysisRichText(data['analysis']);
type = data['type'];
choiceOption.choiceType = data['choiceType'];
if(type === 'choice' || type === 'tureOrFalse') {