Assignment

Qualified name: tin.apps.assignments.models.Assignment

class Assignment(*args, **kwargs)[source]

Bases: Model

An assignment (or quiz) for a student.

If is_quiz is True, this model doubles as a quiz.

The manager for this model is AssignmentQuerySet.

Parameters:

Relationship fields:

Parameters:

Reverse relationships:

Parameters:
  • cooldown_periods (Reverse ForeignKey from CooldownPeriod) – All cooldown periods of this assignment (related name of assignment)

  • quiz (Reverse OneToOneField from Quiz) – The quiz of this assignment (related name of assignment)

  • log_messages (Reverse ForeignKey from QuizLogMessage) – All log messages of this assignment (related name of assignment)

  • moss_results (Reverse ForeignKey from MossResult) – All moss results of this assignment (related name of assignment)

  • submissions (Reverse ForeignKey from Submission) – All submissions of this assignment (related name of assignment)

  • final_submissions (Reverse ForeignKey from PublishedSubmission) – All final submissions of this assignment (related name of assignment)

Methods

check_rate_limit

Check if a student is submitting too quickly

delete_file

Delete a file by id

get_absolute_url

get_file

get_language_display

Shows the label of the language.

get_next_by_assigned

Finds next instance based on assigned.

get_next_by_due

Finds next instance based on due.

get_previous_by_assigned

Finds previous instance based on assigned.

get_previous_by_due

Finds previous instance based on due.

get_quiz_action_display

Shows the label of the quiz_action.

list_files

List all files in the assignments directory

make_assignment_dir

Creates the directory where the assignment grader scripts go.

quiz_ended_for_student

Check if the quiz has ended for a student

quiz_issues_for_student

Check if the student has exceeded the maximum amount of issues they can have with a quiz.

quiz_locked_for_student

Check if the quiz has been locked (e.g. due to leaving the tab).

quiz_open_for_student

Check if a quiz is open for a specific student

save_file

Save some text as a file

save_grader_file

Save the grader file to the correct location.

Attributes

LANGUAGES

QUIZ_ACTIONS

assigned

Type: DateTimeField

cooldown_periods

Type: Reverse ForeignKey from CooldownPeriod

course

Type: ForeignKey to Course

course_id

Internal field, use course instead.

description

Type: CharField

due

Type: DateTimeField

enable_grader_timeout

Type: BooleanField

filename

Type: CharField

final_submissions

Type: Reverse ForeignKey from PublishedSubmission

folder

Type: ForeignKey to Folder

folder_id

Internal field, use folder instead.

grader_file

Type: FileField

grader_has_network_access

Type: BooleanField

grader_log_filename

grader_timeout

Type: IntegerField

has_network_access

Type: BooleanField

hidden

Type: BooleanField

id

Type: BigAutoField

is_quiz

Type: BooleanField

language

Type: CharField

last_action_output

Type: CharField

log_messages

Type: Reverse ForeignKey from QuizLogMessage

markdown

Type: BooleanField

moss_results

Type: Reverse ForeignKey from MossResult

name

Type: CharField

objects

points_possible

Type: DecimalField

quiz

Type: Reverse OneToOneField from Quiz

quiz_action

Type: CharField

quiz_autocomplete_enabled

Type: BooleanField

quiz_description

Type: CharField

quiz_description_markdown

Type: BooleanField

submission_limit_cooldown

Type: PositiveIntegerField

submission_limit_count

Type: PositiveIntegerField

submission_limit_interval

Type: PositiveIntegerField

submissions

Type: Reverse ForeignKey from Submission

venv

Type: ForeignKey to Venv

venv_fully_created

venv_id

Internal field, use venv instead.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

check_rate_limit(student) None[source]

Check if a student is submitting too quickly

delete_file(file_id: int) None[source]

Delete a file by id

list_files() list[tuple[int, str, str, int, datetime]][source]

List all files in the assignments directory

Returns:

  • The index of the assignment

  • The name of the assignment submission

  • The full path to the assignment submission

  • The size of the submission

  • The time at which it was submitted

make_assignment_dir() None[source]

Creates the directory where the assignment grader scripts go.

quiz_ended_for_student(student) bool[source]

Check if the quiz has ended for a student

quiz_issues_for_student(student) bool[source]

Check if the student has exceeded the maximum amount of issues they can have with a quiz.

quiz_locked_for_student(student) bool[source]

Check if the quiz has been locked (e.g. due to leaving the tab)

quiz_open_for_student(student)[source]

Check if a quiz is open for a specific student

save_file(file_text: str, file_name: str) None[source]

Save some text as a file

save_grader_file(grader_text: str) None[source]

Save the grader file to the correct location.

Warning

Writing to files in directories not controlled by us without some form of sandboxing is a security risk. Most notably, users can use symbolic links to trick you into writing to another file, outside the directory. they control. This solution is very hacky, but we don’t have another good way of doing this.