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

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
+27 -3
View File
@@ -1,10 +1,30 @@
import json
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
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):
"""
主界面
@@ -22,10 +42,14 @@ def to_baiban(request):
return render(request, "html/baiban.html", param)
def to_pinglun(request):
user = request.user
test_date = request.GET.get('id')
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,
"comment_list": comment_list}
"comment_list": comment_list,
"front_code": front_code}
print(test_date)
return render(request, "html/commont.html", param)