Commit 88d3e149 authored by zhangjianqian's avatar zhangjianqian

Merge remote-tracking branch 'origin/master'

parents fb499b15 95f5a2fd
......@@ -16,6 +16,12 @@
</description>
<dependencies>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.40</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
......
......@@ -164,23 +164,23 @@ public class TBankSubjectController extends BaseController
}
}
/**答案*/
if ("A".equals(row.getCell(9).toString())){
excelEntity.setAnswer(0);
}else if ("B".equals(row.getCell(9).toString())){
excelEntity.setAnswer(1);
}else if ("C".equals(row.getCell(9).toString())){
excelEntity.setAnswer(2);
}else if ("D".equals(row.getCell(9).toString())){
excelEntity.setAnswer(3);
}else if ("E".equals(row.getCell(9).toString())){
excelEntity.setAnswer(4);
}else if ("F".equals(row.getCell(9).toString())){
excelEntity.setAnswer(5);
}else if ("G".equals(row.getCell(9).toString())){
excelEntity.setAnswer(6);
}else if ("H".equals(row.getCell(9).toString())){
excelEntity.setAnswer(7);
}
// if ("A".equals(row.getCell(9).toString())){
// excelEntity.setAnswer(0);
// }else if ("B".equals(row.getCell(9).toString())){
// excelEntity.setAnswer(1);
// }else if ("C".equals(row.getCell(9).toString())){
// excelEntity.setAnswer(2);
// }else if ("D".equals(row.getCell(9).toString())){
// excelEntity.setAnswer(3);
// }else if ("E".equals(row.getCell(9).toString())){
// excelEntity.setAnswer(4);
// }else if ("F".equals(row.getCell(9).toString())){
// excelEntity.setAnswer(5);
// }else if ("G".equals(row.getCell(9).toString())){
// excelEntity.setAnswer(6);
// }else if ("H".equals(row.getCell(9).toString())){
// excelEntity.setAnswer(7);
// }
excelEntity.setTopicOption(String.valueOf(jsonArray));
excelEntity.setDatetime(new Date());
list.add(excelEntity);
......
package com.zehong.web.controller.train;
import com.alibaba.fastjson.JSON;
import com.zehong.common.annotation.Log;
import com.zehong.common.core.controller.BaseController;
import com.zehong.common.core.domain.AjaxResult;
......@@ -25,7 +26,7 @@ import java.util.Map;
/**
* 培训课程Controller
*
*
* @author zehong
* @date 2022-09-19
*/
......@@ -65,8 +66,10 @@ public class TTrainCourseController extends BaseController
@ApiOperation("用户课程考试")
@GetMapping("/examination")
public AjaxResult examination(Long userCourseId,String answers){
Map<String,Object> map = tTrainCourseService.examination(userCourseId, answers.split(","));
String n="["+answers+']';
//字符串转换成二维数组
Integer[][] integers = JSON.parseObject(n, Integer[][].class);
Map<String,Object> map = tTrainCourseService.examination(userCourseId,integers);
return AjaxResult.success(map);
}
/**
......
......@@ -26,7 +26,7 @@ import com.zehong.common.core.page.TableDataInfo;
/**
* 培训课程题库Controller
*
*
* @author zehong
* @date 2022-09-19
*/
......@@ -133,4 +133,12 @@ public class TTrainCourseTopicController extends BaseController
public AjaxResult bachAddTopic(@RequestBody BatchTopicVo batchTopicVo){
return toAjax(tTrainCourseTopicService.bachAddTopic(batchTopicVo));
}
/**
* 培训课程管理批量导入试题
*/
@PostMapping("/addTTrainCourseTopic")
public AjaxResult addTTrainCourseTopic(@RequestBody BatchTopicVo batchTopicVo){
return toAjax(tTrainCourseTopicService.addTTrainCourseTopic(batchTopicVo));
}
}
......@@ -2,11 +2,17 @@ package com.zehong.web.controller.videomonitor;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.util.StringUtil;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.core.redis.RedisCache;
import com.zehong.common.utils.StringUtils;
import com.zehong.system.domain.TDeviceAlarmInfo;
import com.zehong.system.domain.TEntranceGuardPersonInfo;
import com.zehong.system.domain.vo.ArtemisPerson;
import com.zehong.system.service.ITDeviceAlarmInfoService;
import com.zehong.system.service.ITEntranceGuardPersonInfoService;
import com.zehong.web.uitls.ArtemisUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -15,8 +21,11 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
......@@ -33,6 +42,8 @@ public class SubscriptionEventController {
private RedisCache redisCache;
@Autowired
private ITDeviceAlarmInfoService tDeviceAlarmInfoService;
@Autowired
private ITEntranceGuardPersonInfoService tEntranceGuardPersonInfoService;
/**
* 烟雾检测订阅事件
......@@ -58,16 +69,83 @@ public class SubscriptionEventController {
@PostMapping("/faceVerification")
public AjaxResult faceVerification(@RequestBody Map<String,Object> faceVeriy){
logger.info("人脸验证信息:"+ JSON.toJSONString(faceVeriy));
try {
logger.info("人脸验证信息:"+ JSON.toJSONString(faceVeriy));
//解析人脸信息
entranceGuardEventDeal(faceVeriy);
} catch (Exception e) {
logger.error("人脸通过信息接收失败:" + e);
}
return AjaxResult.success();
}
@PostMapping("/patrolCardCheck")
public AjaxResult patrolCardCheck(@RequestBody Map<String,Object> patrolCard){
logger.info("巡查卡比对信息信息:"+ JSON.toJSONString(patrolCard));
try {
logger.info("巡查卡比对信息:"+ JSON.toJSONString(patrolCard));
//解析人脸信息
entranceGuardEventDeal(patrolCard);
} catch (Exception e) {
logger.error("巡查卡比对信息接收失败:" + e);
}
return AjaxResult.success();
}
/**
* 门禁事件解析
*/
private void entranceGuardEventDeal(Map<String,Object> entranceGuardEvent) throws Exception {
//解析人脸信息
JSONObject params = (JSONObject) JSON.toJSON(entranceGuardEvent.get("params"));
List<JSONObject> events = (List<JSONObject>) params.get("events");
if(null== events || events.size() == 0){
throw new Exception("订阅信息有误不包含events信息");
}
for(JSONObject event : events){
Date happenTime = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'+'").parse((String)event.get("happenTime"));
if((System.currentTimeMillis() - happenTime.getTime()) /(1000 * 3600) > 1){
throw new Exception("事件超过一小时,数据丢弃");
}
JSONObject data = (JSONObject)JSON.toJSON(event.get("data"));
String personNo = (String)data.get("ExtEventPersonNo");
//获取人员信息
String extEventInOut = String.valueOf(data.get("ExtEventInOut"));
ArtemisPerson artemisPerson = new ArtemisPerson();
artemisPerson.setPageNo(1);
artemisPerson.setPageSize(1000);
if(StringUtils.isNotEmpty(personNo)){
artemisPerson.setPersonIds(personNo);
}else {
String cardNo = (String)data.get("ExtEventCardNo");
if(StringUtils.isNotEmpty(cardNo)){
artemisPerson.setCardNo(cardNo);
}else {
throw new Exception("人员和卡信息不全!");
}
}
String personInfoStr = ArtemisUtils.personList(artemisPerson);
JSONObject personInfo = JSON.parseObject(personInfoStr);
if(!"0".equals(personInfo.get("code"))){
throw new Exception("人员信息接口信息获取错误");
}
JSONObject personData = (JSONObject)personInfo.get("data");
List<JSONObject> list = (List<JSONObject>)personData.get("list");
if(null == list || list.size() == 0){
throw new Exception("未获取到人员信息");
}
String personName = (String)list.get(0).get("personName");
TEntranceGuardPersonInfo tEntranceGuardPersonInfo = new TEntranceGuardPersonInfo();
tEntranceGuardPersonInfo.setPersonName(personName);
tEntranceGuardPersonInfo.setPersonNum((String)list.get(0).get("certificateNo"));
if("0".equals(extEventInOut) || "1".equals(extEventInOut)){
tEntranceGuardPersonInfo.setActionType("0".equals(extEventInOut) ? "1" : "0");
}
tEntranceGuardPersonInfo.setActionTime(happenTime);
tEntranceGuardPersonInfoService.insertTEntranceGuardPersonInfo(tEntranceGuardPersonInfo);
}
}
/**
* 设置订阅事件缓存
* @param deviceCode 设备编号
......
package com.zehong.web.uitls;
import com.alibaba.fastjson.JSONObject;
import com.hikvision.artemis.sdk.ArtemisHttpUtil;
import com.hikvision.artemis.sdk.config.ArtemisConfig;
import com.zehong.common.utils.StringUtils;
import com.zehong.system.domain.vo.ArtemisPerson;
import java.util.HashMap;
import java.util.Map;
/**
* 海康平台工具类
*/
public class ArtemisUtils {
/**
* 请根据自己的appKey和appSecret更换static静态块中的三个参数. [1 host]
* 如果你选择的是和现场环境对接,host要修改为现场环境的ip,https端口默认为443,http端口默认为80.例如10.33.25.22:443 或者10.33.25.22:80
* appKey和appSecret请按照或得到的appKey和appSecret更改.
*/
static {
// 代理API网关nginx服务器ip端口
ArtemisConfig.host = "27.128.189.137:1443";
// 秘钥appkey
ArtemisConfig.appKey = "28616162";
// 秘钥appSecret
ArtemisConfig.appSecret = "5ueTWDOJ21jRbpHACAzF";
}
/**
* 能力开放平台的网站路径
*/
private static final String ARTEMIS_PATH = "/artemis";
/**获取人员信息*/
private static final String PERSON_LIST = ARTEMIS_PATH + "/api/resource/v2/person/advance/personList";
public static String personList(ArtemisPerson artemisPerson){
Map<String, String> path = new HashMap<String, String>(2) {
{
//根据现场环境部署确认是http还是https
put("https://", PERSON_LIST);
}
};
JSONObject jsonBody = new JSONObject();
if(StringUtils.isNotEmpty(artemisPerson.getPersonIds())){
jsonBody.put("personIds", artemisPerson.getPersonIds());
}
if(StringUtils.isNotEmpty(artemisPerson.getPersonName())){
jsonBody.put("personName", artemisPerson.getPersonName());
}
if(StringUtils.isNotEmpty(artemisPerson.getOrgIndexCodes())){
jsonBody.put("orgIndexCodes", artemisPerson.getOrgIndexCodes());
}
if(StringUtils.isNotEmpty(artemisPerson.getCertificateNo())){
jsonBody.put("certificateNo", artemisPerson.getCertificateNo());
}
if(StringUtils.isNotEmpty(artemisPerson.getCardNo())){
jsonBody.put("cardNo", artemisPerson.getCardNo());
}
jsonBody.put("pageNo", artemisPerson.getPageNo());
jsonBody.put("pageSize", artemisPerson.getPageSize());
String body = jsonBody.toJSONString();
// post请求application/json类型参数
return ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json",null);
}
}
......@@ -21,7 +21,7 @@ spring:
druid:
# 主库数据源
master:
url: jdbc:mysql://36.138.181.113:33060/danger_manage_area_a?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
url: jdbc:mysql://36.138.181.113:33060/danger_manage_area_test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: zehong_/sjz!D
# 从库数据源
......@@ -75,11 +75,11 @@ spring:
# 地址
host: 127.0.0.1
# 端口,默认为6379
port: 6378
port: 6379
# 数据库索引
database: 1
# 密码
password: Redis@2021
password:
# 连接超时时间
timeout: 10s
lettuce:
......
......@@ -73,7 +73,7 @@ spring:
# redis 配置
redis:
# 地址
host: localhost
host: 127.0.0.1
# 端口,默认为6379
port: 6379
# 数据库索引
......
......@@ -21,7 +21,7 @@ spring:
druid:
# 主库数据源
master:
url: jdbc:mysql://36.138.181.113:3306/danger_manage_area_b?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
url: jdbc:mysql://36.138.181.113:3306/danger_manage_area_test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: root@123
# 从库数据源
......@@ -75,11 +75,11 @@ spring:
# 地址
host: 127.0.0.1
# 端口,默认为6379
port: 6378
port: 6379
# 数据库索引
database: 0
# 密码
password: Redis@2021
password:
# 连接超时时间
timeout: 10s
lettuce:
......
......@@ -36,13 +36,24 @@ public class TBankSubject extends BaseEntity
/** 答案 */
@Excel(name = "正确答案(必填)")
private int answer;
private String answer;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date datetime;
/** 题目类型 1单选 2多选 3判断 */
private Integer topicType;
public Integer getTopicType() {
return topicType;
}
public void setTopicType(Integer topicType) {
this.topicType = topicType;
}
public void setSubjectId(Long subjectId)
{
this.subjectId = subjectId;
......@@ -84,11 +95,11 @@ public class TBankSubject extends BaseEntity
return serialVersionUID;
}
public int getAnswer() {
public String getAnswer() {
return answer;
}
public void setAnswer(int answer) {
public void setAnswer(String answer) {
this.answer = answer;
}
......
......@@ -11,7 +11,7 @@ import com.zehong.common.core.domain.BaseEntity;
/**
* 培训课程对象 t_train_course
*
*
* @author zehong
* @date 2022-09-19
*/
......@@ -53,8 +53,8 @@ public class TTrainCourse extends BaseEntity
@Excel(name = "课程视频")
private String video;
/** 答题合格*/
@Excel(name = "答题合格数")
/** 答题合格分数*/
@Excel(name = "答题合格数")
private Integer qualifiedNum;
/** 录入题数量 */
......@@ -91,6 +91,43 @@ public class TTrainCourse extends BaseEntity
private Integer duration;
/** 多选题分数*/
private Integer multipleChoiceScore;
/**单选题分数*/
private Integer singleChoiceScore;
/**判断题分数*/
private Integer judgmentScore;
public static long getSerialVersionUID() {
return serialVersionUID;
}
public Integer getMultipleChoiceScore() {
return multipleChoiceScore;
}
public void setMultipleChoiceScore(Integer multipleChoiceScore) {
this.multipleChoiceScore = multipleChoiceScore;
}
public Integer getSingleChoiceScore() {
return singleChoiceScore;
}
public void setSingleChoiceScore(Integer singleChoiceScore) {
this.singleChoiceScore = singleChoiceScore;
}
public Integer getJudgmentScore() {
return judgmentScore;
}
public void setJudgmentScore(Integer judgmentScore) {
this.judgmentScore = judgmentScore;
}
public Integer getDuration() {
return duration;
}
......@@ -120,106 +157,106 @@ public class TTrainCourse extends BaseEntity
this.courseId = courseId;
}
public Long getCourseId()
public Long getCourseId()
{
return courseId;
}
public void setCourseName(String courseName)
public void setCourseName(String courseName)
{
this.courseName = courseName;
}
public String getCourseName()
public String getCourseName()
{
return courseName;
}
public void setCourseType(Long courseType)
public void setCourseType(Long courseType)
{
this.courseType = courseType;
}
public Long getCourseType()
public Long getCourseType()
{
return courseType;
}
public void setCourseConent(String courseConent)
public void setCourseConent(String courseConent)
{
this.courseConent = courseConent;
}
public String getCourseConent()
public String getCourseConent()
{
return courseConent;
}
public void setStatus(Integer status)
public void setStatus(Integer status)
{
this.status = status;
}
public Integer getStatus()
public Integer getStatus()
{
return status;
}
public void setReleaseTime(Date releaseTime)
public void setReleaseTime(Date releaseTime)
{
this.releaseTime = releaseTime;
}
public Date getReleaseTime()
public Date getReleaseTime()
{
return releaseTime;
}
public void setEnclosure(String enclosure)
public void setEnclosure(String enclosure)
{
this.enclosure = enclosure;
}
public String getEnclosure()
public String getEnclosure()
{
return enclosure;
}
public void setVideo(String video)
public void setVideo(String video)
{
this.video = video;
}
public String getVideo()
public String getVideo()
{
return video;
}
public void setQualifiedNum(Integer qualifiedNum)
public void setQualifiedNum(Integer qualifiedNum)
{
this.qualifiedNum = qualifiedNum;
}
public Integer getQualifiedNum()
public Integer getQualifiedNum()
{
return qualifiedNum;
}
public void setTopicNum(Integer topicNum)
public void setTopicNum(Integer topicNum)
{
this.topicNum = topicNum;
}
public Integer getTopicNum()
public Integer getTopicNum()
{
return topicNum;
}
public void setCreateUser(String createUser)
public void setCreateUser(String createUser)
{
this.createUser = createUser;
}
public String getCreateUser()
public String getCreateUser()
{
return createUser;
}
public void setIsDel(Integer isDel)
public void setIsDel(Integer isDel)
{
this.isDel = isDel;
}
public Integer getIsDel()
public Integer getIsDel()
{
return isDel;
}
......
......@@ -5,9 +5,11 @@ import com.zehong.common.core.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.util.List;
/**
* 培训课程题库对象 t_train_course_topic
*
*
* @author zehong
* @date 2022-09-19
*/
......@@ -31,55 +33,74 @@ public class TTrainCourseTopic extends BaseEntity
private String topicOption;
/** 答案 */
// @Excel(name = "答案")
// private Integer answer;
/** 答案 */
@Excel(name = "答案")
private Integer answer;
private String answer;
/** 题目类型 1单选 2多选 3判断 */
private Integer topicType;
public static long getSerialVersionUID() {
return serialVersionUID;
}
public Integer getTopicType() {
return topicType;
}
public void setTopicType(Integer topicType) {
this.topicType = topicType;
}
public void setTopicId(Long topicId)
public void setTopicId(Long topicId)
{
this.topicId = topicId;
}
public Long getTopicId()
public Long getTopicId()
{
return topicId;
}
public void setCourseId(Long courseId)
public void setCourseId(Long courseId)
{
this.courseId = courseId;
}
public Long getCourseId()
public Long getCourseId()
{
return courseId;
}
public void setTopicTitle(String topicTitle)
public void setTopicTitle(String topicTitle)
{
this.topicTitle = topicTitle;
}
public String getTopicTitle()
public String getTopicTitle()
{
return topicTitle;
}
public void setTopicOption(String topicOption)
public void setTopicOption(String topicOption)
{
this.topicOption = topicOption;
}
public String getTopicOption()
public String getTopicOption()
{
return topicOption;
}
public void setAnswer(Integer answer)
{
this.answer = answer;
}
public Integer getAnswer()
{
public String getAnswer() {
return answer;
}
public void setAnswer(String answer) {
this.answer = answer;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
......
package com.zehong.system.domain.vo;
import java.util.List;
public class ArtemisPerson {
/**
* 是否必须 False
* 人员ID集合
* 多个值使用英文逗号分隔,不超过1000个
* 获取人员列表v2 接口获取
*/
private String personIds;
/**
* 是否必须 False
* 人员姓名
* 支持中英文字符,不能包含 ’ / \ : * ? " < >
*/
private String personName;
/**
* 是否必须 False
* 性别
* 1:男
* 2:女
* 0:未知
*/
private String gender;
/**
* 是否必须 False
* 所属组织唯一标识码集合
* 多个值使用英文逗号分隔,不超过1000个
*/
private String orgIndexCodes;
/**
* 是否必须 False
* 证件类型
* 111:身份证
* 414:护照
* 113:户口簿
* 335:驾驶证
* 131:工作证
* 133:学生证
* 990:其他
* 平台上人员信息实名标识选择为身份证件时必填
*/
private String certificateType;
/**
* 是否必须 False
* 证件号码(最大长度64)
*/
private String certificateNo;
/**
* 是否必须 True
* 当前页码需大于0(pageNo>0)
*/
private int pageNo;
/**
* 是否必须 True
* 每页记录展示的数目应大于0,小于等于1000(0<pageSize<=1000)
*/
private int pageSize;
/**
* 是否必须 False
* 是否包含下级组织,true时,搜索orgIndexCodes及其所有子孙组织的人员;
* false时,只搜索orgIndexCodes的人员
*/
private String isSubOrg;
/**
* 是否必须 False
* 卡号, 获取卡片列表接口可以获取
*/
private String cardNo;
/**
* 是否必须 False
* 车牌号
*/
private String plateNo;
/**
* 是否必须 False
* 排序字段,注意:排序字段必须是查询条件,否则返回参数错误
*/
private String orderBy;
/**
* 是否必须 False
* 降序:desc
* 升序:asc
*/
private String orderType;
/**
* 是否必须 False
* 查询表达式
*/
private List<ArtemisPersonExpressions> expressions;
public String getPersonIds() {
return personIds;
}
public void setPersonIds(String personIds) {
this.personIds = personIds;
}
public String getPersonName() {
return personName;
}
public void setPersonName(String personName) {
this.personName = personName;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public String getOrgIndexCodes() {
return orgIndexCodes;
}
public void setOrgIndexCodes(String orgIndexCodes) {
this.orgIndexCodes = orgIndexCodes;
}
public String getCertificateType() {
return certificateType;
}
public void setCertificateType(String certificateType) {
this.certificateType = certificateType;
}
public String getCertificateNo() {
return certificateNo;
}
public void setCertificateNo(String certificateNo) {
this.certificateNo = certificateNo;
}
public int getPageNo() {
return pageNo;
}
public void setPageNo(int pageNo) {
this.pageNo = pageNo;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public String getIsSubOrg() {
return isSubOrg;
}
public void setIsSubOrg(String isSubOrg) {
this.isSubOrg = isSubOrg;
}
public String getCardNo() {
return cardNo;
}
public void setCardNo(String cardNo) {
this.cardNo = cardNo;
}
public String getPlateNo() {
return plateNo;
}
public void setPlateNo(String plateNo) {
this.plateNo = plateNo;
}
public String getOrderBy() {
return orderBy;
}
public void setOrderBy(String orderBy) {
this.orderBy = orderBy;
}
public String getOrderType() {
return orderType;
}
public void setOrderType(String orderType) {
this.orderType = orderType;
}
public List<ArtemisPersonExpressions> getExpressions() {
return expressions;
}
public void setExpressions(List<ArtemisPersonExpressions> expressions) {
this.expressions = expressions;
}
}
package com.zehong.system.domain.vo;
public class ArtemisPersonExpressions {
/**
* 是否必须 True
* 资源属性名,支持按jobNo、phoneNo、email、updateTim、cerateTime查询,例如:key传updateTime,operator传between可以查询特定时间段更新的数据,考虑到校时和夏令时,建议值查询过去一天的数据变更
*/
private String key;
/**
* 是否必须 True
* 操作运算符,
* 0 :=
* 1 :>=
* 2 :<=
* 3 :in
* 4 :not in
* 5 :between
* 6 :like
* 7 :pre like
* 8 :suffix like
*/
private int operator;
/**
* 是否必须 True
* 资源属性值,=、>=、<=、like、values数组长度只能是1;
* in、not in,values数组长度大于1,最大不超时20;
* in_array用于查询key值有多个value的情况,例如行车监控添加的设备类型为encodeDevice、encodeDeviceMss两个类型,使用encodeDevice或者encodeDeviceMss都可以查询到;between只能用于整形、日期(ISO8601格式)
* ;like只能用于字符串。
*/
private String[] values;
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public int getOperator() {
return operator;
}
public void setOperator(int operator) {
this.operator = operator;
}
public String[] getValues() {
return values;
}
public void setValues(String[] values) {
this.values = values;
}
}
......@@ -42,4 +42,16 @@ public class UserCourseVo {
private Integer trainState;
/**总分*/
private Integer totalScore;
/**多选题分数*/
private Integer multipleChoiceScore;
/**判断题分数*/
private Integer judgmentScore;
/**单选题分数*/
private Integer singleChoiceScore;
}
......@@ -10,15 +10,15 @@ import com.zehong.system.domain.vo.UserCourseVo;
/**
* 培训课程Service接口
*
*
* @author zehong
* @date 2022-09-19
*/
public interface ITTrainCourseService
public interface ITTrainCourseService
{
/**
* 查询培训课程
*
*
* @param courseId 培训课程ID
* @return 培训课程
*/
......@@ -33,7 +33,7 @@ public interface ITTrainCourseService
/**
* 查询培训课程列表
*
*
* @param tTrainCourse 培训课程
* @return 培训课程集合
*/
......@@ -41,7 +41,7 @@ public interface ITTrainCourseService
/**
* 新增培训课程
*
*
* @param tTrainCourse 培训课程
* @return 结果
*/
......@@ -49,7 +49,7 @@ public interface ITTrainCourseService
/**
* 修改培训课程
*
*
* @param tTrainCourse 培训课程
* @return 结果
*/
......@@ -58,7 +58,7 @@ public interface ITTrainCourseService
/**
* 批量删除培训课程
*
*
* @param courseIds 需要删除的培训课程ID
* @return 结果
*/
......@@ -66,7 +66,7 @@ public interface ITTrainCourseService
/**
* 删除培训课程信息
*
*
* @param courseId 培训课程ID
* @return 结果
*/
......@@ -85,7 +85,7 @@ public interface ITTrainCourseService
/**
* 考试
*/
public Map<String,Object> examination(Long userCourseId,String[] answers);
public Map<String,Object> examination(Long userCourseId,Integer[][] answers);
/**
* 考试发布
......
......@@ -7,15 +7,15 @@ import java.util.List;
/**
* 培训课程题库Service接口
*
*
* @author zehong
* @date 2022-09-19
*/
public interface ITTrainCourseTopicService
public interface ITTrainCourseTopicService
{
/**
* 查询培训课程题库
*
*
* @param topicId 培训课程题库ID
* @return 培训课程题库
*/
......@@ -23,7 +23,7 @@ public interface ITTrainCourseTopicService
/**
* 查询培训课程题库列表
*
*
* @param tTrainCourseTopic 培训课程题库
* @return 培训课程题库集合
*/
......@@ -32,7 +32,7 @@ public interface ITTrainCourseTopicService
/**
* 新增培训课程题库
*
*
* @param tTrainCourseTopic 培训课程题库
* @return 结果
*/
......@@ -40,7 +40,7 @@ public interface ITTrainCourseTopicService
/**
* 修改培训课程题库
*
*
* @param tTrainCourseTopic 培训课程题库
* @return 结果
*/
......@@ -48,7 +48,7 @@ public interface ITTrainCourseTopicService
/**
* 批量删除培训课程题库
*
*
* @param topicIds 需要删除的培训课程题库ID
* @return 结果
*/
......@@ -56,7 +56,7 @@ public interface ITTrainCourseTopicService
/**
* 删除培训课程题库信息
*
*
* @param topicId 培训课程题库ID
* @return 结果
*/
......@@ -68,4 +68,11 @@ public interface ITTrainCourseTopicService
* @return int
*/
int bachAddTopic(BatchTopicVo batchTopicVo);
/**
* 培训课程管理批量导入试题
* @param batchTopicVo
* @return
*/
int addTTrainCourseTopic(BatchTopicVo batchTopicVo);
}
package com.zehong.system.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.zehong.common.utils.DateUtils;
import com.zehong.common.utils.StringUtils;
import com.zehong.system.domain.StatisticsTrainCourse;
import com.zehong.system.domain.TTrainCourse;
import com.zehong.system.domain.TTrainCourseTopic;
......@@ -19,16 +21,18 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
/**
* 培训课程Service业务层处理
*
*
* @author zehong
* @date 2022-09-19
*/
@Service
public class TTrainCourseServiceImpl implements ITTrainCourseService
public class TTrainCourseServiceImpl implements ITTrainCourseService
{
@Autowired
private TTrainCourseMapper tTrainCourseMapper;
......@@ -41,7 +45,7 @@ public class TTrainCourseServiceImpl implements ITTrainCourseService
/**
* 查询培训课程
*
*
* @param courseId 培训课程ID
* @return 培训课程
*/
......@@ -70,7 +74,7 @@ public class TTrainCourseServiceImpl implements ITTrainCourseService
}
/**
* 查询培训课程列表
*
*
* @param tTrainCourse 培训课程
* @return 培训课程
*/
......@@ -82,7 +86,7 @@ public class TTrainCourseServiceImpl implements ITTrainCourseService
/**
* 新增培训课程
*
*
* @param tTrainCourse 培训课程
* @return 结果
*/
......@@ -105,7 +109,7 @@ public class TTrainCourseServiceImpl implements ITTrainCourseService
/**
* 修改培训课程
*
*
* @param tTrainCourse 培训课程
* @return 结果
*/
......@@ -126,7 +130,7 @@ public class TTrainCourseServiceImpl implements ITTrainCourseService
/**
* 批量删除培训课程
*
*
* @param courseIds 需要删除的培训课程ID
* @return 结果
*/
......@@ -138,7 +142,7 @@ public class TTrainCourseServiceImpl implements ITTrainCourseService
/**
* 删除培训课程信息
*
*
* @param courseId 培训课程ID
* @return 结果
*/
......@@ -163,6 +167,23 @@ public class TTrainCourseServiceImpl implements ITTrainCourseService
v.setState(4);
}
}
for (int i=0;i<list.size();i++){
int totalScore=0;
Long courseId = list.get(i).getCourseId();
//查询课程下面的题
List<TTrainCourseTopic> tTrainCourseTopics = tTrainCourseTopicMapper.selectCourseTopicList(courseId);
for (int t=0;t<tTrainCourseTopics.size();t++){
if (tTrainCourseTopics.get(t).getTopicType()==1){
totalScore=totalScore+list.get(i).getSingleChoiceScore();
}else if (tTrainCourseTopics.get(t).getTopicType()==2){
totalScore=totalScore+list.get(i).getMultipleChoiceScore();
}else if (tTrainCourseTopics.get(t).getTopicType()==3){
totalScore=totalScore+list.get(i).getJudgmentScore();
}
}
list.get(i).setTotalScore(totalScore);
}
return list;
}
......@@ -183,30 +204,96 @@ public class TTrainCourseServiceImpl implements ITTrainCourseService
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Map<String,Object> examination (Long userCourseId,String[] answers){
public Map<String,Object> examination (Long userCourseId,Integer[][] answers){
//查询用户课程信息
TTrainUserCourse userCourse = tTrainUserCourseMapper.selectTTrainUserCourseById(userCourseId);
TTrainCourseTopic topic = new TTrainCourseTopic();
/**添加所属课程id*/
topic.setCourseId(userCourse.getCourseId());
/**查询培训课程题库列表*/
List<TTrainCourseTopic> list = tTrainCourseTopicMapper.selectTTrainCourseTopicList(topic);
/**查询培训课程*/
TTrainCourse c = tTrainCourseMapper.selectTTrainCourseById(userCourse.getCourseId());
/**获取各个题目类型多少分*/
//多选题分数
Integer multipleChoiceScore = c.getMultipleChoiceScore();
//单选题分数
Integer singleChoiceScore = c.getSingleChoiceScore();
//判断题分数
Integer judgmentScore = c.getJudgmentScore();
//答题合格分数
Integer qualifiedNum = c.getQualifiedNum();
//已获得分数
int num = 0;
for(Integer i=0;i<answers.length;i++){
if(Integer.parseInt(answers[i])==list.get(i).getAnswer()){
num++;
/**
* 大循环 共有多少答案 此循环最后只算出 得了多少分
*/
for (int i=0;i<answers.length;i++){
/**答题是否正确 0 不正确 1正确*/
int PassedNot =0;
/*题目答案*/
String answer = list.get(i).getAnswer();
System.out.println("答案:"+answer);
//答案转换成数组
Integer[] integers = JSON.parseObject(answer, Integer[].class);
/**判断所选答案是否与正确答案长度相等*/
if (integers.length==answers[i].length){
boolean adopt=true;
for (int n=0;n<integers.length;n++){
if (integers[n]!=answers[i][n]){
adopt=false;
break;
}
}
if (adopt){
/** 1单选 2多选 3判断*/
if (list.get(i).getTopicType()==1){
System.out.println(num);
num=num+singleChoiceScore;
}else if (list.get(i).getTopicType()==2){
System.out.println(num);
num=num+multipleChoiceScore;
}else if (list.get(i).getTopicType()==3){
System.out.println(num);
num=num+judgmentScore;
}
}
}
/**
* 小循环 循环出每次的答案
*/
// for (int s=0;s<answers[i].length;s++){
// System.out.println("所选答案"+answers[i][s]);
// }
}
for(Integer i=0;i<answers.length;i++){
// String demosub = list.get(i).getAnswer().substring(1,list.get(i).getAnswer().length()-1);
// if(Integer.parseInt(answers[i])==demosub){
// num++;
// }
}
/**已获得分数*/
userCourse.setExaminationResult(num);
/**生成日期*/
userCourse.setExaminationTime(new Date());
TTrainCourse c = tTrainCourseMapper.selectTTrainCourseById(userCourse.getCourseId());
if(num>=c.getQualifiedNum()){
/**判断已获得分数 是否通过 1未通过 2已通过*/
if(num>=qualifiedNum){
userCourse.setState(2);
}else {
userCourse.setState(1);
}
tTrainUserCourseMapper.updateTTrainUserCourse(userCourse);
Map<String,Object> map = new HashMap<>();
map.put("answer",num);
map.put("qualifiedNum",c.getQualifiedNum());
map.put("topicNum",list.size());
map.put("answer",num); //得分分数
map.put("qualifiedNum",c.getQualifiedNum()); //答题合格分数
map.put("topicNum",list.size()); //题目数据
return map;
}
......
......@@ -23,12 +23,12 @@ import java.util.List;
/**
* 培训课程题库Service业务层处理
*
*
* @author zehong
* @date 2022-09-19
*/
@Service
public class TTrainCourseTopicServiceImpl implements ITTrainCourseTopicService
public class TTrainCourseTopicServiceImpl implements ITTrainCourseTopicService
{
@Autowired
private TTrainCourseTopicMapper tTrainCourseTopicMapper;
......@@ -39,7 +39,7 @@ public class TTrainCourseTopicServiceImpl implements ITTrainCourseTopicService
/**
* 查询培训课程题库
*
*
* @param topicId 培训课程题库ID
* @return 培训课程题库
*/
......@@ -51,7 +51,7 @@ public class TTrainCourseTopicServiceImpl implements ITTrainCourseTopicService
/**
* 查询培训课程题库列表
*
*
* @param tTrainCourseTopic 培训课程题库
* @return 培训课程题库
*/
......@@ -68,7 +68,7 @@ public class TTrainCourseTopicServiceImpl implements ITTrainCourseTopicService
/**
* 新增培训课程题库
*
*
* @param tTrainCourseTopic 培训课程题库
* @return 结果
*/
......@@ -87,7 +87,7 @@ public class TTrainCourseTopicServiceImpl implements ITTrainCourseTopicService
/**
* 修改培训课程题库
*
*
* @param tTrainCourseTopic 培训课程题库
* @return 结果
*/
......@@ -99,7 +99,7 @@ public class TTrainCourseTopicServiceImpl implements ITTrainCourseTopicService
/**
* 批量删除培训课程题库
*
*
* @param topicIds 需要删除的培训课程题库ID
* @return 结果
*/
......@@ -111,7 +111,7 @@ public class TTrainCourseTopicServiceImpl implements ITTrainCourseTopicService
/**
* 删除培训课程题库信息
*
*
* @param topicId 培训课程题库ID
* @return 结果
*/
......@@ -156,7 +156,45 @@ public class TTrainCourseTopicServiceImpl implements ITTrainCourseTopicService
courseTopic.setCourseId(batchTopicVo.getCourseId());
courseTopic.setTopicTitle(bankSubjects.get(i).getTopicTitle());
courseTopic.setTopicOption(bankSubjects.get(i).getTopicOption());
courseTopic.setAnswer(bankSubjects.get(i).getAnswer());
courseTopic.setAnswer(String.valueOf(bankSubjects.get(i).getAnswer()));
courseTopic.setCreateTime(new Date());
topics.add(courseTopic);
}
count += topic.getQuan();
}
//批量新增试题
tTrainCourseTopicMapper.batchInsertTTrainCourseTopic(topics);
//更新试题数量
TTrainCourse course = tTrainCourseMapper.selectTTrainCourseById(batchTopicVo.getCourseId());
course.setTopicNum(course.getTopicNum() + count);
return tTrainCourseMapper.updateTTrainCourse(course);
}
/**
* 培训课程管理批量导入试题
* @param batchTopicVo
* @return
*/
@Override
public int addTTrainCourseTopic(BatchTopicVo batchTopicVo) {
if(CollectionUtil.isEmpty(batchTopicVo.getTopicInfos()) || StringUtils.isEmpty(String.valueOf(batchTopicVo.getCourseId()))){
return 0;
}
List<TTrainCourseTopic> topics = new ArrayList<>();
int count = 0;
for(BatchTopicVo.TopicInfos topic : batchTopicVo.getTopicInfos()){
//获取题库试题
TBankSubject tBankSubject = new TBankSubject();
tBankSubject.setBankId(topic.getBankId());
List<TBankSubject> bankSubjects = tBankSubjectMapper.selectTBankSubjectList(tBankSubject);
//获取随机试题
Collections.shuffle(bankSubjects);
for(int i = 0;i<topic.getQuan();i++){
TTrainCourseTopic courseTopic = new TTrainCourseTopic();
courseTopic.setCourseId(batchTopicVo.getCourseId());
courseTopic.setTopicTitle(bankSubjects.get(i).getTopicTitle());
courseTopic.setTopicOption(bankSubjects.get(i).getTopicOption());
courseTopic.setAnswer(String.valueOf(bankSubjects.get(i).getAnswer()));
courseTopic.setCreateTime(new Date());
topics.add(courseTopic);
}
......
......@@ -11,10 +11,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="topicOption" column="topic_option" />
<result property="answer" column="answer" />
<result property="datetime" column="datetime" />
<result property="topicType" column="topic_type" />
</resultMap>
<sql id="selectTBankSubjectVo">
select subject_id, bank_id, topic_title, topic_option, answer, datetime from t_bank_subject
select subject_id, bank_id, topic_title, topic_option, answer, datetime ,topic_type from t_bank_subject
</sql>
<select id="selectTBankSubjectList" parameterType="TBankSubject" resultMap="TBankSubjectResult">
......@@ -41,6 +42,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="topicOption != null">topic_option,</if>
<if test="answer != null">answer,</if>
<if test="datetime != null">datetime,</if>
<if test="topicType != null">topic_type,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="bankId != null">#{bankId},</if>
......@@ -48,6 +50,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="topicOption != null">#{topicOption},</if>
<if test="answer != null">#{answer},</if>
<if test="datetime != null">#{datetime},</if>
<if test="topicType != null">#{topicType},</if>
</trim>
</insert>
......@@ -59,6 +62,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="topicOption != null">topic_option = #{topicOption},</if>
<if test="answer != null">answer = #{answer},</if>
<if test="datetime != null">datetime = #{datetime},</if>
<if test="topicType != null">topic_type = #{topicType},</if>
</trim>
where subject_id = #{subjectId}
</update>
......
......@@ -111,43 +111,42 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="statisticsStayInPersons" resultType="java.lang.String">
SELECT
COUNT(*)
COUNT(import.person_num)
FROM
(
(
(
SELECT
*
*
FROM
(
SELECT
action_time AS importTime,
person_num
FROM
t_entrance_guard_person_info
SELECT
action_time AS importTime,
person_num
FROM
t_entrance_guard_person_info
WHERE
action_type = '0'
ORDER BY action_time DESC
)a
GROUP BY a.person_num
)import,
action_type = '0'
ORDER BY action_time DESC LIMIT 10000
)a
GROUP BY a.person_num
)import
LEFT JOIN
(
SELECT
*
FROM
(
SELECT
*
SELECT
action_time AS exportTime,
person_num
FROM
(
SELECT
action_time AS exportTime,
person_num
FROM
t_entrance_guard_person_info
WHERE
action_type = '1'
ORDER BY action_time DESC
)b
GROUP BY b.person_num
)export
)
WHERE import.person_num = export.person_num AND (export.exportTime - import.importTime) > 0
t_entrance_guard_person_info
WHERE
action_type = '1'
ORDER BY action_time DESC LIMIT 10000
)b
GROUP BY b.person_num
)export ON import.person_num = export.person_num
WHERE (unix_timestamp(import.importTime) - IFNULL(unix_timestamp(export.exportTime),0)) > 0
</select>
<select id="lastImportAndExportData" resultMap="TEntranceGuardPersonInfoResult">
......@@ -158,7 +157,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
*
FROM
t_entrance_guard_person_info
ORDER BY action_time DESC
ORDER BY action_time DESC LIMIT 10000
)present
GROUP BY
present.action_type
......
......@@ -3,7 +3,7 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zehong.system.mapper.TTrainCourseMapper">
<resultMap type="TTrainCourse" id="TTrainCourseResult">
<result property="courseId" column="course_id" />
<result property="courseName" column="course_name" />
......@@ -25,6 +25,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="testEndTime" column="test_end_time" />
<result property="testPersons" column="test_persons" />
<result property="duration" column="duration" />
<result property="multipleChoiceScore" column="multiple_choice_score" />
<result property="singleChoiceScore" column="single_choice_score" />
<result property="judgmentScore" column="judgment_score" />
</resultMap>
<resultMap id="StatisticsTrainCourseResult" type="StatisticsTrainCourse">
......@@ -39,14 +42,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectTTrainCourseVo">
select course_id, course_name, course_type, course_conent, status,personnel_type, release_time, enclosure, video, qualified_num, topic_num, create_time, create_user, is_del, data_kind, test_start_time, test_end_time, test_persons,duration from t_train_course
select multiple_choice_score,single_choice_score,judgment_score,course_id, course_name, course_type, course_conent, status,personnel_type, release_time, enclosure, video, qualified_num, topic_num, create_time, create_user, is_del, data_kind, test_start_time, test_end_time, test_persons,duration from t_train_course
</sql>
<select id="selectTTrainCourseList" parameterType="TTrainCourse" resultMap="TTrainCourseResult">
select c.*,p.plan_name from t_train_course c
LEFT JOIN t_train_plan p on p.plan_id = c.course_type
<where>
<where>
<if test="courseName != null and courseName != ''"> and c.course_name like concat('%', #{courseName}, '%')</if>
<if test="courseType != null "> and c.course_type = #{courseType}</if>
<if test="courseConent != null and courseConent != ''"> and c.course_conent = #{courseConent}</if>
......@@ -58,12 +61,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createUser != null and createUser != ''"> and c.create_user = #{createUser}</if>
<if test="isDel != null "> and c.is_del = #{isDel}</if>
<if test="dataKind != null and dataKind != ''"> and data_kind = #{dataKind}</if>
<if test="dataKind == null and dataKind != ''"> and data_kind != '1'</if>
<if test="testStartTime != null "> and test_start_time = #{testStartTime}</if>
<if test="testEndTime != null "> and test_end_time = #{testEndTime}</if>
<if test="testPersons != null and testPersons != ''"> and test_persons = #{testPersons}</if>
</where>
</select>
<select id="selectTTrainCourseById" parameterType="Long" resultMap="TTrainCourseResult">
<include refid="selectTTrainCourseVo"/>
where course_id = #{courseId}
......@@ -90,7 +94,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="testEndTime != null">test_end_time,</if>
<if test="testPersons != null">test_persons,</if>
<if test="duration != null">duration,</if>
<if test="multipleChoiceScore != null">multiple_choice_score,</if>
<if test="singleChoiceScore != null">single_choice_score,</if>
<if test="judgmentScore != null">judgment_score,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="courseName != null">#{courseName},</if>
......@@ -111,7 +117,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="testEndTime != null">#{testEndTime},</if>
<if test="testPersons != null">#{testPersons},</if>
<if test="duration != null">#{duration},</if>
<if test="multipleChoiceScore != null">#{multipleChoiceScore},</if>
<if test="singleChoiceScore != null">#{singleChoiceScore},</if>
<if test="judgmentScore != null">#{judgmentScore},</if>
</trim>
</insert>
......@@ -136,6 +144,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="testEndTime != null">test_end_time = #{testEndTime},</if>
<if test="testPersons != null">test_persons = #{testPersons},</if>
<if test="duration != null">duration = #{duration},</if>
<if test="multipleChoiceScore != null">multiple_choice_score = #{multipleChoiceScore},</if>
<if test="singleChoiceScore != null">single_choice_score = #{singleChoiceScore},</if>
<if test="judgmentScore != null">judgment_score = #{judgmentScore},</if>
</trim>
where course_id = #{courseId}
</update>
......@@ -145,7 +156,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<delete id="deleteTTrainCourseByIds" parameterType="String">
delete from t_train_course where course_id in
delete from t_train_course where course_id in
<foreach item="courseId" collection="array" open="(" separator="," close=")">
#{courseId}
</foreach>
......@@ -160,7 +171,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
SELECT uc.user_course_id AS userCourseId,uc.state ,uc.examination_time AS examinationTime,uc.train_state AS trainState,
uc.`examination_result` AS examinationResult,uc.`create_time` AS createTime,c.test_start_time as testStartTime,c.test_end_time as testEndTime,
c.`course_name` AS courseName, c.`topic_num` AS topicNum,c.`release_time` AS releaseTime,c.data_kind as dataKind,c.personnel_type as personnelType,
p.`plan_name` AS courseType,c.course_id as courseId,c.qualified_num as qualifiedNum
p.`plan_name` AS courseType,c.course_id as courseId,c.qualified_num as qualifiedNum,c.multiple_choice_score as multipleChoiceScore,
c.judgment_score as judgmentScore,c.single_choice_score as singleChoiceScore
FROM t_train_user_course uc
LEFT JOIN t_train_course c ON c.`course_id` = uc.`course_id`
LEFT JOIN t_train_plan p ON p.`plan_id` = c.`course_type`
......@@ -198,4 +210,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
GROUP BY course.course_id
</select>
</mapper>
\ No newline at end of file
</mapper>
......@@ -3,7 +3,7 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zehong.system.mapper.TTrainCourseTopicMapper">
<resultMap type="TTrainCourseTopic" id="TTrainCourseTopicResult">
<result property="topicId" column="topic_id" />
<result property="courseId" column="course_id" />
......@@ -11,15 +11,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="topicOption" column="topic_option" />
<result property="answer" column="answer" />
<result property="createTime" column="create_time" />
<result property="topicType" column="topic_type" />
</resultMap>
<sql id="selectTTrainCourseTopicVo">
select topic_id, course_id, topic_title, topic_option, answer, create_time from t_train_course_topic
select topic_id, course_id, topic_title, topic_option, answer, create_time,topic_type from t_train_course_topic
</sql>
<select id="selectTTrainCourseTopicList" parameterType="TTrainCourseTopic" resultMap="TTrainCourseTopicResult">
<include refid="selectTTrainCourseTopicVo"/>
<where>
<where>
<if test="courseId != null "> and course_id = #{courseId}</if>
<if test="topicTitle != null and topicTitle != ''"> and topic_title = #{topicTitle}</if>
<if test="topicOption != null and topicOption != ''"> and topic_option = #{topicOption}</if>
......@@ -27,14 +28,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
</select>
<select id="selectCourseTopicList" resultMap="TTrainCourseTopicResult">
select topic_id, course_id, topic_title, topic_option, answer, create_time from t_train_course_topic
select topic_id, course_id, topic_title, topic_option, answer, create_time,topic_type from t_train_course_topic
WHERE course_id = #{courseId}
</select>
<select id="selectTTrainCourseTopicById" parameterType="Long" resultMap="TTrainCourseTopicResult">
<include refid="selectTTrainCourseTopicVo"/>
where topic_id = #{topicId}
</select>
<insert id="insertTTrainCourseTopic" parameterType="TTrainCourseTopic">
insert into t_train_course_topic
<trim prefix="(" suffix=")" suffixOverrides=",">
......@@ -44,6 +45,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="topicOption != null">topic_option,</if>
<if test="answer != null">answer,</if>
<if test="createTime != null">create_time,</if>
<if test="topicType != null">topic_type</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="topicId != null">#{topicId},</if>
......@@ -52,6 +54,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="topicOption != null">#{topicOption},</if>
<if test="answer != null">#{answer},</if>
<if test="createTime != null">#{createTime},</if>
<if test="topicType != null">#{topicType},</if>
</trim>
</insert>
......@@ -63,6 +66,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="topicOption != null">topic_option = #{topicOption},</if>
<if test="answer != null">answer = #{answer},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="topicType != null">topic_type= #{topicType}</if>
</trim>
where topic_id = #{topicId}
</update>
......@@ -72,7 +76,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<delete id="deleteTTrainCourseTopicByIds" parameterType="String">
delete from t_train_course_topic where topic_id in
delete from t_train_course_topic where topic_id in
<foreach item="topicId" collection="array" open="(" separator="," close=")">
#{topicId}
</foreach>
......@@ -84,4 +88,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
(#{topic.courseId},#{topic.topicTitle},#{topic.topicOption},#{topic.answer},#{topic.createTime})
</foreach>
</insert>
</mapper>
\ No newline at end of file
</mapper>
......@@ -46,6 +46,7 @@
"js-cookie": "2.2.1",
"jsencrypt": "3.0.0-rc.1",
"nprogress": "0.2.0",
"qrcodejs2": "^0.0.2",
"quill": "1.3.7",
"screenfull": "5.0.2",
"sortablejs": "1.10.2",
......@@ -54,6 +55,7 @@
"vue-cropper": "0.5.5",
"vue-esign": "^1.1.4",
"vue-print-nb": "^1.7.5",
"vue-qr": "^4.0.9",
"vue-router": "3.4.9",
"vue-video-player": "5.0.2",
"vuedraggable": "2.24.3",
......
import request from '@/utils/request'
......@@ -2,7 +2,7 @@
* @Author: 纪泽龙 jizelong@qq.com
* @Date: 2022-12-19 17:39:55
* @LastEditors: 纪泽龙 jizelong@qq.com
* @LastEditTime: 2022-12-26 09:36:52
* @LastEditTime: 2023-01-13 15:37:54
* @FilePath: /danger-manage-web/src/views/educationPlanExam/textPaper/components/ChangePapel.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
......@@ -248,7 +248,7 @@ export default {
padding-left: 11px;
overflow-y: scroll;
&::-webkit-scrollbar {
display: none; /* Chrome Safari */
// display: none; /* Chrome Safari */
}
.item {
width: 70px;
......
......@@ -5,6 +5,18 @@
目前录入题目是第<span>{{ questionNextNum }}</span
>道题
</div>
<div>
<el-radio-group
v-model="form.topicType"
size="mini"
@input="topicTypeChange"
>
<el-radio-button :label="1">单选</el-radio-button>
<el-radio-button :label="2">多选</el-radio-button>
<el-radio-button :label="3">判断</el-radio-button>
</el-radio-group>
</div>
<div class="right">{{ courseName }}</div>
</div>
......@@ -40,15 +52,11 @@
:label="'选项' + (index + 1)"
:key="question.key"
:prop="'questions.' + index + '.value'"
:rules="
index === 0
? {
required: true,
message: '第一项不能为空不能为空',
trigger: 'blur',
}
: {}
"
:rules="{
required: true,
message: '选项内容不能为空不能为空',
trigger: 'change',
}"
>
<div class="add-select flex">
<el-input
......@@ -62,7 +70,9 @@
<div
@click="rightAnswerClick(index)"
class="right"
:class="{ active: answerNum === index }"
:class="{
active: answerNum.indexOf(index) >= 0,
}"
>
设为正确答案
</div>
......@@ -100,7 +110,7 @@
>
设为正确答案
</div> -->
<div style="padding-left:30px">
<div style="padding-left: 30px" v-if="form.topicType != 3">
<el-button size="mini" type="primary" @click.prevent="add(addValue)"
>新增选项</el-button
>
......@@ -140,11 +150,13 @@ export default {
components: {},
data() {
return {
// topicType:1,
form: {
topicType: 1,
topicTitle: "",
questions: [{ value: "" }, { value: "" }],
},
answerNum: null,
answerNum: [],
addValue: "",
// 录入的是第几道题
questionNextNum: 1,
......@@ -159,10 +171,11 @@ export default {
console.log(res.data);
const data = res.data;
this.form = {
topicType :data.topicType,
topicTitle: data.topicTitle,
questions: JSON.parse(data.topicOption),
};
this.answerNum = data.answer;
this.answerNum = JSON.parse(data.answer);
});
}
......@@ -172,6 +185,23 @@ export default {
this.getLessonById(this.courseId);
},
methods: {
// 题目类型变化
topicTypeChange(num) {
if (num == 1) {
this.answerNum = [];
} else if (num == 2) {
this.answerNum = [];
// this.form.questions=[{ value: "" }, { value: "" }];
} else {
this.answerNum = [];
const form = {
topicType: 3,
topicTitle: this.form.topicTitle,
questions: [{ value: "对" }, { value: "错" }],
};
this.form = form;
}
},
getQuestion() {
getQuestion({ courseId: this.courseId }).then((res) => {
// 如果是修改 就是原来的值,如果不是,就是总数+1
......@@ -202,19 +232,46 @@ export default {
}
},
rightAnswerClick(index) {
this.answerNum = index;
console.log(index);
if (this.form.topicType === 2) {
const ind = this.answerNum.indexOf(index);
if (ind < 0) {
this.answerNum.push(index);
} else {
this.answerNum.splice(ind, 1);
}
this.answerNum = this.answerNum.sort((a, b) => {
return a - b;
});
console.log(this.answerNum);
} else {
// 判断跟单选模式差不多
this.answerNum = [index];
}
},
// 删除选项
removeDomain(question) {
const index = this.form.questions.indexOf(question);
console.log(index);
// 如果是正确答案,就让正确答案清空
if (this.answerNum === index) {
this.answerNum = null;
const ind = this.answerNum.indexOf(index);
if (ind >= 0) {
this.answerNum.splice(ind, 1);
}
// 如果是最后一位呗删除,那不用管,如果不是最后一位置,这一位删除之后,则这一位后面的所有数字都要-1;
if (index != this.form.questions.length - 1) {
this.answerNum = this.answerNum.map((item, i) => {
if (item >= index) {
return item - 1;
} else {
return item;
}
});
}
if (index >= 0) {
this.form.questions.splice(index, 1);
}
console.log(this.answerNum);
// console.log(this.form.questions)
},
// 新增选项
add(addValue) {
......@@ -223,7 +280,7 @@ export default {
},
save(num = 2) {
return new Promise((resove) => {
if (!this.answerNum && this.answerNum !== 0) {
if (this.answerNum.length<=0) {
this.$message({
message: "警告,请设置一个正确答案",
type: "warning",
......@@ -235,11 +292,14 @@ export default {
const data = {};
data.topicTitle = this.form.topicTitle;
data.topicOption = JSON.stringify(this.form.questions);
data.answer = this.answerNum;
data.answer = JSON.stringify(this.answerNum);
data.topicType=this.form.topicType;
console.log(data)
this.addQuestion(data).then((res) => {
if (res.code == 200) {
// 把修改的这个归位,变成正常添加
this.$emit("update:topicId", null);
console.log("updateTopicId", this.topicId);
this.$message({
message: "添加题目成功",
type: "success",
......@@ -264,11 +324,13 @@ export default {
});
},
reset() {
const topicType = this.form.topicType
this.form = {
topicType,
topicTitle: "",
questions: [{ value: "" }, { value: "" }, { value: "" }],
questions: [{ value: "" }, { value: "" }],
};
this.answerNum = null;
this.answerNum = [];
this.addValue = "";
},
},
......
<!--
* @Author: 纪泽龙 jizelong@qq.com
* @Date: 2022-12-27 09:30:19
* @LastEditors: 纪泽龙 jizelong@qq.com
* @LastEditTime: 2022-12-28 10:29:18
* @FilePath: /danger-manage-web/src/views/educationPlanExam/textPaper/components/ChangeQuestion.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
<div class="table-wrapper">
<el-form :model="queryParams" ref="queryForm" :inline="true">
<el-form-item label="所属单位" prop="deptId" ref="treeItem">
<Treeselect
class="tree"
v-model="queryParams.deptId"
:options="deptOptions"
:show-count="true"
placeholder="请选择归属部门"
style="width: 200px"
/>
</el-form-item>
<el-form-item label="题库名称" prop="bankName">
<el-input
v-model="queryParams.bankName"
placeholder="考试时间"
clearable
size="small"
/>
</el-form-item>
<el-form-item>
<el-button
type="primary"
icon="el-icon-search"
size="mini"
@click="search"
>搜索</el-button
>
<el-button icon="el-icon-refresh" size="mini" @click="resetClick"
>重置</el-button
>
</el-form-item>
</el-form>
<el-table v-loading="loading" :data="list" height="435" ref="multipleTable">
<!-- <el-table-column type="selection"></el-table-column> -->
<el-table-column label="" align="center" prop="profession">
<template v-slot="{ row }">
<!-- <div> -->
<el-checkbox
:disabled="row.numberQuestions == 0"
v-model="row.checked"
></el-checkbox>
<!-- </div> -->
</template>
</el-table-column>
<el-table-column label="题库名称" align="center" prop="bankName">
</el-table-column>
<el-table-column label="所属单位" align="center" prop="courseType">
<template v-slot="scope">
<div>
{{ selectList(deptOptions, scope.row.deptId) || "-" }}
</div>
</template>
</el-table-column>
<el-table-column
label="包含题目数量"
align="center"
prop="numberQuestions"
:formatter="formatter"
>
</el-table-column>
<el-table-column label="选取题目数量" align="center" prop="profession">
<template v-slot="{ row }">
<div>
<!-- <el-input
:disabled="!row.checked|| row.numberQuestions==0 "
v-model="row.changeNum"
size="mini"
style="width: 100px"
></el-input> -->
<el-input-number
v-model="row.changeNum"
:disabled="!row.checked || row.numberQuestions == 0"
size="mini"
:min="1"
:max="+row.numberQuestions ? +row.numberQuestions : 1000000"
label="描述文字"
></el-input-number>
</div>
</template>
</el-table-column>
</el-table>
<!-- <div> -->
<el-pagination
:layout="'prev, pager, next'"
v-show="total > 0"
:total="total"
:current-page="queryParams.pageNum"
:page-sizes="[queryParams.pageSize]"
@current-change="currentChangeClick"
/>
</div>
</template>
<script>
import { listBank, delBank } from "@/api/educationPlanExam/questionBank";
import { bachAddTopic } from "@/api/educationPlanExam/lessonsProgram.js";
// 部门列表
import { treeselect } from "@/api/system/dept";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
export default {
name: "",
components: {
Treeselect,
},
props: {
courseId: {
type: Number,
},
},
data() {
return {
queryParams: {
deptId: null,
courseName: "",
pageNum: 1,
pageSize: 10,
},
list: [
{
checked: false,
},
],
total: 20,
loading: false,
// 题库id
deptId: null,
// 归属部门列表
deptOptions: [],
};
},
created() {
this.getList();
this.getTreeselect();
},
methods: {
getTreeselect() {
treeselect().then((response) => {
this.deptOptions = response.data;
// console.log("123", this.deptOptions);
// console.log(this.selectList(this.deptOptions, 175));
});
},
// 递归查值的方法
selectList(list, id) {
for (let i = 0; i < list.length; i++) {
let item = list[i];
if (item.id == id) {
return item.label;
} else {
if (Array.isArray(item.children)) {
let a = this.selectList(item.children, id);
if (a) {
return a;
}
}
}
}
},
getList() {
this.loading = true;
listBank(this.queryParams)
.then((res) => {
console.log(res);
this.list = res.rows.map((item, index) => {
return {
bankNum:
index +
1 +
(this.queryParams.pageNum - 1) * this.queryParams.pageSize,
checked: false,
changeNum: 0,
...item,
};
});
this.total = res.total;
})
.finally(() => {
this.loading = false;
});
},
saveAndNext() {
const topicInfos = this.list
.filter((item) => item.checked)
.map((item) => {
return {
bankId: item.bankId,
quan: item.changeNum,
};
});
console.log(this.courseId, topicInfos);
const data = { courseId: this.courseId, topicInfos };
console.log(data);
bachAddTopic(data).then((res) => {
console.log(res);
if (res.code == 200) {
this.$parent.$parent.componentsNumChange(2);
this.$parent.$parent.$parent.getList();
}
});
},
resetClick() {},
search() {
this.getList();
},
currentChangeClick() {},
formatter(row, column, cellValue, index) {
// console.log(row, column, cellValue, index);
if (!cellValue) return "-";
else return cellValue;
},
},
};
</script>
<style lang="scss" scoped>
.table-wrapper {
padding-top: 22px;
width: 100%;
height: 550px;
overflow: hidden;
// padding-bottom: 10px;
margin-bottom: 20px;
}
</style>
......@@ -2,7 +2,7 @@
* @Author: 纪泽龙 jizelong@qq.com
* @Date: 2022-09-22 10:38:49
* @LastEditors: 纪泽龙 jizelong@qq.com
* @LastEditTime: 2023-01-04 17:50:46
* @LastEditTime: 2023-01-13 15:59:47
* @FilePath: /danger-manage-web/src/views/lessonsProgram/components/addLesson.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
......@@ -18,7 +18,7 @@
@closed="closeFinished"
destroy-on-close
>
<div v-if="visible" ref="myBody" class="body ">
<div v-if="visible" ref="myBody" class="body">
<transition name="fade" mode="out-in">
<component
:is="currentComponent"
......@@ -33,13 +33,25 @@
</div>
<div slot="footer" class="dialog-footer">
<el-button
type="primary"
v-if="this.componentsNum == 2"
@click="componentsNumChange(4)"
>从题库选择</el-button
>
<el-button
type="primary"
v-if="this.componentsNum == 1 || this.componentsNum == 3"
@click="save"
>保存</el-button
>
<el-button
type="primary"
v-if="this.componentsNum == 4"
@click="componentsNumChange(2)"
>返回题目列表</el-button
>
<el-button type="primary" @click="saveAndNext">{{
saveNextText
}}</el-button>
......@@ -58,6 +70,8 @@
import Lesson from "./Lesson";
import AddQuestion from "./AddQuestion";
import QuestionList from "./QuestionList";
import ChangeQuestion from "./ChangeQuestion";
export default {
name: "AnswerLesson",
......@@ -102,13 +116,16 @@ export default {
this.currentComponent = QuestionList;
this.title = "题目列表";
} else {
} else if(num===3) {
this.currentComponent = AddQuestion;
if (this.topicId) {
this.title = "修改题目";
} else {
this.title = "新增题目";
}
}else if (num == 4) {
this.currentComponent = ChangeQuestion;
this.title = "从题库选题";
}
},
deep: true,
......@@ -146,7 +163,7 @@ export default {
// 隐藏与显示dialog
dialogCancel() {
// 录入考题的时候不会有修改的缓存
if (this.topicId) {
if (this.topicId) {
this.topicId = null;
}
this.$emit("update:visible", false);
......
......@@ -2,7 +2,7 @@
* @Author: 纪泽龙 jizelong@qq.com
* @Date: 2022-09-22 17:56:05
* @LastEditors: 纪泽龙 jizelong@qq.com
* @LastEditTime: 2022-09-28 17:54:16
* @LastEditTime: 2023-01-13 16:26:33
* @FilePath: /danger-manage-web/src/views/lessonsProgram/components/QuestionList.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
......@@ -14,11 +14,46 @@
>道题
<span class="warn">温馨提示:发布课程前需要进行考试设置</span>
</div>
<div class="right">{{courseName}}</div>
<div class="right">{{ courseName }}</div>
</div>
<div class="detail flex">
<div class="detail-item">
单选题<span>{{ bottomFrom.singleChoiceScore }}</span
>分/题,共<span>{{ danxs }}</span
>题,计<span class="textC">{{
danxs * bottomFrom.singleChoiceScore
}}</span
>
</div>
<div class="detail-item">
多选题<span>{{ bottomFrom.multipleChoiceScore }}</span
>分/题,共<span>{{ duoxs }}</span> 题,计<span class="textC">{{
duoxs * bottomFrom.multipleChoiceScore
}}</span
>
</div>
<div class="detail-item">
判断提<span>{{ bottomFrom.judgmentScore }}</span
>/题,共<span>{{ pds }}</span> 题,计<span class="textC">{{
pds * bottomFrom.judgmentScore
}}</span
>
</div>
<div class="detail-item">
一共<span>{{ danxs + duoxs + pds }}</span
>道题,总共计<span class="textC">{{
danxs * bottomFrom.singleChoiceScore +
duoxs * bottomFrom.multipleChoiceScore +
pds * bottomFrom.judgmentScore
}}</span
>
</div>
</div>
<div class="table flex" v-loading="loading">
<div class="th flex">
<div class="left">序号</div>
<div class="type">题目类型</div>
<div class="middle">题目名称</div>
<div class="right">操作</div>
</div>
......@@ -29,6 +64,7 @@
class="td flex"
>
<div class="left">{{ index + 1 }}</div>
<div class="type">{{ topicTypeArr[item.topicType] }}</div>
<div class="middle zzz">
{{ item.topicTitle }}
</div>
......@@ -51,19 +87,57 @@
</div>
</div>
</div>
<div class="rightNum flex">
<div class="left">考试设置</div>
<div class="middle flex">
<div class="left-text">单选一题</div>
<div>
<el-input
v-model="bottomFrom.singleChoiceScore"
style="width: 50px"
size="mini"
></el-input>
</div>
<div></div>
</div>
<div class="middle flex">
<div class="left-text">多选一题</div>
<div>
<el-input
v-model="bottomFrom.multipleChoiceScore"
style="width: 50px"
size="mini"
></el-input>
</div>
<div></div>
</div>
<div class="middle flex">
<div class="left-text">判断一题</div>
<div>
<el-input
v-model="bottomFrom.judgmentScore"
style="width: 50px"
size="mini"
></el-input>
</div>
<div></div>
</div>
<div class="middle flex">
<div class="left-text">答对题目大于</div>
<div class="left-text">总分大于</div>
<div>
<el-input
v-model="rightNum"
v-model="bottomFrom.qualifiedNum"
style="width: 60px"
size="mini"
></el-input>
</div>
<div>为合格</div>
</div>
<div class="right">
<el-button
@click="saveRightNum"
......@@ -97,10 +171,21 @@ export default {
// 当前课程的第几题,调一遍接口
questionNum: null,
// 答对几道题
rightNum: 0,
// rightNum: 0,
bottomFrom: {
singleChoiceScore: 0,
multipleChoiceScore: 0,
judgmentScore: 0,
qualifiedNum: 0,
},
questionList: [],
loading: false,
courseName:'',
courseName: "",
topicTypeArr: {
1: "单选题",
2: "多选题",
3: "判断题",
},
};
},
// watch: {
......@@ -112,7 +197,17 @@ export default {
// }
// },
// },
computed: {
danxs() {
return this.questionList.filter((item) => item.topicType === 1).length;
},
duoxs() {
return this.questionList.filter((item) => item.topicType === 2).length;
},
pds() {
return this.questionList.filter((item) => item.topicType === 3).length;
},
},
created() {
console.log("this.courseId", this.courseId);
if (this.courseId) {
......@@ -134,6 +229,7 @@ export default {
this.questionList = res.rows.map((item) => {
return {
topicType: item.topicType,
topicId: item.topicId,
topicTitle: item.topicTitle,
};
......@@ -145,7 +241,12 @@ export default {
getLessonById(courseId) {
getLessonById(courseId).then((res) => {
console.log(res);
this.rightNum = res.data.qualifiedNum;
this.bottomFrom = {
singleChoiceScore: res.data.singleChoiceScore || 0,
multipleChoiceScore: res.data.multipleChoiceScore || 0,
judgmentScore: res.data.judgmentScore || 0,
qualifiedNum: res.data.qualifiedNum || 0,
};
this.courseName = res.data.courseName;
});
},
......@@ -179,23 +280,44 @@ export default {
});
},
saveRightNum() {
if (this.rightNum > this.questionList.length) {
// if (this.bottomFrom.rightNum > this.questionList.length) {
// this.$message({
// message: "答对题目数应小于等于考试题目总数",
// type: "warning",
// });
// return;
// }
// const danx = this.questionList.filter(item=>item.topicType===1);
// const duox = this.questionList.filter(item=>item.topicType===2);
// const pd = this.questionList.filter(item=>item.topicType===3);
// 如果有一个没写,就不允许保存
if (
!(
this.bottomFrom.singleChoiceScore > 0 &&
this.bottomFrom.multipleChoiceScore > 0 &&
this.bottomFrom.judgmentScore > 0 &&
this.fobottomFromrm.qualifiedNum > 0
)
) {
this.$message({
message: "答对题目数应小于等于考试题目总数",
message: "请将分数填写完整",
type: "warning",
});
return;
}
changeLesson({ courseId: this.courseId, qualifiedNum: this.rightNum }).then(
(res) => {
if (res.code == 200) {
this.$message({
message: "答题合格数修改成功",
type: "success",
});
}
changeLesson({
courseId: this.courseId,
// qualifiedNum: this.rightNum,
...this.bottomFrom,
}).then((res) => {
if (res.code == 200) {
this.$message({
message: "答题合格数修改成功",
type: "success",
});
}
);
});
},
},
};
......@@ -209,7 +331,7 @@ export default {
padding-bottom: 7px;
margin-bottom: 20px;
border-bottom: 1px solid #bbbbbb00;
position: relative;
.text {
margin-top: 13px;
margin-bottom: 32px;
......@@ -236,6 +358,19 @@ export default {
text-align: right;
}
}
.detail {
position: absolute;
bottom: -20px;
left: 10px;
.textC {
font-weight: 800;
font-size: 18px;
}
.detail-item {
margin-right: 20px;
color: red;
}
}
.table {
flex: 1;
height: 0;
......@@ -255,9 +390,13 @@ export default {
width: 15%;
text-align: center;
}
.type {
width: 10%;
text-align: center;
}
.middle {
width: 60%;
padding-left: 100px;
width: 50%;
padding-left: 50px;
}
.right {
width: 25%;
......@@ -283,9 +422,13 @@ export default {
width: 15%;
text-align: center;
}
.type {
width: 10%;
text-align: center;
}
.middle {
width: 60%;
padding-left: 10px;
width: 50%;
padding-left: 50px;
}
.right {
width: 25%;
......
......@@ -113,11 +113,11 @@
</template>
</el-table-column>
<!--<el-table-column label="视频" align="center" prop="video">-->
<!--<template v-slot="{ row: { courseName, video } }">-->
<!--<a @click="downLoadVideo(video, courseName)" class="down-load"-->
<!--&gt;下载视频</a-->
<!--&gt;-->
<!--</template>-->
<!--<template v-slot="{ row: { courseName, video } }">-->
<!--<a @click="downLoadVideo(video, courseName)" class="down-load"-->
<!--&gt;下载视频</a-->
<!--&gt;-->
<!--</template>-->
<!--</el-table-column>-->
<el-table-column
label="发布时间"
......@@ -343,7 +343,12 @@ export default {
return getLessonById(courseId);
})
.then((res) => {
if (res.data.qualifiedNum > 0) {
if (
res.data.singleChoiceScore > 0 &&
res.data.multipleChoiceScore > 0 &&
res.data.judgmentScore > 0 &&
res.data.qualifiedNum > 0
) {
return true;
}
})
......@@ -353,7 +358,7 @@ export default {
return issue({ courseId });
} else {
this.$message({
message: "请先录入答题合格数",
message: "请先在题目列表录入题目分数跟合格分数",
type: "warning",
});
}
......
......@@ -20,14 +20,26 @@
<transition name="fade" mode="out-in">
<div class="question-wrapper" v-if="visible" :key="nowQuestion">
<div v-for="(item, index) in list" :key="item.id">
<Question
v-if="index === nowQuestion"
:questionObj="item"
:index="index"
:nowQuestion="nowQuestion"
:selectLetter="selectLetter"
@changeLetter="changeLetter"
/>
<template v-if="item.topicType === 1 || item.topicType === 3">
<Question
v-if="index === nowQuestion"
:questionObj="item"
:index="index"
:nowQuestion="nowQuestion"
:selectLetter="selectLetter"
@changeLetter="changeLetter"
/>
</template>
<template v-else>
<QuestionChoice
v-if="index === nowQuestion"
:questionObj="item"
:index="index"
:nowQuestion="nowQuestion"
:selectLetter="selectLetter"
@changeLetter="changeLetter"
/>
</template>
</div>
</div>
</transition>
......@@ -40,7 +52,11 @@
active:
answerArr.findIndex(
(item) => item.questionNum === index + 1
) >= 0,
) >= 0 && activeBool(index),
activered:
answerArr.findIndex(
(item) => item.questionNum === index + 1
) >= 0 && !activeBool(index),
now: index === nowQuestion,
}"
v-for="(item, index) in list"
......@@ -77,6 +93,7 @@
<script>
import Question from "./Question";
import QuestionChoice from "./QuestionChoice";
import GoodJob from "./GoodJob.vue";
import {
userQuestionList,
......@@ -101,8 +118,10 @@ export default {
},
components: {
Question,
QuestionChoice,
GoodJob,
},
data() {
return {
nowQuestion: 0,
......@@ -119,9 +138,10 @@ export default {
],
answerArr: [],
// 题目是否被答过,如果答过,就把值传回去,如果没有答过,就是空
selectLetter: 999,
selectLetter: [],
};
},
// watch: {
// visible(newValue) {
// if (newValue) {
......@@ -138,6 +158,7 @@ export default {
return {
id: item.topicId,
text: item.topicTitle,
topicType: item.topicType,
question: JSON.parse(item.topicOption).map((item) => item.value),
};
});
......@@ -151,7 +172,9 @@ export default {
// this.answerClear();
// this.$emit("update:visible", false);
this.saveBody();
const answers = this.answerArr.map((item) => item.answer).join(",");
const json = JSON.stringify(this.answerArr.map((item) => item.answer));
const answers = json.slice(1,json.length-1);
console.log(answers);
this.loading = true;
setAnswer({
userCourseId: this.userCourseId,
......@@ -159,15 +182,15 @@ export default {
})
.then((res) => {
if (res.code == 200) {
console.log(res.data)
this.goodJobData = res.data;
this.goodJobShow = true;
}
})
.finally(() => {
this.loading = false;
// 是否作对
this.$emit('jj',this.goodJobData)
this.$emit("jj", this.goodJobData);
});
},
dialogCancel() {
......@@ -193,8 +216,7 @@ export default {
this.nowQuestion = index;
}
// 赋值,如果答过的,就传回去,如果没答过,就是空 变成字符串是因为0位false
this.selectLetter =
this.answerArr[this.nowQuestion]?.answer + "" || 99999;
this.selectLetter = this.answerArr[this.nowQuestion]?.answer || [];
},
nextBtnClick() {
// 到头了,打完了
......@@ -232,7 +254,10 @@ export default {
// 替换
this.answerArr.splice(index, 1, obj);
}
// console.log(this.answerArr);
console.log(this.answerArr);
},
activeBool(index) {
return this.answerArr[index]?.answer.length > 0;
},
},
};
......@@ -279,9 +304,16 @@ export default {
font-size: 14px;
text-align: center;
margin-right: 18px;
box-sizing: border-box;
cursor: pointer;
&.active {
background: #e9e9e9;
background: #afe8ab87;
border:none;
}
&.activered {
background: #b9112633;
border:none;
}
&.now {
background: #a3d3ff;
......
......@@ -2,7 +2,7 @@
* @Author: 纪泽龙 jizelong@qq.com
* @Date: 2022-09-21 17:20:49
* @LastEditors: 纪泽龙 jizelong@qq.com
* @LastEditTime: 2022-09-28 11:56:49
* @LastEditTime: 2023-01-12 17:00:34
* @FilePath: /danger-manage-web/src/views/myLessons/components/GoodJob.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
......@@ -13,17 +13,16 @@
<template v-if="goodJobData.answer >= goodJobData.qualifiedNum">
<div class="icon"><i class="iconfont icon-smiling" /></div>
<div>
恭喜你,做对{{ goodJobData.answer }}道题得分{{
Math.floor((goodJobData.answer / goodJobData.topicNum) * 100)
}},成绩合格!
<!-- 恭喜你,做对{{ goodJobData.answer }}道题 -->
恭喜你,得分{{ goodJobData.answer }},成绩合格!
</div>
</template>
<template v-else>
<div class="icon"><i class="iconfont icon-nanguo" /></div>
<div>
继续努力,做对{{ goodJobData.answer }}道题得分{{
Math.floor((goodJobData.answer / goodJobData.topicNum) * 100)
}},成绩不合格!
继续努力,
<!-- 做对{{ goodJobData.answer }}道题 -->
得分{{ goodJobData.answer }},成绩不合格!
</div>
</template>
</div>
......
......@@ -2,12 +2,13 @@
* @Author: 纪泽龙 jizelong@qq.com
* @Date: 2022-09-21 11:00:14
* @LastEditors: 纪泽龙 jizelong@qq.com
* @LastEditTime: 2022-09-28 11:15:27
* @LastEditTime: 2023-01-11 16:44:43
* @FilePath: /danger-manage-web/src/views/myLessons/components/Question.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
<div class="question flex">
<div class="tips">{{ tipsArr[questionObj.topicType] }}</div>
<div
class="top"
:class="{ flex: alignItemsCenter }"
......@@ -23,7 +24,7 @@
<div
class="item flex"
v-for="(item, index) in questionObj.question"
:key="item+'aas'+index"
:key="item + 'aas' + index"
>
<div class="letter">
{{ letters[index] }}
......@@ -38,10 +39,10 @@
<div class="change-wrapper flex">
<div
class="change"
:class="{ active: letterActive+'' === index+'' }"
:class="{ active: letterActive.indexOf(index) >= 0 }"
@click="changeLetter(index)"
v-for="(item, index) in questionObj.question"
:key="item+'a'+index"
:key="item + 'a' + index"
>
{{ letters[index] }}
</div>
......@@ -105,8 +106,10 @@ export default {
},
// 从外面传进来的选项,选择过的才有,没选择过的没有
selectLetter: {
type: [String, Number],
default:999,
type: [String, Number, Array],
default: () => {
return [];
},
},
},
data() {
......@@ -115,6 +118,11 @@ export default {
// 如果传进来了,就是这个值,如果没有就是null,因为动画需要那个key的问题,会清空原始的盒子,所以要传一下值
letterActive: this.selectLetter,
letters,
tipsArr: {
1: "单选题",
2: "多选题",
3: "判断题",
},
};
},
mounted() {
......@@ -143,8 +151,8 @@ export default {
}
},
changeLetter(index) {
this.letterActive = index;
this.$emit("changeLetter", index);
this.letterActive = [index];
this.$emit("changeLetter", this.letterActive);
// this.$emit("changeLetter", this.letters[index]);
},
},
......@@ -161,6 +169,19 @@ export default {
border-bottom: 1px solid #bbbbbb;
// background: red;
flex-direction: column;
position: relative;
.tips {
width: 80px;
height: 24px;
background: #1d84ff;
font-size: 14px;
color: #fff;
position: absolute;
top: -45px;
left: 0px;
text-align: center;
line-height: 24px;
}
.top {
background: #f9f9f9;
height: 54px;
......
<!--
* @Author: 纪泽龙 jizelong@qq.com
* @Date: 2022-09-21 11:00:14
* @LastEditors: 纪泽龙 jizelong@qq.com
* @LastEditTime: 2023-01-11 14:59:40
* @FilePath: /danger-manage-web/src/views/myLessons/components/Question.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
<div class="question flex">
<div class="tips">{{ tipsArr[questionObj.topicType] }}</div>
<div
class="top"
:class="{ flex: alignItemsCenter }"
:style="{ alignItems: alignItemsCenter ? 'center' : '' }"
ref="top"
>
<div class="text" ref="text">
{{ questionObj.text }}
</div>
<div class="num">{{ nowQuestion + 1 }}</div>
</div>
<div class="middle">
<div
class="item flex"
v-for="(item, index) in questionObj.question"
:key="item + 'aas' + index"
>
<div class="letter">
{{ letters[index] }}
</div>
<div class="">
{{ item }}
</div>
</div>
</div>
<div class="bottom flex">
<div class="change-wrapper flex">
<div
class="change"
:class="{ active: letterActive.indexOf(index) >= 0 }"
@click="changeLetter(index)"
v-for="(item, index) in questionObj.question"
:key="item + 'a' + index"
>
{{ letters[index] }}
</div>
</div>
</div>
</div>
</template>
<script>
const letters = [
"A",
"B",
"C",
"D",
"E",
"F",
"G",
"H",
"I",
"J",
"K",
"L",
"M",
"N",
"O",
"P",
"Q",
"R",
"S",
"T",
"U",
"V",
"W",
"X",
"Y",
"Z",
];
export default {
name: "question",
props: {
questionObj: {
type: Object,
default: () => {
return {
text: "asdfasdf",
question: [
"沙发斯蒂芬大师沙发斯蒂芬大师沙发斯蒂芬大师沙发斯蒂芬大师沙发斯蒂芬大师沙发斯蒂芬大师沙发斯蒂芬大师沙发斯蒂芬大师沙发斯蒂芬大师沙发斯蒂芬大师沙发斯蒂芬大师沙发斯蒂芬大师沙发斯蒂芬大师沙发斯蒂芬大师沙发斯蒂芬大师沙发斯蒂芬大师沙发斯蒂芬大师沙发斯蒂芬大师沙发斯蒂芬大师沙发斯蒂芬大师沙发斯蒂芬大师",
"沙发斯蒂芬大师",
"沙发斯蒂芬大师",
"沙发斯蒂芬大师",
"沙发斯蒂芬大师",
],
};
},
},
nowQuestion: {
type: Number,
},
index: {
type: Number,
},
// 从外面传进来的选项,选择过的才有,没选择过的没有
selectLetter: {
type: [String, Number, Array],
default: () => {
return [];
},
},
},
data() {
return {
alignItemsCenter: false,
// 如果传进来了,就是这个值,如果没有就是null,因为动画需要那个key的问题,会清空原始的盒子,所以要传一下值
letterActive: this.selectLetter,
letters,
tipsArr: {
1: "单选题",
2: "多选题",
3: "判断题",
},
};
},
mounted() {
// console.log('123')
// 每次都会更新,所以不需要watch 直接在这里面写 因为动画需要那个key的问题,会清空原始的盒子,所以要传一下值
this.textCenter();
},
watch: {
// 监听一下当前题目,调整一下位置
// nowQuestion(value) {
// console.log('nowQuestion变化',value)
// this.$nextTick(() => {
// this.textCenter();
// });
// },
},
methods: {
textCenter() {
let h1 = this.$refs.text?.offsetHeight;
let h2 = this.$refs.top?.offsetHeight;
// 如果text大于或者等于top,就出不居中,如果不小于top,就上下居中
if (h2 <= h1) {
this.alignItemsCenter = false;
} else {
this.alignItemsCenter = true;
}
},
changeLetter(index) {
// this.letterActive = index;
const ind = this.letterActive.indexOf(index);
if (ind < 0) {
this.letterActive.push(index);
} else {
this.letterActive.splice(ind, 1);
}
this.$emit("changeLetter", this.letterActive);
// this.$emit("changeLetter", this.letters[index]);
},
},
};
</script>
<style lang="scss" scoped>
.question {
// position: absolute;
// top: 0px;
// display: inline-block;
width: 100%;
height: 370px;
padding-bottom: 10px;
border-bottom: 1px solid #bbbbbb;
// background: red;
flex-direction: column;
position: relative;
.tips {
width: 80px;
height: 24px;
background: #1d84ff;
font-size: 14px;
color: #fff;
position: absolute;
top: -45px;
left: 0px;
text-align: center;
line-height: 24px;
}
.top {
background: #f9f9f9;
height: 54px;
padding: 0px 10px 0px 43px;
overflow-wrap: anywhere;
// align-items: center;
overflow-y: auto;
position: relative;
.text {
font-size: 14px;
text-indent: 2em;
}
.num {
position: absolute;
left: 0;
width: 48px;
height: 48px;
top: 4px;
background: #1d84ff;
border-radius: 50%;
text-align: center;
line-height: 48px;
font-size: 18px;
color: #ffffff;
}
}
.middle {
flex: 1;
// background: blue;
overflow-y: auto;
padding-left: 43px;
padding-right: 10px;
margin-bottom: 15px;
.item {
padding-top: 38px;
width: 100%;
overflow-wrap: anywhere;
font-size: 14px;
color: #101010;
.letter {
padding: 2px;
margin-right: 10px;
box-sizing: border-box;
}
}
}
.bottom {
max-height: 70px;
// background: black;
padding-left: 43px;
padding-right: 10px;
overflow-y: auto;
.change-wrapper {
width: 756px;
flex-wrap: wrap;
margin: 0 auto;
.change {
width: 90px;
height: 30px;
background: #e8f4ff;
color: #101010;
border: 1px solid #a3d3ff;
line-height: 30px;
text-align: center;
margin: 0 9px 5px;
border-radius: 4px;
cursor: pointer;
&.active {
background: #1d84ff;
color: #ffffff;
border: 1px solid #a3d3ff;
}
&:hover {
background: rgba(29, 132, 255, 0.5);
color: #ffffff;
}
}
}
}
}
</style>
......@@ -26,19 +26,20 @@
</div>
<div class="right flex">
<div class="a">
<span
<!-- <span
class="text"
:class="{ red: item.examinationResult < item.qualifiedNum }"
>{{
(item.examinationResult &&item.topicNum)? Math.floor((item.examinationResult / item.topicNum) * 100):0
}}</span
>/<span>100</span>
>/<span>100</span> -->
<span class="text">{{item.examinationResult}}</span>/<span>{{item.totalScore}}</span>
</div>
<div class="b flex">
<div style="width: 60px">
<el-progress
:percentage="
Math.floor((item.examinationResult / item.topicNum) * 100)
Math.floor((item.examinationResult / item.totalScore) * 100)
"
:show-text="false"
></el-progress>
......@@ -64,6 +65,9 @@ export default {
data() {
return {};
},
mounted(){
console.log(this.list)
},
methods: {},
};
</script>
......
......@@ -5,6 +5,18 @@
目前录入题目是第<span>{{ questionNextNum }}</span
>道题
</div>
<div>
<el-radio-group
v-model="form.topicType"
size="mini"
@input="topicTypeChange"
>
<el-radio-button :label="1">单选</el-radio-button>
<el-radio-button :label="2">多选</el-radio-button>
<el-radio-button :label="3">判断</el-radio-button>
</el-radio-group>
</div>
<div class="right">{{ courseName }}</div>
</div>
......@@ -62,7 +74,7 @@
<div
@click="rightAnswerClick(index)"
class="right"
:class="{ active: answerNum === index }"
:class="{ active: answerNum.indexOf(index) >= 0 }"
>
设为正确答案
</div>
......@@ -77,7 +89,7 @@
</div>
</el-form-item>
<el-form-item
<!-- <el-form-item
class="noAttr"
:label="`选项${form.questions.length + 1}`"
prop=""
......@@ -99,17 +111,15 @@
:class="{ active: answerNum === form.questions.length }"
>
设为正确答案
</div>
<el-button
size="mini"
type="primary"
@click.prevent="add(addValue)"
>新增</el-button
>
</div>
</div> -->
<div style="padding-left: 30px" v-if="form.topicType != 3">
<el-button size="mini" type="primary" @click.prevent="add(addValue)"
>新增选项</el-button
>
</div>
<!-- </div>
</div>
</el-form-item>
</el-form-item> -->
</div>
</el-form>
</div>
......@@ -148,10 +158,11 @@ export default {
data() {
return {
form: {
topicType: 1,
topicTitle: "",
questions: [{ value: "" }, { value: "" }, { value: "" }],
questions: [{ value: "" }, { value: "" }],
},
answerNum: null,
answerNum: [],
addValue: "",
// 录入的是第几道题
questionNextNum: 1,
......@@ -166,10 +177,12 @@ export default {
console.log("?", res.data);
const data = res.data;
this.form = {
topicType: data.topicType,
topicTitle: data.topicTitle,
questions: JSON.parse(data.topicOption),
};
this.answerNum = data.answer;
// this.answerNum = data.answer;
this.answerNum = JSON.parse(data.answer);
});
}
......@@ -179,6 +192,23 @@ export default {
// this.getLessonById(this.bankId);
},
methods: {
// 题目类型变化
topicTypeChange(num) {
if (num == 1) {
this.answerNum = [];
} else if (num == 2) {
this.answerNum = [];
// this.form.questions=[{ value: "" }, { value: "" }];
} else {
this.answerNum = [];
const form = {
topicType: 3,
topicTitle: this.form.topicTitle,
questions: [{ value: "对" }, { value: "错" }],
};
this.form = form;
}
},
getQuestion() {
listSubject({ bankId: this.bankId }).then((res) => {
console.log(res);
......@@ -209,19 +239,46 @@ export default {
}
},
rightAnswerClick(index) {
this.answerNum = index;
console.log(index);
if (this.form.topicType === 2) {
const ind = this.answerNum.indexOf(index);
if (ind < 0) {
this.answerNum.push(index);
} else {
this.answerNum.splice(ind, 1);
}
this.answerNum = this.answerNum.sort((a, b) => {
return a - b;
});
console.log(this.answerNum);
} else {
// 判断跟单选模式差不多
this.answerNum = [index];
}
},
// 删除选项
removeDomain(question) {
const index = this.form.questions.indexOf(question);
console.log(index);
// 如果是正确答案,就让正确答案清空
if (this.answerNum === index) {
this.answerNum = null;
const ind = this.answerNum.indexOf(index);
if (ind >= 0) {
this.answerNum.splice(ind, 1);
}
// 如果是最后一位呗删除,那不用管,如果不是最后一位置,这一位删除之后,则这一位后面的所有数字都要-1;
if (index != this.form.questions.length - 1) {
this.answerNum = this.answerNum.map((item, i) => {
if (item >= index) {
return item - 1;
} else {
return item;
}
});
}
if (index >= 0) {
this.form.questions.splice(index, 1);
}
console.log(this.answerNum);
// console.log(this.form.questions)
},
// 新增选项
add(addValue) {
......@@ -230,7 +287,7 @@ export default {
},
save(num = 2) {
return new Promise((resove) => {
if (!this.answerNum && this.answerNum !== 0) {
if (this.answerNum.length <= 0) {
this.$message({
message: "警告,请设置一个正确答案",
type: "warning",
......@@ -242,7 +299,9 @@ export default {
const data = {};
data.topicTitle = this.form.topicTitle;
data.topicOption = JSON.stringify(this.form.questions);
data.answer = this.answerNum;
// data.answer = this.answerNum;
data.answer = JSON.stringify(this.answerNum);
data.topicType = this.form.topicType;
this.addQuestion(data).then((res) => {
if (res.code == 200) {
// 把修改的这个归位,变成正常添加
......@@ -273,9 +332,9 @@ export default {
reset() {
this.form = {
topicTitle: "",
questions: [{ value: "" }, { value: "" }, { value: "" }],
questions: [{ value: "" }, { value: "" }],
};
this.answerNum = null;
this.answerNum = [];
this.addValue = "";
},
},
......
......@@ -2,7 +2,7 @@
* @Author: 纪泽龙 jizelong@qq.com
* @Date: 2022-09-22 17:56:05
* @LastEditors: 纪泽龙 jizelong@qq.com
* @LastEditTime: 2022-12-27 16:03:40
* @LastEditTime: 2023-01-15 13:47:35
* @FilePath: /danger-manage-web/src/views/lessonsProgram/components/QuestionList.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
......@@ -32,6 +32,7 @@
<div class="table flex" v-loading="loading">
<div class="th flex">
<div class="left">序号</div>
<div class="type">题目类型</div>
<div class="middle">题目名称</div>
<div class="right">操作</div>
</div>
......@@ -42,6 +43,7 @@
class="td flex"
>
<div class="left">{{ index + 1 }}</div>
<div class="type">{{ topicTypeArr[item.topicType] }}</div>
<div class="middle zzz">
{{ item.topicTitle }}
</div>
......@@ -189,7 +191,12 @@ export default {
url: process.env.VUE_APP_BASE_API + "/system/subject/import",
},
queryParams: {
bankId:0
bankId: 0,
},
topicTypeArr: {
1: "单选题",
2: "多选题",
3: "判断题",
},
};
},
......@@ -214,11 +221,14 @@ export default {
methods: {
// 文件下载处理
handleDownload(row) {
const a = document.createElement('a')
a.setAttribute('download', '试题导入模板')
a.setAttribute('target', '_blank')
a.setAttribute('href', 'http://36.138.181.113:8091/dangerManage/profile/upload/2022/kaoshi/shitimoban.xlsx')
a.click()
const a = document.createElement("a");
a.setAttribute("download", "试题导入模板");
a.setAttribute("target", "_blank");
a.setAttribute(
"href",
"http://36.138.181.113:8091/dangerManage/profile/upload/2022/kaoshi/shitimoban.xlsx"
);
a.click();
},
/** 导入按钮操作 */
......@@ -263,9 +273,9 @@ export default {
},
getQuestion(bankId) {
return listSubject(bankId).then((res) => {
this.questionList = res.rows.map((item) => {
return {
topicType:item.topicType,
subjectId: item.subjectId,
topicTitle: item.topicTitle,
};
......@@ -388,9 +398,13 @@ export default {
width: 15%;
text-align: center;
}
.type {
width: 10%;
text-align: center;
}
.middle {
width: 60%;
padding-left: 100px;
width: 50%;
padding-left: 50px;
}
.right {
width: 25%;
......@@ -416,9 +430,13 @@ export default {
width: 15%;
text-align: center;
}
.type {
width: 10%;
text-align: center;
}
.middle {
width: 60%;
padding-left: 10px;
width: 50%;
padding-left: 50px;
}
.right {
width: 25%;
......
......@@ -5,6 +5,17 @@
目前录入题目是第<span>{{ questionNextNum }}</span
>道题
</div>
<div>
<el-radio-group
v-model="form.topicType"
size="mini"
@input="topicTypeChange"
>
<el-radio-button :label="1">单选</el-radio-button>
<el-radio-button :label="2">多选</el-radio-button>
<el-radio-button :label="3">判断</el-radio-button>
</el-radio-group>
</div>
<div class="right">{{ courseName }}</div>
</div>
......@@ -40,15 +51,11 @@
:label="'选项' + (index + 1)"
:key="question.key"
:prop="'questions.' + index + '.value'"
:rules="
index === 0
? {
required: true,
message: '第一项不能为空不能为空',
trigger: 'blur',
}
: {}
"
:rules="{
required: true,
message: '第一项不能为空不能为空',
trigger: 'blur',
}"
>
<div class="add-select flex">
<el-input
......@@ -62,7 +69,7 @@
<div
@click="rightAnswerClick(index)"
class="right"
:class="{ active: answerNum === index }"
:class="{ active: answerNum.indexOf(index) >= 0 }"
>
设为正确答案
</div>
......@@ -100,7 +107,7 @@
>
设为正确答案
</div> -->
<div style="padding-left:30px">
<div style="padding-left: 30px">
<el-button size="mini" type="primary" @click.prevent="add(addValue)"
>新增选项</el-button
>
......@@ -141,10 +148,11 @@ export default {
data() {
return {
form: {
topicType: 1,
topicTitle: "",
questions: [{ value: "" }, { value: "" }],
},
answerNum: null,
answerNum: [],
addValue: "",
// 录入的是第几道题
questionNextNum: 1,
......@@ -159,10 +167,12 @@ export default {
console.log(res.data);
const data = res.data;
this.form = {
topicType: data.topicType,
topicTitle: data.topicTitle,
questions: JSON.parse(data.topicOption),
};
this.answerNum = data.answer;
// this.answerNum = data.answer;
this.answerNum = JSON.parse(data.answer);
});
}
......@@ -172,14 +182,31 @@ export default {
this.getLessonById(this.courseId);
},
methods: {
// 题目类型变化
topicTypeChange(num) {
if (num == 1) {
this.answerNum = [];
} else if (num == 2) {
this.answerNum = [];
// this.form.questions=[{ value: "" }, { value: "" }];
} else {
this.answerNum = [];
const form = {
topicType: 3,
topicTitle: this.form.topicTitle,
questions: [{ value: "对" }, { value: "错" }],
};
this.form = form;
}
},
getQuestion() {
getQuestion({ courseId: this.courseId }).then((res) => {
// 如果是修改 就是原来的值,如果不是,就是总数+1
console.log(res)
console.log(res);
if (this.topicId) {
res.rows.forEach((item, index) => {
if (item.topicId == this.topicId) {
this.questionNextNum = index+1;
this.questionNextNum = index + 1;
}
});
} else {
......@@ -202,20 +229,58 @@ export default {
}
},
rightAnswerClick(index) {
this.answerNum = index;
console.log(index);
if (this.form.topicType === 2) {
const ind = this.answerNum.indexOf(index);
if (ind < 0) {
this.answerNum.push(index);
} else {
this.answerNum.splice(ind, 1);
}
this.answerNum = this.answerNum.sort((a, b) => {
return a - b;
});
console.log(this.answerNum);
} else {
// 判断跟单选模式差不多
this.answerNum = [index];
}
},
// 删除选项
removeDomain(question) {
const index = this.form.questions.indexOf(question);
console.log(index);
// 如果是正确答案,就让正确答案清空
if (this.answerNum === index) {
this.answerNum = null;
const ind = this.answerNum.indexOf(index);
if (ind >= 0) {
this.answerNum.splice(ind, 1);
}
// 如果是最后一位呗删除,那不用管,如果不是最后一位置,这一位删除之后,则这一位后面的所有数字都要-1;
if (index != this.form.questions.length - 1) {
this.answerNum = this.answerNum.map((item, i) => {
if (item >= index) {
return item - 1;
} else {
return item;
}
});
}
if (index >= 0) {
this.form.questions.splice(index, 1);
}
console.log(this.answerNum);
// console.log(this.form.questions)
},
// 删除选项
// removeDomain(question) {
// const index = this.form.questions.indexOf(question);
// // 如果是正确答案,就让正确答案清空
// if (this.answerNum === index) {
// this.answerNum = null;
// }
// if (index >= 0) {
// this.form.questions.splice(index, 1);
// }
// },
// 新增选项
add(addValue) {
this.form.questions.push({ value: addValue });
......@@ -235,7 +300,9 @@ export default {
const data = {};
data.topicTitle = this.form.topicTitle;
data.topicOption = JSON.stringify(this.form.questions);
data.answer = this.answerNum;
// data.answer = this.answerNum;
data.answer = JSON.stringify(this.answerNum);
data.topicType = this.form.topicType;
this.addQuestion(data).then((res) => {
if (res.code == 200) {
// 把修改的这个归位,变成正常添加
......
......@@ -2,7 +2,7 @@
* @Author: 纪泽龙 jizelong@qq.com
* @Date: 2022-09-22 17:56:05
* @LastEditors: 纪泽龙 jizelong@qq.com
* @LastEditTime: 2022-12-26 16:55:10
* @LastEditTime: 2023-01-13 16:26:00
* @FilePath: /danger-manage-web/src/views/lessonsProgram/components/QuestionList.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
......@@ -16,9 +16,43 @@
</div>
<div class="right">{{ courseName }}</div>
</div>
<div class="detail flex">
<div class="detail-item">
单选题<span>{{ bottomFrom.singleChoiceScore }}</span
>分/题,共<span>{{ danxs }}</span
>题,计<span class="textC">{{
danxs * bottomFrom.singleChoiceScore
}}</span
>
</div>
<div class="detail-item">
多选题<span>{{ bottomFrom.multipleChoiceScore }}</span
>分/题,共<span>{{ duoxs }}</span> 题,计<span class="textC">{{
duoxs * bottomFrom.multipleChoiceScore
}}</span
>
</div>
<div class="detail-item">
判断提<span>{{ bottomFrom.judgmentScore }}</span>/题,共<span>{{ pds }}</span> 题,计<span
class="textC"
>{{ pds * bottomFrom.judgmentScore }}</span
>
</div>
<div class="detail-item">
一共<span>{{ danxs + duoxs + pds }}</span>道题,总共计<span class="textC">{{
danxs * bottomFrom.singleChoiceScore +
duoxs * bottomFrom.multipleChoiceScore +
pds * bottomFrom.judgmentScore
}}</span
>
</div>
</div>
<div class="table flex" v-loading="loading">
<div class="th flex">
<div class="left">序号</div>
<div class="type">题目类型</div>
<div class="middle">题目名称</div>
<div class="right">操作</div>
</div>
......@@ -29,6 +63,7 @@
class="td flex"
>
<div class="left">{{ index + 1 }}</div>
<div class="type">{{ topicTypeArr[item.topicType] }}</div>
<div class="middle zzz">
{{ item.topicTitle }}
</div>
......@@ -53,7 +88,7 @@
</div>
<div class="rightNum flex">
<div class="left">考试设置</div>
<div class="middle flex">
<!-- <div class="middle flex">
<div class="left-text">答对题目大于</div>
<div>
<el-input
......@@ -63,6 +98,52 @@
></el-input>
</div>
<div>为合格</div>
</div> -->
<div class="middle flex">
<div class="left-text">单选一题</div>
<div>
<el-input
v-model="bottomFrom.singleChoiceScore"
style="width: 50px"
size="mini"
></el-input>
</div>
<div></div>
</div>
<div class="middle flex">
<div class="left-text">多选一题</div>
<div>
<el-input
v-model="bottomFrom.multipleChoiceScore"
style="width: 50px"
size="mini"
></el-input>
</div>
<div></div>
</div>
<div class="middle flex">
<div class="left-text">判断一题</div>
<div>
<el-input
v-model="bottomFrom.judgmentScore"
style="width: 50px"
size="mini"
></el-input>
</div>
<div></div>
</div>
<div class="middle flex">
<div class="left-text">总分大于</div>
<div>
<el-input
v-model="bottomFrom.qualifiedNum"
style="width: 60px"
size="mini"
></el-input>
</div>
<div>为合格</div>
</div>
<div class="right">
<el-button
......@@ -96,11 +177,22 @@ export default {
return {
// 当前课程的第几题,调一遍接口
questionNum: null,
bottomFrom: {
singleChoiceScore: 0,
multipleChoiceScore: 0,
judgmentScore: 0,
qualifiedNum: 0,
},
// 答对几道题
rightNum: 0,
questionList: [],
loading: false,
courseName: "",
topicTypeArr: {
1: "单选题",
2: "多选题",
3: "判断题",
},
};
},
// watch: {
......@@ -112,7 +204,17 @@ export default {
// }
// },
// },
computed: {
danxs() {
return this.questionList.filter((item) => item.topicType === 1).length;
},
duoxs() {
return this.questionList.filter((item) => item.topicType === 2).length;
},
pds() {
return this.questionList.filter((item) => item.topicType === 3).length;
},
},
created() {
console.log("this.courseId", this.courseId);
if (this.courseId) {
......@@ -134,6 +236,7 @@ export default {
this.questionList = res.rows.map((item) => {
return {
topicType: item.topicType,
topicId: item.topicId,
topicTitle: item.topicTitle,
};
......@@ -145,7 +248,13 @@ export default {
getLessonById(courseId) {
getLessonById(courseId).then((res) => {
console.log(res);
this.rightNum = res.data.qualifiedNum;
// this.rightNum = res.data.qualifiedNum;
this.bottomFrom = {
singleChoiceScore: res.data.singleChoiceScore || 0,
multipleChoiceScore: res.data.multipleChoiceScore || 0,
judgmentScore: res.data.judgmentScore || 0,
qualifiedNum: res.data.qualifiedNum || 0,
};
this.courseName = res.data.courseName;
});
},
......@@ -179,16 +288,31 @@ export default {
});
},
saveRightNum() {
if (this.rightNum > this.questionList.length) {
// if (this.rightNum > this.questionList.length) {
// this.$message({
// message: "答对题目数应小于等于考试题目总数",
// type: "warning",
// });
// return;
// }
if (
!(
this.bottomFrom.singleChoiceScore > 0 &&
this.bottomFrom.multipleChoiceScore > 0 &&
this.bottomFrom.judgmentScore > 0 &&
this.bottomFrom.qualifiedNum > 0
)
) {
this.$message({
message: "答对题目数应小于等于考试题目总数",
message: "请将分数填写完整",
type: "warning",
});
return;
}
changeLesson({
courseId: this.courseId,
qualifiedNum: this.rightNum,
// qualifiedNum: this.rightNum,
...this.bottomFrom,
}).then((res) => {
if (res.code == 200) {
this.$message({
......@@ -211,6 +335,7 @@ export default {
padding-bottom: 7px;
margin-bottom: 20px;
border-bottom: 1px solid #bbbbbb00;
position: relative;
.text {
margin-top: 13px;
......@@ -238,6 +363,19 @@ export default {
text-align: right;
}
}
.detail {
position: absolute;
bottom: -20px;
left: 10px;
.textC {
font-weight: 800;
font-size: 18px;
}
.detail-item {
margin-right: 20px;
color: red;
}
}
.table {
flex: 1;
height: 0;
......@@ -257,9 +395,13 @@ export default {
width: 15%;
text-align: center;
}
.type {
width: 10%;
text-align: center;
}
.middle {
width: 60%;
padding-left: 100px;
width: 50%;
padding-left: 50px;
}
.right {
width: 25%;
......@@ -285,9 +427,13 @@ export default {
width: 15%;
text-align: center;
}
.type {
width: 10%;
text-align: center;
}
.middle {
width: 60%;
padding-left: 10px;
width: 50%;
padding-left: 50px;
}
.right {
width: 25%;
......
......@@ -83,7 +83,7 @@
width="180"
>
<template v-slot="{ row: { topicNum, courseId } }">
<div class="timuNum">
<div class="timuNum">
<div v-if="topicNum > 0">{{ `已录入${topicNum}题` }}</div>
<div v-else>未录入</div>
</div>
......@@ -114,7 +114,6 @@
<el-button
:disabled="status == 1"
v-if="status == 0"
size="mini"
type="text"
icon="el-icon-edit"
......@@ -131,7 +130,6 @@
<el-button
:disabled="status == 1"
v-if="status == 0"
size="mini"
type="text"
icon="el-icon-delete"
......@@ -328,7 +326,12 @@ export default {
return getLessonById(courseId);
})
.then((res) => {
if (res.data.qualifiedNum > 0) {
if (
res.data.singleChoiceScore > 0 &&
res.data.multipleChoiceScore > 0 &&
res.data.judgmentScore > 0 &&
res.data.qualifiedNum > 0
) {
return true;
}
})
......@@ -340,7 +343,7 @@ export default {
return testPublish({ courseId, personnelType: 1 });
} else {
this.$message({
message: "请先录入答题合格数",
message: "请先在题目列表录入题目分数跟合格分数",
type: "warning",
});
}
......
<template>
<img :src="src" style=" position: relative;
left: 37%;
top: 10%;
width: 27%;">
</template>
<script>
const src = require('../qRCode/img/qrcode_1673250700723.png')
export default{
computed:{
src(){
return src
}
}
}
</script>
......@@ -35,7 +35,6 @@ module.exports = {
// detail: https://cli.vuejs.org/config/#devserver-proxy
[process.env.VUE_APP_BASE_API]: {
target: process.env.VUE_APP_TARGET,
//target: `http://192.168.31.87:8908/dangerManage`,
changeOrigin: true,
pathRewrite: {
['^' + process.env.VUE_APP_BASE_API]: ''
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment