diff --git a/SSCM/SSCM/__pycache__/settings.cpython-312.pyc b/SSCM/SSCM/__pycache__/settings.cpython-312.pyc index 5f1ba6b..c3d9777 100644 Binary files a/SSCM/SSCM/__pycache__/settings.cpython-312.pyc and b/SSCM/SSCM/__pycache__/settings.cpython-312.pyc differ diff --git a/SSCM/SSCM/settings.py b/SSCM/SSCM/settings.py index 2befd98..847cf29 100644 --- a/SSCM/SSCM/settings.py +++ b/SSCM/SSCM/settings.py @@ -66,6 +66,7 @@ TEMPLATES = [ 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], + 'builtins': ['django.templatetags.static'] }, }, ] diff --git a/SSCM/__pycache__/manage.cpython-312.pyc b/SSCM/__pycache__/manage.cpython-312.pyc new file mode 100644 index 0000000..12b8bfe Binary files /dev/null and b/SSCM/__pycache__/manage.cpython-312.pyc differ diff --git a/SSCM/course/__pycache__/cbvs.cpython-312.pyc b/SSCM/course/__pycache__/cbvs.cpython-312.pyc index 8f75e8c..346880f 100644 Binary files a/SSCM/course/__pycache__/cbvs.cpython-312.pyc and b/SSCM/course/__pycache__/cbvs.cpython-312.pyc differ diff --git a/SSCM/course/__pycache__/forms.cpython-312.pyc b/SSCM/course/__pycache__/forms.cpython-312.pyc index 850541a..aede4ac 100644 Binary files a/SSCM/course/__pycache__/forms.cpython-312.pyc and b/SSCM/course/__pycache__/forms.cpython-312.pyc differ diff --git a/SSCM/course/__pycache__/models.cpython-312.pyc b/SSCM/course/__pycache__/models.cpython-312.pyc index 21e03b7..fa5f565 100644 Binary files a/SSCM/course/__pycache__/models.cpython-312.pyc and b/SSCM/course/__pycache__/models.cpython-312.pyc differ diff --git a/SSCM/course/__pycache__/urls.cpython-312.pyc b/SSCM/course/__pycache__/urls.cpython-312.pyc index aa9acc5..59c3428 100644 Binary files a/SSCM/course/__pycache__/urls.cpython-312.pyc and b/SSCM/course/__pycache__/urls.cpython-312.pyc differ diff --git a/SSCM/course/__pycache__/views.cpython-312.pyc b/SSCM/course/__pycache__/views.cpython-312.pyc index 0344ef8..eaceeee 100644 Binary files a/SSCM/course/__pycache__/views.cpython-312.pyc and b/SSCM/course/__pycache__/views.cpython-312.pyc differ diff --git a/SSCM/course/cbvs.py b/SSCM/course/cbvs.py index 2635c41..86ea145 100644 --- a/SSCM/course/cbvs.py +++ b/SSCM/course/cbvs.py @@ -15,6 +15,7 @@ class ScoreUpdateView(UpdateView): self.object = self.get_object() title = "给分" + if request.GET.get("update"): title = "修改成绩" @@ -28,7 +29,7 @@ class ScoreUpdateView(UpdateView): "kind": "teacher", } - return_url = reverse("view_detail", kwargs={"course_id": self.object.course_id}) + return_url = reverse("view_detail", kwargs={"course_id": self.object.course.id}) return self.render_to_response(self.get_context_data( info=info, @@ -65,20 +66,18 @@ class RateUpdateView(UpdateView): def get_success_url(self): return reverse("view_course", kwargs={"view_kind": "is_end"}) -class StudentCourseDetailView(DetailView): - model=StudentCourse - template_name= "course/student/course.html" - def get(self,requset,*args,**kwargs): - self.object=self.get_object() - context=self.get_context_data(object=self.object) +class StudentCourseDetailView(DetailView): + model = StudentCourse + template_name = "course/student/course.html" + def get(self, request, *args, **kwargs): + self.object = self.get_object() + context = self.get_context_data(object=self.object) if self.object: - context["info"]={ - "name":self.object.student.name, - "kind":"student" + context["info"] = { + "name": self.object.student.name, + "kind": "student" } return self.render_to_response(context) - - diff --git a/SSCM/course/urls.py b/SSCM/course/urls.py index 922b71e..44c9025 100644 --- a/SSCM/course/urls.py +++ b/SSCM/course/urls.py @@ -1,20 +1,20 @@ from django.urls import path -from course import views,cbvs +from course.views import * +from course.cbvs import ScoreUpdateView,RateUpdateView,StudentCourseDetailView urlpatterns = [ - path('/', views.home, name="course"), - path('teacher/create_course',views.create_course,name="create_course"), - path('teacher/view_detail/', views.view_detail, name="view_detail"), - path('teacher/create_schedule/', views.create_schedule, name="create_schedule"), - path('teacher/delete_schedule/', views.delete_schedule, name="delete_schedule"), - path('teacher/score/', cbvs.ScoreUpdateView.as_view(), name="score"), - path('teacher/handle_course//', - views.handle_course, name="handle_course"), + path('/', home, name="course"), + path('teacher/create_course',create_course,name="create_course"), + path('teacher/view_detail/', view_detail, name="view_detail"), + path('teacher/create_schedule/', create_schedule, name="create_schedule"), + path('teacher/delete_schedule/', delete_schedule, name="delete_schedule"), + path('teacher/score/', ScoreUpdateView.as_view(), name="score"), + path('teacher/handle_course//',handle_course, name="handle_course"), - path('student/view/', views.view_course, name="view_course"), - path("student/operate//",views.operate_course,name="operate_course"), + path('student/view/', view_course, name="view_course"), + path("student/operate//",operate_course,name="operate_course"), - path("student/evaluate/",cbvs.RateUpdateView.as_view(),name="evaluate"), - path("student/view_detail/",cbvs.StudentCourseDetailView.as_view(),name="view_detail") + path("student/evaluate/",RateUpdateView.as_view(),name="evaluate"), + path("student/view_detail/",StudentCourseDetailView.as_view(),name="sview_detail") ] \ No newline at end of file diff --git a/SSCM/course/views.py b/SSCM/course/views.py index 532ebc4..a8bfe9c 100644 --- a/SSCM/course/views.py +++ b/SSCM/course/views.py @@ -1,5 +1,5 @@ from django.http import HttpResponse -from django.shortcuts import redirect, render +from django.shortcuts import redirect, render,reverse from django.db.models import Q from django.utils import timezone @@ -62,7 +62,6 @@ def teacher_home(request): context = { "info": info - } q = Q(teacher=user) @@ -147,6 +146,7 @@ def delete_schedule(request, schedule_id): return redirect("login", kind=kind) schedule = Schedule.objects.get(pk=schedule_id) + course_id = request.GET.get("course_id") or schedule.course_id schedule.delete() @@ -162,13 +162,13 @@ def handle_course(request, course_id, handle_kind): info = { "name": user.name, - "kind": kind + "kind": kind, } course = Course.objects.get(pk=course_id) if course.status == handle_kind and course.status < 5: if course.status == 4: - scs = StudentCourse.objects.filter(Q(course=course)&Q(with_draw=False)) + scs = StudentCourse.objects.filter(course=course) all_given = True res = "" for sc in scs: @@ -179,7 +179,7 @@ def handle_course(request, course_id, handle_kind): if all_given: course.status += 1 course.save() - return redirect("view.detail", course_id=course_id) + return redirect("view_detail", course_id=course_id) else: return HttpResponse(res) @@ -187,13 +187,9 @@ def handle_course(request, course_id, handle_kind): course.status += 1 course.save() - # course_list = Course.objects.filter(teacher=user) - # - # context = {"info": info, - # "course_list": course_list, - # "course_id": course_id} - # print("Context:", context) - return redirect("course", kind="teacher") + course_list = Course.objects.filter(teacher=user) + # return render(request, 'course/teacher/home.html', {'info': info, 'course_list': course_list}) + return redirect("course",kind=kind) def view_detail(request, course_id): @@ -208,17 +204,17 @@ def view_detail(request, course_id): } course = Course.objects.get(pk=course_id) - c_stu_list = StudentCourse.objects.filter(Q(course=course)&Q(with_draw=False)) + c_stu_list = StudentCourse.objects.filter(Q(course=course) & Q(with_draw=False)) sche_list = Schedule.objects.filter(course=course) context = { "info": info, "course": course, - "course_student": c_stu_list, + "course_students": c_stu_list, "schedules": sche_list } if course.status == 5: - sorted_cs_list = sorted(c_stu_list, key=lambda cs: cs.score) + sorted_cs_list = sorted(c_stu_list, key=lambda cs: cs.scores) context["sorted_course_student"] = sorted_cs_list return render(request, "course/teacher/course.html", context) @@ -302,6 +298,5 @@ def operate_course(request, operate_kind, course_id): course.with_draw = True course.with_draw_time = timezone.now() course.save() - print("Course ID:", course_id) - print("Operation Kind:", operate_kind) + return redirect("view_course", view_kind=operate_kind) diff --git a/SSCM/db.sqlite3 b/SSCM/db.sqlite3 index 4d54922..8415bec 100644 Binary files a/SSCM/db.sqlite3 and b/SSCM/db.sqlite3 differ diff --git a/SSCM/static/css/nav.css b/SSCM/static/css/nav.css index 0c2e14f..9a68ad8 100644 --- a/SSCM/static/css/nav.css +++ b/SSCM/static/css/nav.css @@ -14,9 +14,13 @@ body { .nav { background: #4a2c98; + position: fixed; width: 100%; + color: #ccc; + z-index: 1; } + .nav a { color: #ccc; text-decoration: unset; diff --git a/SSCM/templates/course/nav.html b/SSCM/templates/course/nav.html index 0fe7633..5e250ac 100644 --- a/SSCM/templates/course/nav.html +++ b/SSCM/templates/course/nav.html @@ -1,6 +1,7 @@ {% load static %} + diff --git a/SSCM/templates/course/student/course.html b/SSCM/templates/course/student/course.html index 9a2914e..40316ce 100644 --- a/SSCM/templates/course/student/course.html +++ b/SSCM/templates/course/student/course.html @@ -1,65 +1,47 @@ {% extends "course/nav.html" %} +{% load static %} {% block title %}课程详情{% endblock %} + {% block content %} -

课程详情

-
    -
  • - 课程编号 - {{ object.course.id }} -
  • -
  • - 课程名 - {{ object.course.name }} -
  • -
  • - 学分 - {{ object.course.credit }} -
  • -
  • - 课程人数/最大人数 - {{ object.course.get_current_count }}/{{ object.course.max_number }} -
  • -
  • - 年份 - {{ object.course.year }} -
  • -
  • - 学期 - {{ object.course.get_semester_display }} -
  • -
  • - 教师 - {{ object.course.teacher.name }} -
  • -
  • - 上课时间 - - {% for schedule in object.course.get_schedules %} -
    {{ schedule }}
    - {% endfor %} -
    -
  • -
  • - 得分 - {% if object.scores != None %}{{ object.scores }} - {% else %} - {% endif %} -
  • -
  • - 评语 - {% if object.comments != None %}{{ object.comments }} - {% else %} - {% endif %} -
  • -
  • - 学生评分 - {% if object.rating != None %}{{ object.rating }} - {% else %} - {% endif %} -
  • -
  • - 学生评价 - {% if object.assessment != None %}{{ object.assessment }} - {% else %} - {% endif %} -
  • -
- +

课程详情

+
    +
  • 课程编号{{ object.course.id }}
  • +
  • 课程名{{ object.course.name }}
  • +
  • 学分{{ object.course.credit }}
  • +
  • 课程人数/最大人数 + {{ object.course.get_current_count }}/{{ object.course.max_number }}
  • +
  • 年份{{ object.course.year }}
  • +
  • 学期{{ object.course.get_semester_display }}
  • + +
  • 教师{{ object.course.teacher.name }}
  • +
  • 上课时间 + + {% for schedule in object.course.get_schedules %} +
    {{ schedule }}
    + {% endfor %} +
    +
  • +
  • + 得分 + {% if object.scores != None %}{{ object.scores }} + {% else %} - {% endif %} +
  • +
  • + 评语 + {% if object.comments != None %}{{ object.comments }} + {% else %} - {% endif %} +
  • +
  • + 学生评分 + {% if object.rating != None %}{{ object.rating }} + {% else %} - {% endif %} +
  • +
  • + 学生评价 + {% if object.assessment != None %}{{ object.assessment }} + {% else %} - {% endif %} +
  • +
+ {% endblock %} \ No newline at end of file diff --git a/SSCM/templates/course/student/home.html b/SSCM/templates/course/student/home.html index cc69114..9c3b20e 100644 --- a/SSCM/templates/course/student/home.html +++ b/SSCM/templates/course/student/home.html @@ -1,5 +1,7 @@ {% extends "course/nav.html" %} +{% load static %} {% block title %}主页{% endblock %} + {% block content %}
@@ -67,8 +69,13 @@ {{ sc.course.credit }} {{ sc.course.year }}{{ sc.get_semester_display }} {{ sc.course.teacher.name }} - {{ sc.scores }} - {{ sc.comments }} + {% if sc.scores == None %} + - + - + {% else %} + {{ sc.scores }} + {{ sc.comments }} + {% endif %} {% if sc.rating == None %} - - @@ -76,7 +83,7 @@ + onclick='window.open("{% url 'evaluate' sc.id %}")' /> {% else %} {{ sc.rating }} @@ -107,11 +114,11 @@ {% if view_kind == "select" %} + onclick="location.href='{% url 'operate_course' course.id 'select' %}'"> {% endif %} {% if view_kind == "withdraw" %} + onclick="location.href='{% url 'operate_course' course.id 'withdraw' %}'"> {% endif %} {% if view_kind == "current" %}-{% endif %} diff --git a/SSCM/templates/course/student/rating.html b/SSCM/templates/course/student/rating.html index 4fb73d2..a641918 100644 --- a/SSCM/templates/course/student/rating.html +++ b/SSCM/templates/course/student/rating.html @@ -1,5 +1,7 @@ {% extends "course/nav.html" %} +{% load static %} {% block title %}评教{% endblock %} + {% block content %}

评教

diff --git a/SSCM/templates/course/teacher/course.html b/SSCM/templates/course/teacher/course.html index fc233dd..0a7b6f1 100644 --- a/SSCM/templates/course/teacher/course.html +++ b/SSCM/templates/course/teacher/course.html @@ -1,7 +1,7 @@ {% extends "course/nav.html" %} -{% block title %} - 课程详情 -{% endblock %} +{% load static %} +{% block title %}课程详情{% endblock %} + {% block content %}

课程详情

@@ -27,8 +27,9 @@ -

上课时间

+ +

上课时间

@@ -38,73 +39,75 @@ - {% for schedule in schedules %} - - - - - - {% endfor %} + {% for schedule in schedules %} + + + + + + {% endfor %}
{{ schedule.id }}{{ schedule }} - -
{{ schedule.id }}{{ schedule }} + +

学生列表 {% if course.status == 4 %} - + + {{ course.status }} {% endif %}

- - - - - - - - + + + + + + + + - {% for cs in course_students %} - - - - - - - + + + + + + - - {% endfor %} + + + {% endfor %} -
学生学号学生姓名学生邮箱得分评语操作
学生学号学生姓名学生邮箱得分评语操作
{{ cs.student.get_id }}{{ cs.student.name }}{{ cs.student.email }}{% if cs.scores == None %} - {% else %} {{ cs.scores }} {% endif %} {% if cs.scores == None %} - {% else %} {{ cs.comments }} {% endif %} - {% if course.status == 4 %} - {% if sc.scores == None %} - + {% for cs in course_students %} +
{{ cs.student.get_id }}{{ cs.student.name }}{{ cs.student.email }}{% if cs.scores == None %} - {% else %} {{ cs.scores }} {% endif %} {% if cs.scores == None %} - {% else %} {{ cs.comments }} {% endif %} + {% if course.status == 4 %} + {% if sc.scores == None %} + + {% else %} + + + {% endif %} {% else %} - - + - {% endif %} - {% else %} - - {% endif %} -
+ + {% if course.status == 5 %}

学生评价

- - - - + + + + - {% for cs in sorted_course_students %} + {% for cs in sorted_course_student %} {% if cs.rating != None %} diff --git a/SSCM/templates/course/teacher/create_course.html b/SSCM/templates/course/teacher/create_course.html index 6f8f872..c6d16fc 100644 --- a/SSCM/templates/course/teacher/create_course.html +++ b/SSCM/templates/course/teacher/create_course.html @@ -1,5 +1,7 @@ {% extends "course/nav.html" %} +{% load static %} {% block title %}创建课程{% endblock %} + {% block content %}

创建课程

diff --git a/SSCM/templates/course/teacher/create_schedule.html b/SSCM/templates/course/teacher/create_schedule.html index bdb72da..1f86fc8 100644 --- a/SSCM/templates/course/teacher/create_schedule.html +++ b/SSCM/templates/course/teacher/create_schedule.html @@ -1,5 +1,7 @@ {% extends "course/nav.html" %} +{% load static %} {% block title %}创建时刻表{% endblock %} + {% block content %}

创建时刻表:    [{{ course.id }}]{{ course.name }}

diff --git a/SSCM/templates/course/teacher/home.html b/SSCM/templates/course/teacher/home.html index b901981..8d7e288 100644 --- a/SSCM/templates/course/teacher/home.html +++ b/SSCM/templates/course/teacher/home.html @@ -1,7 +1,7 @@ {% extends "course/nav.html" %} -{% block title %} - 主页 -{% endblock %} +{% load static %} +{% block title %}主页{% endblock %} + {% block content %}
@@ -43,11 +43,15 @@ + + {% endif %} + {% if course.status == 4 %} + + {% else %} + {% endif %} -
{% endfor %} diff --git a/SSCM/templates/course/teacher/score.html b/SSCM/templates/course/teacher/score.html index 6f9b003..3d5eccc 100644 --- a/SSCM/templates/course/teacher/score.html +++ b/SSCM/templates/course/teacher/score.html @@ -1,7 +1,9 @@ {% extends "course/nav.html" %} +{% load static %} {% block title %} {{ title }} {% endblock %} + {% block content %}

{{ title }}

学生评分学生评价
学生评分学生评价ss
{{ cs.rating }}