예제 #1
0
class GradeDocument(models.Model):
    course = models.ForeignKey(Course, models.PROTECT, related_name='grade_documents', verbose_name=_("Course"))
    file = models.FileField(upload_to=helper_upload_path, verbose_name=_("File"))  # upload_to="grades/{}/".format(course.id),

    MIDTERM_GRADES = 'MID'
    FINAL_GRADES = 'FIN'
    GRADE_DOCUMENT_TYPES = (
        (MIDTERM_GRADES, _('midterm grades')),
        (FINAL_GRADES, _('final grades')),
    )
    type = models.CharField(max_length=3, choices=GRADE_DOCUMENT_TYPES, verbose_name=_('grade type'), default=MIDTERM_GRADES)

    description_de = models.CharField(max_length=255, verbose_name=_("description (german)"))
    description_en = models.CharField(max_length=255, verbose_name=_("description (english)"))
    description = translate(en='description_en', de='description_de')

    last_modified_time = models.DateTimeField(auto_now=True, verbose_name=_("Created"))
    last_modified_user = models.ForeignKey(settings.AUTH_USER_MODEL, models.SET_NULL, related_name="grades_last_modified_user+", null=True, blank=True)

    class Meta:
        verbose_name = _("Grade Document")
        verbose_name_plural = _("Grade Documents")
        unique_together = (
            ('course', 'description_de'),
            ('course', 'description_en')
        )

    def __str__(self):
        return self.description

    def filename(self):
        return os.path.basename(self.file.name)
예제 #2
0
class GradeDocument(models.Model):
    course = models.ForeignKey(Course, models.PROTECT, related_name="grade_documents", verbose_name=_("course"))
    file = models.FileField(upload_to=helper_upload_path, verbose_name=_("File"))

    class Type(models.TextChoices):
        MIDTERM_GRADES = "MID", _("midterm grades")
        FINAL_GRADES = "FIN", _("final grades")

    type = models.CharField(
        max_length=3, choices=Type.choices, verbose_name=_("grade type"), default=Type.MIDTERM_GRADES
    )

    description_de = models.CharField(max_length=255, verbose_name=_("description (german)"))
    description_en = models.CharField(max_length=255, verbose_name=_("description (english)"))
    description = translate(en="description_en", de="description_de")

    last_modified_time = models.DateTimeField(auto_now=True, verbose_name=_("Created"))
    last_modified_user = models.ForeignKey(
        settings.AUTH_USER_MODEL, models.SET_NULL, related_name="grades_last_modified_user+", null=True, blank=True
    )

    class Meta:
        verbose_name = _("Grade Document")
        verbose_name_plural = _("Grade Documents")
        unique_together = [["course", "description_de"], ["course", "description_en"]]

    def __str__(self):
        return self.description

    def filename(self):
        return os.path.basename(self.file.name)
예제 #3
0
class TextAnswerWarning(models.Model):
    warning_text_de = models.CharField(max_length=1024,
                                       verbose_name=_("Warning text (German)"))
    warning_text_en = models.CharField(
        max_length=1024, verbose_name=_("Warning text (English)"))
    warning_text = translate(en='warning_text_en', de='warning_text_de')

    trigger_strings = ArrayField(
        models.CharField(max_length=1024),
        default=list,
        verbose_name=_("Trigger strings (case-insensitive)"),
        blank=True)

    order = models.IntegerField(verbose_name=_("Warning order"), default=-1)

    class Meta:
        ordering = ['order']