wheel-w / bk-c-course

课程管理系统
11 stars 12 forks source link

题库管理 #3

Open wheel-w opened 2 years ago

wheel-w commented 2 years ago
  1. 新建一个app (question)
  2. 问题建模,参考现有的题目相关的models,简答题支持文件上传,上传(ppt,mp4,word,图片)
  3. 题目也进行tag分组,移除现有分组的概念
mocusez commented 2 years ago

引入 django-taggit打标签,没拿到蓝鲸账号,忘记缺了什么功能:sweat:,题目的Textfield可以是URL链接

from django.db import models
from taggit.managers import TaggableManager

# Create your models here.
class Question(models.Model):
    class Types:
        SINGLE = 'SINGLE'
        MULTIPLE = 'MULTIPLE'
        COMPLETION = 'COMPLETION'
        JUDGE = 'JUDGE'
        SHORT_ANSWER = 'SHORT_ANSWER'

    TYPES = [
        (Types.SINGLE, '单选题'),
        (Types.MULTIPLE, '多选题'),
        (Types.COMPLETION, '填空题'),
        (Types.JUDGE, '判断题'),
        (Types.SHORT_ANSWER, '简答题'),
    ]

    course_id = models.IntegerField('题目所属课程id')
    chapter_id = models.IntegerField('题目所属章节id')
    types = models.CharField('题目类型', max_length=20, choices=TYPES)
    question = models.TextField('题目')
    option_A = models.TextField('选项A', blank=True, null=True)
    option_B = models.TextField('选项B', blank=True, null=True)
    option_C = models.TextField('选项C', blank=True, null=True)
    option_D = models.TextField('选项D', blank=True, null=True)
    option_E = models.TextField('选项E', blank=True, null=True)
    answer = models.TextField('问题答案')
    explain = models.TextField('答案解析', blank=True, null=True, default='无')

    tags = TaggableManager(blank=True)
mocusez commented 2 years ago

image

mocusez commented 2 years ago

出题答题建模

目前看上的富文本编辑器:CKeditor

题库管理建模

mocusez commented 2 years ago

试卷和考试分离开 题库管理建模

mocusez commented 2 years ago

Model比较多,没有好的画UML的工具,这里贴一下model的代码 Qustion:储存问题 QuestionTag,QuestionTagContact:Tag相关 Paper:试卷 Exam: 测试 StudentExamAnswer: 学生答案 StudentExamContact: 学生测验状态

等于允许试卷在不同考试中使用

class Question(models.Model):
    class QuestionTypes:
        SINGLE = "SINGLE"
        MULTIPLE = "MULTIPLE"
        COMPLETION = "COMPLETION"
        JUDGE = "JUDGE"
        SHORT_ANSWER = "SHORT_ANSWER"

    TYPES = [
        (QuestionTypes.SINGLE, "单选题"),
        (QuestionTypes.MULTIPLE, "多选题"),
        (QuestionTypes.COMPLETION, "填空题"),
        (QuestionTypes.JUDGE, "判断题"),
        (QuestionTypes.SHORT_ANSWER, "简答题"),
    ]

    course_id = models.IntegerField("题目所属课程id")
    types = models.CharField("题目类型", max_length=20, choices=TYPES)
    question = models.TextField("题目")
    question_url = models.TextField("题目文件url", null=True, blank=True)
    option_A = models.TextField("选项A", blank=True, null=True)
    option_B = models.TextField("选项B", blank=True, null=True)
    option_C = models.TextField("选项C", blank=True, null=True)
    option_D = models.TextField("选项D", blank=True, null=True)
    option_E = models.TextField("选项E", blank=True, null=True)
    answer = models.TextField("问题答案")
    answer_url = models.TextField("问题答案文件url", null=True, blank=True)
    explain = models.TextField("答案解析", blank=True, null=True, default="无")
    explain_url = models.TextField("答案解析文件url", null=True, blank=True)

    def __str__(self):
        return "{}".format(self.question)

class QuestionTag(models.Model):
    tag_value = models.CharField("标签值", max_length=20)
    tag_color = models.CharField("标签颜色", max_length=7)
    tag_text = models.CharField("标签说明", max_length=200)
    time_created = models.DateTimeField("创建时间", default=timezone.now)
    time_updated = models.DateTimeField("修改时间", auto_now=True)

    def __str__(self):
        return "{}".format(self.tag_value)

class QuestionTagContact(models.Model):
    user_id = models.BigIntegerField("用户id")
    tag_id = models.BigIntegerField("标签id")

    def __str__(self):
        return "{}-{}".format(self.user_id, self.tag_id)

class Paper(models.Model):
    status_list = ["DRAFT", "RELEASE", "MARKED"]

    class Types:
        EXERCISE = "EXERCISE"
        EXAM = "EXAM"

    class Status:
        DRAFT = "DRAFT"
        RELEASE = "RELEASE"
        MARKED = "MARKED"

    TYPES = [(Types.EXERCISE, "练习卷"), (Types.EXAM, "测试卷")]

    STATUS = [(Status.DRAFT, "草稿"), (Status.RELEASE, "已发布"), (Status.MARKED, "已批阅")]

    types = models.CharField("试卷类型", max_length=10, choices=TYPES)
    course_id = models.IntegerField("卷子所属课程id")
    paper_name = models.CharField("卷子名称", max_length=255)
    teacher = models.CharField("教师姓名", max_length=90)
    question_order = models.CharField(
        "存储题目顺序",
        validators=[validate_comma_separated_integer_list],
        max_length=200,
        blank=True,
        null=True,
        default="",
    )

    def __str__(self):
        return self.paper_name

class Exam(models.Model):
    class Status:
        DRAFT = "DRAFT"
        RELEASE = "RELEASE"
        MARKED = "MARKED"

    STATUS = [(Status.DRAFT, "草稿"), (Status.RELEASE, "已发布"), (Status.MARKED, "已批阅")]

    paper_id = models.IntegerField("试卷id")
    create_time = models.DateTimeField("创建时间", auto_now_add=True)
    start_time = models.DateTimeField("开始时间", blank=True, null=True)
    end_time = models.DateTimeField("截止时间", blank=True, null=True)
    status = models.CharField("卷子状态", max_length=10, choices=STATUS)

    def __str__(self):
        return self.id

class StudentExamAnswer(models.Model):
    student_id = models.BigIntegerField("用户id")
    exam_id = models.IntegerField("考试id")
    stu_answers = models.JSONField("学生提交答案")
    individual_score = models.JSONField("学生题目单项得分")
    total_score = models.FloatField("学生总体得分", blank=True, null=True, default=0)

    def __str__(self):
        return "{}-{}".format(self.student_id, self.exam_id)

class StudentExamContact(models.Model):
    class Status:
        NOT_ANSWER = "NOT_ANSWER"
        SAVED = "SAVED"
        SUBMITTED = "SUBMITTED"
        MARKED = "MARKED"

    STATUS = [
        (Status.NOT_ANSWER, "未答题"),
        (Status.SAVED, "已保存"),
        (Status.SUBMITTED, "已提交"),
        (Status.MARKED, "已批改"),
    ]

    course_id = models.IntegerField("课程id")
    paper_id = models.IntegerField("卷子id")
    student_id = models.TextField("学生id")
    status = models.CharField("状态", max_length=10, choices=STATUS)
    score = models.FloatField("总分", blank=True, null=True, default=0)
    cumulative_time = models.DurationField("答题累计时间", default=timedelta(seconds=0))

    def __str__(self):
        return "{}-{}-{}".format(self.course_id, self.paper_id, self.student_id)
mocusez commented 2 years ago

models

YichenWu11 commented 2 years ago

21969194149451655

mocusez commented 2 years ago

2022.4.19 关于项目和项目关系表的建模 project-task

question

mocusez commented 2 years ago

移除question的接口

YichenWu11 commented 2 years ago

693cf377cfd0ecec2b00a068ed3e358 "已撤销"的状态似乎没什么用