题库导入
This commit is contained in:
parent
7993230f06
commit
fe45772be0
|
|
@ -17,7 +17,9 @@ public @interface Excel
|
||||||
/**
|
/**
|
||||||
* 导出到Excel中的名字.
|
* 导出到Excel中的名字.
|
||||||
*/
|
*/
|
||||||
public String name();
|
public String name() default "";
|
||||||
|
|
||||||
|
public int order() default 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 日期格式, 如: yyyy-MM-dd
|
* 日期格式, 如: yyyy-MM-dd
|
||||||
|
|
@ -63,4 +65,7 @@ public @interface Excel
|
||||||
* 是否导出数据,应对需求:有时我们需要导出一份模板,这是标题需要但内容需要用户手工填写.
|
* 是否导出数据,应对需求:有时我们需要导出一份模板,这是标题需要但内容需要用户手工填写.
|
||||||
*/
|
*/
|
||||||
public boolean isExport() default true;
|
public boolean isExport() default true;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -112,16 +112,20 @@ public class ExcelUtil<T>
|
||||||
{
|
{
|
||||||
// 设置类的私有字段属性可访问.
|
// 设置类的私有字段属性可访问.
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
fieldsMap.put(++serialNum, field);
|
Excel annotation = field.getAnnotation(Excel.class);
|
||||||
|
fieldsMap.put(annotation.order(), field);
|
||||||
|
if(annotation.order()>serialNum){
|
||||||
|
serialNum=annotation.order();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = 1; i < rows; i++)
|
for (int i = 2; i < rows; i++)
|
||||||
{
|
{
|
||||||
// 从第2行开始取数据,默认第一行是表头.
|
// 从第2行开始取数据,默认第一行是表头.
|
||||||
Row row = sheet.getRow(i);
|
Row row = sheet.getRow(i);
|
||||||
int cellNum = serialNum;
|
int cellNum = serialNum;
|
||||||
T entity = null;
|
T entity = null;
|
||||||
for (int j = 0; j < cellNum; j++)
|
for (int j = 0; j < serialNum; j++)
|
||||||
{
|
{
|
||||||
Cell cell = row.getCell(j);
|
Cell cell = row.getCell(j);
|
||||||
if (cell == null)
|
if (cell == null)
|
||||||
|
|
@ -145,6 +149,9 @@ public class ExcelUtil<T>
|
||||||
entity = (entity == null ? clazz.newInstance() : entity);
|
entity = (entity == null ? clazz.newInstance() : entity);
|
||||||
// 从map中得到对应列的field.
|
// 从map中得到对应列的field.
|
||||||
Field field = fieldsMap.get(j + 1);
|
Field field = fieldsMap.get(j + 1);
|
||||||
|
if(field==null){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// 取得类型,并根据对象类型设置值.
|
// 取得类型,并根据对象类型设置值.
|
||||||
Class<?> fieldType = field.getType();
|
Class<?> fieldType = field.getType();
|
||||||
if (String.class == fieldType)
|
if (String.class == fieldType)
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,20 @@
|
||||||
package com.ruoyi.exam.controller;
|
package com.ruoyi.exam.controller;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import cn.hutool.json.JSONArray;
|
import cn.hutool.json.JSONArray;
|
||||||
import com.ruoyi.common.json.JSONObject;
|
import com.ruoyi.common.json.JSONObject;
|
||||||
import com.ruoyi.exam.domain.ExamQuestionCategory;
|
import com.ruoyi.exam.domain.ExamQuestionCategory;
|
||||||
|
import com.ruoyi.exam.domain.ExamQuestionFile;
|
||||||
import com.ruoyi.exam.domain.ExamQuestionItem;
|
import com.ruoyi.exam.domain.ExamQuestionItem;
|
||||||
import com.ruoyi.exam.service.IExamQuestionCategoryService;
|
import com.ruoyi.exam.service.IExamQuestionCategoryService;
|
||||||
import com.ruoyi.exam.service.IExamQuestionItemService;
|
import com.ruoyi.exam.service.IExamQuestionItemService;
|
||||||
|
import com.ruoyi.framework.web.util.ShiroUtils;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
|
@ -23,6 +28,7 @@ import com.ruoyi.framework.web.base.BaseController;
|
||||||
import com.ruoyi.framework.web.page.TableDataInfo;
|
import com.ruoyi.framework.web.page.TableDataInfo;
|
||||||
import com.ruoyi.common.base.AjaxResult;
|
import com.ruoyi.common.base.AjaxResult;
|
||||||
import com.ruoyi.common.utils.ExcelUtil;
|
import com.ruoyi.common.utils.ExcelUtil;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -97,14 +103,16 @@ public class ExamQuestionController extends BaseController
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private List<ExamQuestion> getListByIds(List<ExamQuestion> list,ExamQuestion examQuestion){
|
private List<ExamQuestion> getListByIds(List<ExamQuestion> list,ExamQuestion examQuestion){
|
||||||
list.addAll(examQuestionService.selectExamQuestionList(examQuestion));
|
list.addAll(examQuestionService.selectQuestionList(examQuestion));
|
||||||
String categoryId = examQuestion.getCategoryId();
|
String categoryId = examQuestion.getCategoryId();
|
||||||
ExamQuestionCategory examQuestionCategory = new ExamQuestionCategory();
|
if (categoryId != null) {
|
||||||
examQuestionCategory.setParentId(Long.parseLong(categoryId));
|
ExamQuestionCategory examQuestionCategory = new ExamQuestionCategory();
|
||||||
List<ExamQuestionCategory> examQuestionCategories = examQuestionCategoryService.selectList(examQuestionCategory);
|
examQuestionCategory.setParentId(Long.parseLong(categoryId));
|
||||||
for (ExamQuestionCategory questionCategory : examQuestionCategories) {
|
List<ExamQuestionCategory> examQuestionCategories = examQuestionCategoryService.selectList(examQuestionCategory);
|
||||||
examQuestion.setCategoryId(questionCategory.getId().toString());
|
for (ExamQuestionCategory questionCategory : examQuestionCategories) {
|
||||||
getListByIds(list,examQuestion);
|
examQuestion.setCategoryId(questionCategory.getId().toString());
|
||||||
|
getListByIds(list,examQuestion);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
@ -208,4 +216,106 @@ public class ExamQuestionController extends BaseController
|
||||||
return toAjax(examQuestionService.deleteExamQuestionByIds(ids));
|
return toAjax(examQuestionService.deleteExamQuestionByIds(ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@RequiresPermissions("exam:examQuestion:edit")
|
||||||
|
@Log(title = "问题", businessType = BusinessType.DELETE)
|
||||||
|
@PostMapping( "/importfile")
|
||||||
|
@ResponseBody
|
||||||
|
public AjaxResult importfile(@RequestParam("file") MultipartFile file, @RequestParam("categoryId")String id) throws Exception {
|
||||||
|
|
||||||
|
InputStream inputStream = file.getInputStream();
|
||||||
|
|
||||||
|
ExcelUtil<ExamQuestionFile> util = new ExcelUtil<ExamQuestionFile>(ExamQuestionFile.class);
|
||||||
|
List<ExamQuestionFile> examQuestions = util.importExcel(inputStream);
|
||||||
|
|
||||||
|
for (ExamQuestionFile item : examQuestions) {
|
||||||
|
ExamQuestion insert = new ExamQuestion();
|
||||||
|
insert.setCategoryId(id);
|
||||||
|
insert.setCreateBy(ShiroUtils.getLoginName());
|
||||||
|
insert.setAnswer(item.getAnswer());
|
||||||
|
insert.setCreateDate(new Date());
|
||||||
|
insert.setDelFlag("0");
|
||||||
|
insert.setTitle(item.getName());
|
||||||
|
String type = "1";
|
||||||
|
|
||||||
|
if (item.getItemA().equals("正确")||item.getItemA().equals("错误")) {
|
||||||
|
type ="3";
|
||||||
|
}else if(item.getAnswer().split(",").length>1){
|
||||||
|
type="2";
|
||||||
|
}
|
||||||
|
insert.setType(type);
|
||||||
|
insert.setAnswer(item.getAnswer());
|
||||||
|
examQuestionService.insertExamQuestion(insert);
|
||||||
|
if(item.getItemA()!=null&&!item.getItemA().trim().equals("")){
|
||||||
|
ExamQuestionItem examQuestionItem = new ExamQuestionItem();
|
||||||
|
examQuestionItem.setExamQuestionId(insert.getId());
|
||||||
|
examQuestionItem.setNumber("A");
|
||||||
|
examQuestionItem.setContent(item.getItemA());
|
||||||
|
examQuestionItem.setCreateBy(ShiroUtils.getLoginName());
|
||||||
|
examQuestionItem.setCreateDate(new Date());
|
||||||
|
examQuestionItem.setDelFlag("0");
|
||||||
|
examQuestionItemService.insert(examQuestionItem);
|
||||||
|
|
||||||
|
}
|
||||||
|
if(item.getItemB()!=null&&!item.getItemB().trim().equals("")){
|
||||||
|
ExamQuestionItem examQuestionItem = new ExamQuestionItem();
|
||||||
|
examQuestionItem.setExamQuestionId(insert.getId());
|
||||||
|
examQuestionItem.setNumber("B");
|
||||||
|
examQuestionItem.setContent(item.getItemB());
|
||||||
|
examQuestionItem.setCreateBy(ShiroUtils.getLoginName());
|
||||||
|
examQuestionItem.setCreateDate(new Date());
|
||||||
|
examQuestionItem.setDelFlag("0");
|
||||||
|
examQuestionItemService.insert(examQuestionItem);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
if(item.getItemC()!=null&&!item.getItemC().trim().equals("")){
|
||||||
|
ExamQuestionItem examQuestionItem = new ExamQuestionItem();
|
||||||
|
examQuestionItem.setExamQuestionId(insert.getId());
|
||||||
|
examQuestionItem.setNumber("C");
|
||||||
|
examQuestionItem.setContent(item.getItemC());
|
||||||
|
examQuestionItem.setCreateBy(ShiroUtils.getLoginName());
|
||||||
|
examQuestionItem.setCreateDate(new Date());
|
||||||
|
examQuestionItem.setDelFlag("0");
|
||||||
|
examQuestionItemService.insert(examQuestionItem);
|
||||||
|
|
||||||
|
}
|
||||||
|
if(item.getItemD()!=null&&!item.getItemD().trim().equals("")){
|
||||||
|
ExamQuestionItem examQuestionItem = new ExamQuestionItem();
|
||||||
|
examQuestionItem.setExamQuestionId(insert.getId());
|
||||||
|
examQuestionItem.setNumber("D");
|
||||||
|
examQuestionItem.setContent(item.getItemD());
|
||||||
|
examQuestionItem.setCreateBy(ShiroUtils.getLoginName());
|
||||||
|
examQuestionItem.setCreateDate(new Date());
|
||||||
|
examQuestionItem.setDelFlag("0");
|
||||||
|
examQuestionItemService.insert(examQuestionItem);
|
||||||
|
|
||||||
|
}
|
||||||
|
if(item.getItemE()!=null&&!item.getItemE().trim().equals("")){
|
||||||
|
ExamQuestionItem examQuestionItem = new ExamQuestionItem();
|
||||||
|
examQuestionItem.setExamQuestionId(insert.getId());
|
||||||
|
examQuestionItem.setNumber("E");
|
||||||
|
examQuestionItem.setContent(item.getItemE());
|
||||||
|
examQuestionItem.setCreateBy(ShiroUtils.getLoginName());
|
||||||
|
examQuestionItem.setCreateDate(new Date());
|
||||||
|
examQuestionItem.setDelFlag("0");
|
||||||
|
examQuestionItemService.insert(examQuestionItem);
|
||||||
|
|
||||||
|
}
|
||||||
|
if(item.getItemF()!=null&&!item.getItemF().trim().equals("")){
|
||||||
|
ExamQuestionItem examQuestionItem = new ExamQuestionItem();
|
||||||
|
examQuestionItem.setExamQuestionId(insert.getId());
|
||||||
|
examQuestionItem.setNumber("F");
|
||||||
|
examQuestionItem.setContent(item.getItemF());
|
||||||
|
examQuestionItem.setCreateBy(ShiroUtils.getLoginName());
|
||||||
|
examQuestionItem.setCreateDate(new Date());
|
||||||
|
examQuestionItem.setDelFlag("0");
|
||||||
|
examQuestionItemService.insert(examQuestionItem);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return success("导入成功");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.ruoyi.exam.domain;
|
package com.ruoyi.exam.domain;
|
||||||
|
|
||||||
|
import com.ruoyi.common.annotation.Excel;
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
import com.ruoyi.common.base.BaseEntity;
|
import com.ruoyi.common.base.BaseEntity;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,90 @@
|
||||||
|
package com.ruoyi.exam.domain;
|
||||||
|
|
||||||
|
import com.ruoyi.common.annotation.Excel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by flower on 2019/1/1.
|
||||||
|
*/
|
||||||
|
public class ExamQuestionFile {
|
||||||
|
|
||||||
|
@Excel(order = 1)
|
||||||
|
private String name;
|
||||||
|
@Excel(order = 10)
|
||||||
|
private String answer;
|
||||||
|
@Excel(order = 4)
|
||||||
|
private String itemA;
|
||||||
|
@Excel(order = 5)
|
||||||
|
private String itemB;
|
||||||
|
@Excel(order = 6)
|
||||||
|
private String itemC;
|
||||||
|
@Excel(order = 7)
|
||||||
|
private String itemD;
|
||||||
|
@Excel(order = 8)
|
||||||
|
private String itemE;
|
||||||
|
@Excel(order = 9)
|
||||||
|
private String itemF;
|
||||||
|
|
||||||
|
public String getItemA() {
|
||||||
|
return itemA;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItemA(String itemA) {
|
||||||
|
this.itemA = itemA;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getItemB() {
|
||||||
|
return itemB;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItemB(String itemB) {
|
||||||
|
this.itemB = itemB;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getItemC() {
|
||||||
|
return itemC;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItemC(String itemC) {
|
||||||
|
this.itemC = itemC;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getItemD() {
|
||||||
|
return itemD;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItemD(String itemD) {
|
||||||
|
this.itemD = itemD;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getItemE() {
|
||||||
|
return itemE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItemE(String itemE) {
|
||||||
|
this.itemE = itemE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getItemF() {
|
||||||
|
return itemF;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItemF(String itemF) {
|
||||||
|
this.itemF = itemF;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAnswer() {
|
||||||
|
return answer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAnswer(String answer) {
|
||||||
|
this.answer = answer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
package com.ruoyi.exam.service;
|
package com.ruoyi.exam.service;
|
||||||
|
|
||||||
import com.ruoyi.exam.domain.ExamQuestion;
|
import com.ruoyi.exam.domain.ExamQuestion;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.ruoyi.framework.web.base.AbstractBaseService;
|
import com.ruoyi.framework.web.base.AbstractBaseService;
|
||||||
/**
|
/**
|
||||||
|
|
@ -56,4 +58,6 @@ public interface IExamQuestionService extends AbstractBaseService<ExamQuestion>
|
||||||
int updateQuestion(ExamQuestion examQuestion, String[] number, String[] content);
|
int updateQuestion(ExamQuestion examQuestion, String[] number, String[] content);
|
||||||
|
|
||||||
List<ExamQuestion> selectByIds(List<String> ids);
|
List<ExamQuestion> selectByIds(List<String> ids);
|
||||||
|
|
||||||
|
List<ExamQuestion> selectQuestionList(ExamQuestion examQuestion);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -150,4 +150,9 @@ public class ExamQuestionServiceImpl extends AbstractBaseServiceImpl<ExamQuestio
|
||||||
return examQuestionMapper.selectByIds(substring.toString());
|
return examQuestionMapper.selectByIds(substring.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ExamQuestion> selectQuestionList(ExamQuestion examQuestion) {
|
||||||
|
return examQuestionMapper.selectExamQuestionList(examQuestion);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<insert id="insertExamQuestion" parameterType="ExamQuestion">
|
<insert id="insertExamQuestion" keyProperty="id" useGeneratedKeys="true" parameterType="ExamQuestion">
|
||||||
insert into exam_question
|
insert into exam_question
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
<if test="id != null and id != '' ">id,</if>
|
<if test="id != null and id != '' ">id,</if>
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,8 @@
|
||||||
<li>
|
<li>
|
||||||
问题类型:<select name="type" th:with="type=${@dict.getType('exam_question_type')}">
|
问题类型:<select name="type" th:with="type=${@dict.getType('exam_question_type')}">
|
||||||
<option value="">所有</option>
|
<option value="">所有</option>
|
||||||
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
|
<option th:each="dict : ${type}" th:text="${dict.dictLabel}"
|
||||||
|
th:value="${dict.dictValue}"></option>
|
||||||
</select>
|
</select>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
|
@ -61,6 +62,9 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="btn-group-sm hidden-xs" id="toolbar" role="group">
|
<div class="btn-group-sm hidden-xs" id="toolbar" role="group">
|
||||||
|
|
||||||
|
<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">导入</button>
|
||||||
|
|
||||||
<a class="btn btn-success" onclick="addChoiceQuestion()" shiro:hasPermission="exam:examQuestion:add">
|
<a class="btn btn-success" onclick="addChoiceQuestion()" shiro:hasPermission="exam:examQuestion:add">
|
||||||
<i class="fa fa-plus"></i> 添加单选题
|
<i class="fa fa-plus"></i> 添加单选题
|
||||||
</a>
|
</a>
|
||||||
|
|
@ -85,6 +89,24 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- 模态框(Modal) -->
|
||||||
|
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||||
|
<h4 class="modal-title" id="myModalLabel">导入试题</h4>
|
||||||
|
</div>
|
||||||
|
<input id="questionFile" type="file" class="file" data-show-preview="false"
|
||||||
|
data-allowed-file-extensions='["docx","png"]'>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
|
||||||
|
<button type="button" class="btn btn-primary" onclick="importFile()">确定</button>
|
||||||
|
</div>
|
||||||
|
</div><!-- /.modal-content -->
|
||||||
|
</div><!-- /.modal -->
|
||||||
|
</div>
|
||||||
<div th:include="include :: footer"></div>
|
<div th:include="include :: footer"></div>
|
||||||
<script th:src="@{/ajax/libs/jquery-layout/jquery.layout-latest.js}"></script>
|
<script th:src="@{/ajax/libs/jquery-layout/jquery.layout-latest.js}"></script>
|
||||||
<script th:src="@{/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.all-3.5.js}"></script>
|
<script th:src="@{/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.all-3.5.js}"></script>
|
||||||
|
|
@ -114,8 +136,8 @@
|
||||||
showExport: true,
|
showExport: true,
|
||||||
columns: [{
|
columns: [{
|
||||||
checkbox: true
|
checkbox: true
|
||||||
},{
|
}, {
|
||||||
field:"id",
|
field: "id",
|
||||||
title: '#',
|
title: '#',
|
||||||
visible: false
|
visible: false
|
||||||
},
|
},
|
||||||
|
|
@ -128,7 +150,7 @@
|
||||||
field: 'type',
|
field: 'type',
|
||||||
title: '问题类型',
|
title: '问题类型',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
formatter: function(value, item, index) {
|
formatter: function (value, item, index) {
|
||||||
debugger
|
debugger
|
||||||
return $.table.selectDictLabel(type, item.type);
|
return $.table.selectDictLabel(type, item.type);
|
||||||
}
|
}
|
||||||
|
|
@ -196,40 +218,73 @@
|
||||||
createMenuItem(url, "题库管理");
|
createMenuItem(url, "题库管理");
|
||||||
}
|
}
|
||||||
|
|
||||||
function addChoiceQuestion(){
|
function addChoiceQuestion() {
|
||||||
if(!$.tree.notAllowParents($._tree)){
|
if (!$.tree.notAllowParents($._tree)) {
|
||||||
return ;
|
return;
|
||||||
}
|
}
|
||||||
if($("#categoryId").val()==1){
|
if ($("#categoryId").val() == 1) {
|
||||||
$.modal.alertWarning("请选择试题分类");
|
$.modal.alertWarning("请选择试题分类");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var url = prefix + "/choiceadd/"+$("#categoryId").val();
|
var url = prefix + "/choiceadd/" + $("#categoryId").val();
|
||||||
$.operate.jumpModeltoUrl("添加单选题",url);
|
$.operate.jumpModeltoUrl("添加单选题", url);
|
||||||
}
|
}
|
||||||
|
|
||||||
function addMoreChoiceQuestion(){
|
function addMoreChoiceQuestion() {
|
||||||
if(!$.tree.notAllowParents($._tree)){
|
if (!$.tree.notAllowParents($._tree)) {
|
||||||
return ;
|
return;
|
||||||
}
|
}
|
||||||
if($("#categoryId").val()==1){
|
if ($("#categoryId").val() == 1) {
|
||||||
$.modal.alertWarning("请选择试题分类");
|
$.modal.alertWarning("请选择试题分类");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var url = prefix + "/morechoiceadd/"+$("#categoryId").val();
|
var url = prefix + "/morechoiceadd/" + $("#categoryId").val();
|
||||||
$.operate.jumpModeltoUrl("添加多选题",url);
|
$.operate.jumpModeltoUrl("添加多选题", url);
|
||||||
}
|
}
|
||||||
|
|
||||||
function addJudgeQuestion(){
|
function addJudgeQuestion() {
|
||||||
if(!$.tree.notAllowParents($._tree)){
|
if (!$.tree.notAllowParents($._tree)) {
|
||||||
return ;
|
return;
|
||||||
}
|
}
|
||||||
if($("#categoryId").val()==1){
|
if ($("#categoryId").val() == 1) {
|
||||||
$.modal.alertWarning("请选择试题分类");
|
$.modal.alertWarning("请选择试题分类");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var url = prefix + "/judgeadd/"+$("#categoryId").val();
|
var url = prefix + "/judgeadd/" + $("#categoryId").val();
|
||||||
$.operate.jumpModeltoUrl("添加多选题",url);
|
$.operate.jumpModeltoUrl("添加多选题", url);
|
||||||
|
}
|
||||||
|
|
||||||
|
function importFile() {
|
||||||
|
if (!$.tree.notAllowParents($._tree)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($("#categoryId").val() == 1) {
|
||||||
|
$.modal.alertWarning("请选择试题分类");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var formData = new FormData();
|
||||||
|
formData.append("file", document.getElementById("questionFile").files[0]);
|
||||||
|
formData.append("categoryId", $("#categoryId").val());
|
||||||
|
$.ajax({
|
||||||
|
type: 'post',
|
||||||
|
url: prefix + "/importfile",
|
||||||
|
dataType: 'json',
|
||||||
|
data: formData,
|
||||||
|
contentType: false,
|
||||||
|
processData: false,
|
||||||
|
success: function (data) {
|
||||||
|
if (data.code == web_status.SUCCESS) {
|
||||||
|
$.modal.msgSuccess(data.msg);
|
||||||
|
$('#myModal').modal('hide')
|
||||||
|
$.table.search();
|
||||||
|
}else{
|
||||||
|
$.modal.msgError(result.msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue