添加教师端控制评价标准的功能

This commit is contained in:
2024-05-14 13:45:41 +08:00
parent 463d216962
commit 88d0f1d4b6
7 changed files with 58 additions and 71 deletions
+4 -1
View File
@@ -25,6 +25,7 @@ class CooperationMind(AbstractModel):
deleted = models.BooleanField(verbose_name='是否标记为软删除', default=False) deleted = models.BooleanField(verbose_name='是否标记为软删除', default=False)
class_id = models.IntegerField(verbose_name='脑图所属课程id', null=False, blank=False, default=1) class_id = models.IntegerField(verbose_name='脑图所属课程id', null=False, blank=False, default=1)
belong_to = models.TextField(verbose_name='所属课程-小组', default=json.dumps({'belong': []})) belong_to = models.TextField(verbose_name='所属课程-小组', default=json.dumps({'belong': []}))
comment_type = models.TextField(verbose_name='评论分类', default=json.dumps({'type': []}))
class Meta: class Meta:
db_table = 'cooperation_mind' db_table = 'cooperation_mind'
@@ -106,6 +107,7 @@ class StudentandTercher(AbstractModel):
add_time = models.DateTimeField(verbose_name='添加时间', auto_now_add=True) add_time = models.DateTimeField(verbose_name='添加时间', auto_now_add=True)
class_info = models.CharField(verbose_name='课程信息', max_length=128, null=False, blank=False) class_info = models.CharField(verbose_name='课程信息', max_length=128, null=False, blank=False)
class_status = models.CharField(verbose_name='课程状态', max_length=128, null=False, blank=False) class_status = models.CharField(verbose_name='课程状态', max_length=128, null=False, blank=False)
comment_type = models.TextField(verbose_name='评论分类', default=json.dumps({'type': []}))
# #
class Task(AbstractModel): class Task(AbstractModel):
@@ -127,7 +129,8 @@ class Comment(models.Model): # 定义评论模型
comment_time = models.DateTimeField(auto_now_add=True, verbose_name='评论时间') comment_time = models.DateTimeField(auto_now_add=True, verbose_name='评论时间')
pre_comment = models.ForeignKey('self', on_delete=models.DO_NOTHING, null=True, pre_comment = models.ForeignKey('self', on_delete=models.DO_NOTHING, null=True,
verbose_name='父评论id') # 父级评论,如果没有父级则为空NULL, "self"表示外键关联自己 verbose_name='父评论id') # 父级评论,如果没有父级则为空NULL, "self"表示外键关联自己
# comment_type = models.CharField(verbose_name='评论类型', max_length=1024, null=False, blank=False)
# comment_type = models.TextField(verbose_name='评论类型', default=json.dumps({"type": []}))
class Meta: class Meta:
db_table = 'comment_tb' db_table = 'comment_tb'
verbose_name = '评论' verbose_name = '评论'
+12 -13
View File
@@ -17,14 +17,14 @@ urlpatterns = [
path('2_d', to_detail), # 跳转详情界面 path('2_d', to_detail), # 跳转详情界面
path('s_2_d', share_to_detail), # 从分享链接跳转详细界面 path('s_2_d', share_to_detail), # 从分享链接跳转详细界面
path('2_share', to_share), # 到分享界面 path('2_share', to_share), # 到分享界面
path('2_baiban',to_baiban), # 到协作白板 path('2_baiban', to_baiban), # 到协作白板
path('2_echart',to_echarts), # 到图标界面 path('2_echart', to_echarts), # 到图标界面
path('chat_room',to_chat_room), # 到聊天室界面 path('chat_room', to_chat_room), # 到聊天室界面
path('reng_wu',to_rengwu), # 到任务界面 path('reng_wu', to_rengwu), # 到任务界面
path('ke_cheng',to_kecheng), # 到课程界面 path('ke_cheng', to_kecheng), # 到课程界面
path('2_write',to_write), # 到协同边界页面 path('2_write', to_write), # 到协同边界页面
path('2_pinglun',to_pinglun), # 评论 path('2_pinglun', to_pinglun), # 评论
path('2_admin',to_admin), # 跳转到管理员页面 path('2_admin', to_admin), # 跳转到管理员页面
path('2_star', to_star), # 到收藏界面 path('2_star', to_star), # 到收藏界面
@@ -51,16 +51,15 @@ urlpatterns = [
path('logout', LogoutView.as_view()), # 用户登出 path('logout', LogoutView.as_view()), # 用户登出
# --------------------------------------------------- # ---------------------------------------------------
path('tercher_upload_somthings',TeacherView.as_view()), # 老师端上传一些文件 path('tercher_upload_somthings',TeacherView.as_view()), # 老师端上传一些文件
# --------------------------------------------------- # ---------------------------------------------------
path('post_task/', post_task, name='post_task'), path('post_task/', post_task, name='post_task'),
path('post_kecheng/', post_kecheng, name='post_kecheng'), path('post_kecheng/', post_kecheng, name='post_kecheng'),
path('come_kecheng/',come_kecheng, name='come_kecheng'), path('come_kecheng/', come_kecheng, name='come_kecheng'),
path('comment_control/',comment_control,name='comment_control'), #提交评论处理的路由 path('comment_control/', comment_control,name='comment_control'), #提交评论处理的路由
path('admin_fun/',admin_fun,name='admin_fun'), path('admin_fun/', admin_fun,name='admin_fun'),
path('liuyan_fun/',liuyan_fun,name='liuyan_fun') path('liuyan_fun/', liuyan_fun,name='liuyan_fun')
] ]
+27 -3
View File
@@ -1,10 +1,30 @@
import json import json
from django.shortcuts import render from django.shortcuts import render
from server.models import Task,StudentandTercher,Comment,Liuyan from server.models import Task,StudentandTercher,Comment,Liuyan,CooperationMind
from server_auth.models import MindUser from server_auth.models import MindUser
def front_comment(type):
front_datas = []
if len(type) == 0:
return front_datas
for i in range(len(type)):
front_data = f"""
<div class="rating">
<h1>{type[i]}</h1>
<input type="radio" name="rating{i}" id="5{i}" value="5" />
<label for="5{i}"><i class="icon ion-md-star-outline"></i></label>
<input type="radio" name="ratin{i}" id="4{i}" value="4" />
<label for="4{i}"><i class="icon ion-md-star-outline"></i></label>
<input type="radio" name="rating{i}" id="3{i}" value="3" />
<label for="3{i}"><i class="icon ion-md-star-outline"></i></label>
<input type="radio" name="rating{i}" id="2{i}" value="2" />
<label for="2{i}"><i class="icon ion-md-star-outline"></i></label>
<input type="radio" name="rating{i}" id="1{i}" value="1" />
<label for="1{i}"><i class="icon ion-md-star-outline"></i></label>
</div>"""
front_datas.append(front_data)
return front_datas
def to_dashboard(request): def to_dashboard(request):
""" """
主界面 主界面
@@ -22,10 +42,14 @@ def to_baiban(request):
return render(request, "html/baiban.html", param) return render(request, "html/baiban.html", param)
def to_pinglun(request): def to_pinglun(request):
user = request.user
test_date = request.GET.get('id') test_date = request.GET.get('id')
comment_list = Comment.objects.filter(pinglun_id=test_date) # 从数据库找出该文章的评论数据对象 comment_list = Comment.objects.filter(pinglun_id=test_date) # 从数据库找出该文章的评论数据对象
comment_type = CooperationMind.objects.get(id=test_date).comment_type # 找出对应的comment_type字段
front_code = front_comment((json.loads(comment_type))['type'])
param = {"path": test_date, param = {"path": test_date,
"comment_list": comment_list} "comment_list": comment_list,
"front_code": front_code}
print(test_date) print(test_date)
return render(request, "html/commont.html", param) return render(request, "html/commont.html", param)
+2 -1
View File
@@ -131,6 +131,7 @@ class JsMindView(LoginRequiredJSONMixin, ListAPIView):
data_format = 'node_tree' data_format = 'node_tree'
test_id = 0 test_id = 0
for item1, item2 in zipped_lists: for item1, item2 in zipped_lists:
comment_type = StudentandTercher.objects.get(class_name=item1).comment_type
if (CooperationMind.objects.filter(coop_mind_name=str(item1 + "第" + str(item2) + "小组")).exists()): if (CooperationMind.objects.filter(coop_mind_name=str(item1 + "第" + str(item2) + "小组")).exists()):
print("==========================================================") print("==========================================================")
continue continue
@@ -142,7 +143,7 @@ class JsMindView(LoginRequiredJSONMixin, ListAPIView):
mind = CooperationMind(coop_mind_name=str(item1 + "第" + str(item2) + "小组"), client_uuid='', mind = CooperationMind(coop_mind_name=str(item1 + "第" + str(item2) + "小组"), client_uuid='',
mind_log_id=-1, mind_log_id=-1,
creator_user_id=user.id, snapshot_data=SNAPSHOT_JSON_DATA, creator_user_id=user.id, snapshot_data=SNAPSHOT_JSON_DATA,
data_format=data_format,belong_to=json.dumps({'belong':test})) data_format=data_format,belong_to=json.dumps({'belong':test}),comment_type=comment_type)
mind.save() mind.save()
test_id = mind.id test_id = mind.id
return build_response(data=test_id) return build_response(data=test_id)
+8 -1
View File
@@ -162,8 +162,15 @@ def post_kecheng(request):
tercher_name = request.POST.get("tercher_name") tercher_name = request.POST.get("tercher_name")
class_info = request.POST.get("class_info") class_info = request.POST.get("class_info")
class_status = request.POST.get("class_status") class_status = request.POST.get("class_status")
comment_type = request.POST.get("comment_type")
print("===============================")
print(comment_type)
evaluations = comment_type.split(',')
print(evaluations)
default = json.dumps({'type': evaluations})
rengwu = StudentandTercher(add_time=add_time, class_id=class_id, class_name=class_name, rengwu = StudentandTercher(add_time=add_time, class_id=class_id, class_name=class_name,
tercher_name=tercher_name, class_info=class_info, class_status=class_status) tercher_name=tercher_name, class_info=class_info, class_status=class_status, comment_type=default)
rengwu.save() rengwu.save()
return http.JsonResponse({'code': CODE_SUCCESS, 'msg': '发布成功'}) return http.JsonResponse({'code': CODE_SUCCESS, 'msg': '发布成功'})
else: else:
+3 -52
View File
@@ -93,58 +93,9 @@
<div class="comment_post"> {# 提交评论区域的div #} <div class="comment_post"> {# 提交评论区域的div #}
<div class="rating"> {% for front in front_code %}
<h1>清晰性</h1> {{ front|safe }}
<input type="radio" name="rating" id="5a" value="5" /> {% endfor %}
<label for="5a"><i class="icon ion-md-star-outline"></i></label>
<input type="radio" name="rating" id="4a" value="4" />
<label for="4a"><i class="icon ion-md-star-outline"></i></label>
<input type="radio" name="rating" id="3a" value="3" />
<label for="3a"><i class="icon ion-md-star-outline"></i></label>
<input type="radio" name="rating" id="2a" value="2" />
<label for="2a"><i class="icon ion-md-star-outline"></i></label>
<input type="radio" name="rating" id="1a" value="1" />
<label for="1a"><i class="icon ion-md-star-outline"></i></label>
</div>
<div class="rating">
<h1>准确性</h1>
<input type="radio" name="rating2" id="5b" value="5" />
<label for="5b"><i class="icon ion-md-star-outline"></i></label>
<input type="radio" name="rating2" id="4b" value="4" />
<label for="4b"><i class="icon ion-md-star-outline"></i></label>
<input type="radio" name="rating2" id="3b" value="3" />
<label for="3b"><i class="icon ion-md-star-outline"></i></label>
<input type="radio" name="rating2" id="2b" value="2" />
<label for="2b"><i class="icon ion-md-star-outline"></i></label>
<input type="radio" name="rating2" id="1b" value="1" />
<label for="1b"><i class="icon ion-md-star-outline"></i></label>
</div>
<div class="rating">
<h1>稳定性</h1>
<input type="radio" name="rating3" id="5c" value="5" />
<label for="5c"><i class="icon ion-md-star-outline"></i></label>
<input type="radio" name="rating3" id="4c" value="4" />
<label for="4c"><i class="icon ion-md-star-outline"></i></label>
<input type="radio" name="rating3" id="3c" value="3" />
<label for="3c"><i class="icon ion-md-star-outline"></i></label>
<input type="radio" name="rating3" id="2c" value="2" />
<label for="2c"><i class="icon ion-md-star-outline"></i></label>
<input type="radio" name="rating3" id="1c" value="1" />
<label for="1c"><i class="icon ion-md-star-outline"></i></label>
</div>
<div class="rating">
<h1>可靠性</h1>
<input type="radio" name="rating4" id="5d" value="5" />
<label for="5d"><i class="icon ion-md-star-outline"></i></label>
<input type="radio" name="rating4" id="4d" value="4" />
<label for="4d"><i class="icon ion-md-star-outline"></i></label>
<input type="radio" name="rating4" id="3d" value="3" />
<label for="3d"><i class="icon ion-md-star-outline"></i></label>
<input type="radio" name="rating4" id="2d" value="2" />
<label for="2d"><i class="icon ion-md-star-outline"></i></label>
<input type="radio" name="rating4" id="1d" value="1" />
<label for="1d"><i class="icon ion-md-star-outline"></i></label>
</div>
<div id="commentform_title">发表评论</div> <div id="commentform_title">发表评论</div>
<textarea rows="10" cols="60" id="comment_content"></textarea> <textarea rows="10" cols="60" id="comment_content"></textarea>
<p><button>提交评论</button></p> <p><button>提交评论</button></p>
+2
View File
@@ -638,6 +638,7 @@
<td><h6>老师名称</h6></td> <td><h6>老师名称</h6></td>
<td><h6>课程介绍</h6></td> <td><h6>课程介绍</h6></td>
<td><h6>课程状态</h6></td> <td><h6>课程状态</h6></td>
<td><h6>课程评价标准(之间用逗号(,)隔开)</h6></td>
<td><h6>操作</h6></td> <td><h6>操作</h6></td>
</tr> </tr>
<tr style="text-align: center;"> <tr style="text-align: center;">
@@ -651,6 +652,7 @@
<option value="未开课">未开课</option> <option value="未开课">未开课</option>
</select> </select>
</td> </td>
<td><input type="text" name="comment_type"></td>
<td><button type="submit" class="niceButton4">发布课程</button></td> <td><button type="submit" class="niceButton4">发布课程</button></td>
</tr> </tr>