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
isTrue
, this model doubles as a quiz.The manager for this model is
AssignmentQuerySet
.- Parameters:
id (BigAutoField) – Primary key: ID
name (CharField) – Name
description (CharField) – Description
markdown (BooleanField) – Markdown
language (CharField) – Language
filename (CharField) – Filename
points_possible (DecimalField) – Points possible
assigned (DateTimeField) – Assigned
due (DateTimeField) – Due
hidden (BooleanField) – Hidden
grader_file (FileField) – Grader file
enable_grader_timeout (BooleanField) – Enable grader timeout
grader_timeout (IntegerField) – Grader timeout
grader_has_network_access (BooleanField) – Grader has network access
has_network_access (BooleanField) – Has network access
submission_limit_count (PositiveIntegerField) – Submission limit count
submission_limit_interval (PositiveIntegerField) – Submission limit interval
submission_limit_cooldown (PositiveIntegerField) – Submission limit cooldown
last_action_output (CharField) – Last action output
is_quiz (BooleanField) – Is quiz
quiz_action (CharField) – Quiz action
quiz_autocomplete_enabled (BooleanField) – Quiz autocomplete enabled
quiz_description (CharField) – Quiz description
quiz_description_markdown (BooleanField) – Quiz description markdown
Relationship fields:
- Parameters:
folder (
ForeignKey
toFolder
) – Folder (related name:assignments
)course (
ForeignKey
toCourse
) – Course (related name:assignments
)venv (
ForeignKey
toVenv
) – Venv (related name:assignments
)
Reverse relationships:
- Parameters:
cooldown_periods (Reverse
ForeignKey
fromCooldownPeriod
) – All cooldown periods of this assignment (related name ofassignment
)quiz (Reverse
OneToOneField
fromQuiz
) – The quiz of this assignment (related name ofassignment
)log_messages (Reverse
ForeignKey
fromQuizLogMessage
) – All log messages of this assignment (related name ofassignment
)moss_results (Reverse
ForeignKey
fromMossResult
) – All moss results of this assignment (related name ofassignment
)submissions (Reverse
ForeignKey
fromSubmission
) – All submissions of this assignment (related name ofassignment
)final_submissions (Reverse
ForeignKey
fromPublishedSubmission
) – All final submissions of this assignment (related name ofassignment
)
Methods
Check if a student is submitting too quickly
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 all files in the assignments directory
Creates the directory where the assignment grader scripts go.
Check if the quiz has ended for a student
Check if the student has exceeded the maximum amount of issues they can have with a quiz.
Check if the quiz has been locked (e.g. due to leaving the tab).
Check if a quiz is open for a specific student
Save some text as a file
Save the grader file to the correct location.
Attributes
LANGUAGES
QUIZ_ACTIONS
assigned
Type:
DateTimeField
cooldown_periods
Type: Reverse
ForeignKey
fromCooldownPeriod
course
Type:
ForeignKey
toCourse
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
fromPublishedSubmission
folder
Type:
ForeignKey
toFolder
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
fromQuizLogMessage
markdown
Type:
BooleanField
moss_results
Type: Reverse
ForeignKey
fromMossResult
name
Type:
CharField
objects
points_possible
Type:
DecimalField
quiz
Type: Reverse
OneToOneField
fromQuiz
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
fromSubmission
venv
Type:
ForeignKey
toVenv
venv_fully_created
venv_id
Internal field, use
venv
instead.- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- 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
- 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)
- 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.