前言
这两周主要开发了教师端的讨论区功能
一、教师端讨论区功能设想
和学生端的讨论区相似,教师端的讨论区同样分为两级。但是最关键的区别是教师有权管理这些讨论,例如说删除一些讨论;为这些讨论评级,这主要是为后面自动化地帮助教师统计学生平时讨论分数而服务。如果教师回复了某位同学的讨论,那就意味着这条讨论为优质讨论,如果教师认为某一条讨论在有“水群”嫌疑,那么教师可以删除这条讨论,系统会自动将这条讨论设置为质量差的讨论。如果教师删除的是1级讨论,那么会将该条1级讨论下面的2级讨论都删除并设置为差评。希望最后根据讨论的数量和质量判定平时的讨论分数。
二、教师端讨论区部分关键代码
1、前端
bad(i, tag) {
this.comments.splice(i, 1);
this.$message({
showClose: true,
type: 'success',
message: '删除成功'
})
console.log(tag)
this.axios({
url: '/teacher/bad',
method: 'post',
transformRequest: [function (data) { //在请求之前对data传参进行格式转换
data = JSON.stringify(data)
return data
}],
data: {
cid: this.class_id,
sid: this.my_user,
tag: tag,
identity: 'teacher',
},
headers: {
'Content-Type': 'application/json;charset=utf-8'
}
}).then(
(res) => {
// 在 then的内部不能使用Vue的实例化的this, 因为在内部 this 没有被绑定。
console.log(res)
},
function (res) {
alert("操作未成功")
console.log(res)
console.log('啊呀,出错啦')
}
)
},
bad2(i,j,tag){
this.comments[i].reply.splice(j, 1);
this.$message({
showClose: true,
type: 'success',
message: '删除成功'
})
console.log(tag)
this.axios({
url: '/teacher/bad2',
method: 'post',
transformRequest: [function (data) { //在请求之前对data传参进行格式转换
data = JSON.stringify(data)
return data
}],
data: {
cid: this.class_id,
sid: this.my_user,
tag: tag,
identity: 'teacher',
},
headers: {
'Content-Type': 'application/json;charset=utf-8'
}
}).then(
(res) => {
// 在 then的内部不能使用Vue的实例化的this, 因为在内部 this 没有被绑定。
console.log(res)
},
function (res) {
alert("操作未成功")
console.log(res)
console.log('啊呀,出错啦')
}
)
},
上述代码是给某一条讨论评定为质量差时的代码
2、后端
@RequestMapping(value = "/teacher/bad", method = RequestMethod.POST) //接口请求的地址
public void getTeacherBad(@RequestBody JSONObject bad) {
String cid = bad.getString("cid");
String sid = bad.getString("sid");
String tag = bad.getString("tag");
teacherService.getTeacherBad(cid,tag);
//System.out.println(list.size());
}
public void getTeacherBad(String cid,String tag) {//[start,end)
teacherMapper.getTeacherBad(cid,tag);
System.out.println("pppppppp");
System.out.println(tag);
System.out.println("pppppppp");
//查这个评论后面跟风的评论,一律设为bad,
List<comment2> list = teacherMapper.getTeacherShow_reply0(cid, tag);
for(comment2 temp:list){
int temptag=temp.getTag();
String taguse=Integer.toString(temptag);
teacherMapper.getTeacherBad(cid,taguse);
}
}
//mapper
void getTeacherBad(String cid,String tag);
//xml
<select id="getTeacherBad" resultType="String">
update comment
set ifgood= 'bad'
where cid=#{cid} tag=#{tag}
</select>