diff --git a/college/models/assignment.py b/college/models/assignment.py
index 89aa60e..8f157ac 100644
--- a/college/models/assignment.py
+++ b/college/models/assignment.py
@@ -20,6 +20,13 @@ class SchoolAssignment(models.Model):
ondelete='cascade',
domain="[('state', '=', 'published'), ('teacher_id', '=', uid)]",
help='只能选择自己已发布的课程。')
+ chapter_id = fields.Many2one(
+ 'yuthon.school.course.chapter',
+ string='对应章节',
+ domain="[('course_id', '=', course_id)]",
+ ondelete='set null',
+ index=True,
+ help='该作业所属的课程章节,不选则代表整门课程作业。')
teacher_id = fields.Many2one(
'res.users', string='布置教师',
default=lambda self: self.env.user, required=True)
@@ -111,6 +118,15 @@ class SchoolAssignmentSubmission(models.Model):
_order = 'submit_time desc, id'
_rec_name = 'name'
+ chapter_id = fields.Many2one(
+ 'yuthon.school.course.chapter',
+ string='章节',
+ related='assignment_id.chapter_id',
+ store=True, index=True,
+ )
+
+
+
name = fields.Char(string='提交标题', readonly=True, copy=False)
assignment_id = fields.Many2one(
'yuthon.school.assignment', string='作业', required=True, ondelete='cascade')
diff --git a/college/models/course.py b/college/models/course.py
index fcb67bb..fe31426 100644
--- a/college/models/course.py
+++ b/college/models/course.py
@@ -106,6 +106,20 @@ class SchoolCourse(models.Model):
chapter_count = fields.Integer(
string='章节数', compute='_compute_chapter_count', store=True)
+ # 课程作业:一门课对应多条作业记录
+ assignment_ids = fields.One2many(
+ 'yuthon.school.assignment',
+ 'course_id',
+ string='作业布置',
+ )
+
+ # 学习进展:一门课对应多条学员进度记录
+ progress_ids = fields.One2many(
+ 'yuthon.school.progress',
+ 'course_id',
+ string='学习进展',
+ )
+
@api.depends('student_ids')
def _compute_student_count(self):
for record in self:
diff --git a/college/views/course_views.xml b/college/views/course_views.xml
index b466bfc..b5ffb53 100644
--- a/college/views/course_views.xml
+++ b/college/views/course_views.xml
@@ -33,8 +33,8 @@
invisible="[('state', '!=', 'published')]"/>
-
+
+
@@ -104,6 +104,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/college/views/homework_views.xml b/college/views/homework_views.xml
index 3d559a9..4c8515c 100644
--- a/college/views/homework_views.xml
+++ b/college/views/homework_views.xml
@@ -44,9 +44,13 @@
+
+
@@ -55,6 +59,7 @@
+
@@ -119,7 +124,7 @@
yuthon.school.assignment.submission.list
yuthon.school.assignment.submission
-
+